-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated imports and reworked diaries page slightly.
- Loading branch information
1 parent
c300b6f
commit 396b491
Showing
4 changed files
with
74 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,64 @@ | ||
'use client'; | ||
|
||
import { useSuspenseQuery } from '@apollo/experimental-nextjs-app-support/ssr'; | ||
import { gql } from '@apollo/client'; | ||
import Diaries from '@/src/components/diaries/Diaries'; | ||
import { | ||
Diary, | ||
ReadDiariesQuery, | ||
ReadDiariesQueryVariables, | ||
} from '@/src/@types/__graphqlTypes__/graphql'; | ||
|
||
const DIARIES_QUERY = gql` | ||
query ReadDiaries($take: Int!, $skip: Int!) { | ||
readDiaries(take: $take, skip: $skip) { | ||
code | ||
success | ||
message | ||
data { | ||
createdDate | ||
updatedDate | ||
deletedDate | ||
version | ||
id | ||
userId | ||
title | ||
notes { | ||
createdDate | ||
updatedDate | ||
deletedDate | ||
version | ||
id | ||
diaryId | ||
title | ||
text | ||
images { | ||
url | ||
title | ||
} | ||
} | ||
} | ||
count | ||
} | ||
} | ||
`; | ||
|
||
const DiariesPage = () => { | ||
return <Diaries />; | ||
const { data, error } = useSuspenseQuery< | ||
ReadDiariesQuery, | ||
ReadDiariesQueryVariables | ||
>(DIARIES_QUERY, { | ||
variables: { take: 10, skip: 0 }, | ||
}); | ||
|
||
if (error) return <p>Error loading diaries: {error.message}</p>; | ||
if (!data || !data.readDiaries || !data.readDiaries.data) | ||
return <p>No data available</p>; | ||
const filteredData = data.readDiaries.data.filter( | ||
(diary): diary is Diary => diary !== null | ||
); | ||
|
||
return <Diaries diariesData={filteredData} />; | ||
}; | ||
|
||
export default DiariesPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
'use client'; | ||
|
||
import { ApolloLink, HttpLink } from '@apollo/client'; | ||
import { | ||
ApolloNextAppProvider, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters