-
-
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.
- Loading branch information
1 parent
bc16a70
commit df9b1ae
Showing
45 changed files
with
904 additions
and
638 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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const delay = async (timeout: number) => | ||
await new Promise((resolve) => setTimeout(resolve, timeout)); |
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
30 changes: 0 additions & 30 deletions
30
apps/storybook/src/stories/notion/workspace-provider/_components/use-documents.ts
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
apps/storybook/src/stories/notion/workspace-provider/_components/use-pages.ts
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useState } from "react"; | ||
import useSWR from "swr"; | ||
|
||
import { documents, mockPages } from "@swy/notion/mock"; | ||
import { useTree, type TreeItemData } from "@swy/ui/shared"; | ||
|
||
const fetcher = () => Promise.resolve(documents); | ||
|
||
export const usePages = (workspaceId: string) => { | ||
const tree = useTree(); | ||
const [pageId, setPageId] = useState("#"); | ||
|
||
const { isLoading } = useSWR<TreeItemData[], Error>(workspaceId, fetcher, { | ||
onSuccess: (data) => tree.set(data), | ||
onError: (e) => console.log(`[swr:workspace]: ${e.message}`), | ||
}); | ||
const fetchPages = () => Promise.resolve(Object.values(mockPages)); | ||
const selectPage = (path: string) => { | ||
const [, , id] = path.split("/"); | ||
if (!id) return; | ||
setPageId(id); | ||
}; | ||
|
||
return { pageId, isLoading, fetchPages, selectPage }; | ||
}; |
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
Oops, something went wrong.