-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- change logic to display link to demo project
- Loading branch information
1 parent
a128a1c
commit 3370e7a
Showing
4 changed files
with
75 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { QueryFunctionContext, useQuery } from "@tanstack/react-query"; | ||
import api, { PROJECTS_REST_ENDPOINT, QueryConfig } from "@/api/api"; | ||
import { Project } from "@/types/projects"; | ||
import { DEMO_PROJECT_NAME } from "@/constants/shared"; | ||
|
||
type UseDemoProjectParams = { | ||
workspaceName: string; | ||
}; | ||
|
||
const getDemoProject = async ( | ||
{ signal }: QueryFunctionContext, | ||
params: UseDemoProjectParams, | ||
) => { | ||
try { | ||
const { data } = await api.post<Project | null>( | ||
`${PROJECTS_REST_ENDPOINT}retrieve`, | ||
{ | ||
name: DEMO_PROJECT_NAME, | ||
}, | ||
{ | ||
signal, | ||
}, | ||
); | ||
|
||
return data; | ||
} catch (e) { | ||
return null; | ||
} | ||
}; | ||
|
||
export default function useDemoProject( | ||
params: UseDemoProjectParams, | ||
options?: QueryConfig<Project | null>, | ||
) { | ||
return useQuery({ | ||
queryKey: ["project", params], | ||
queryFn: (context) => getDemoProject(context, params), | ||
...options, | ||
}); | ||
} |
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
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