-
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.
chore(canvas): refactor project page
- Loading branch information
Showing
37 changed files
with
870 additions
and
509 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,25 @@ | ||
import clsx from "clsx"; | ||
import React from "react"; | ||
|
||
export type TContainerWithTextCenterProps = React.HTMLProps<HTMLDivElement> & { | ||
paragraphProps?: Omit<React.HTMLProps<HTMLParagraphElement>, "children">; | ||
}; | ||
|
||
export function ContainerWithTextCenter(props: TContainerWithTextCenterProps) { | ||
const { className, children, paragraphProps, ...rest } = props; | ||
const { className: pClassName, ...pRest } = props; | ||
|
||
return ( | ||
<div | ||
className={clsx( | ||
"flex-1 flex flex-col justify-center items-center font-thin text-3xl", | ||
className | ||
)} | ||
{...rest} | ||
> | ||
<p className={clsx("text-center", pClassName)} {...pRest}> | ||
{children} | ||
</p> | ||
</div> | ||
); | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
canvas/app/dashboard/project/all/all-projects-skeleton.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
import { PageContainer } from "@/app/dashboard/_layout/page-container"; | ||
|
||
export function AllProjectsContainer(props: React.PropsWithChildren) { | ||
const { children } = props; | ||
return ( | ||
<PageContainer className="gap-8 py-0 grid grid-cols-1 md:py-8 md:px-0 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4"> | ||
{children} | ||
</PageContainer> | ||
); | ||
} |
89 changes: 89 additions & 0 deletions
89
canvas/app/dashboard/project/all/components/create-project/content.tsx
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,89 @@ | ||
"use client"; | ||
|
||
import { Modal } from "@/components/custom/modal"; | ||
import { CreateProjectForm } from "./form"; | ||
import { Button } from "@/components/ui/button"; | ||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
import { | ||
createProject, | ||
GET_PROJECT_QUERY_KEY, | ||
TProject, | ||
} from "@/services/projects"; | ||
import { useRouter } from "next/navigation"; | ||
import React from "react"; | ||
import { TCreateProjectFormData } from "@/schema/create-project"; | ||
import { Alert } from "@/components/custom/alert"; | ||
import { PROJECT_URL } from "@/constants/routes"; | ||
|
||
const formID = "create-project-form"; | ||
|
||
export function CreateProjectContent() { | ||
const { push } = useRouter(); | ||
const queryClient = useQueryClient(); | ||
|
||
const handleOnCreateProjectSuccess = React.useCallback( | ||
async (data: TProject) => { | ||
/** | ||
* Invalidating queries, as after creating new | ||
* project we want to fetch it. | ||
*/ | ||
await queryClient.invalidateQueries({ | ||
queryKey: [GET_PROJECT_QUERY_KEY], | ||
}); | ||
|
||
setTimeout(() => { | ||
push(`${PROJECT_URL}/${data.id}`); | ||
}, 3000); | ||
}, | ||
[push] | ||
); | ||
|
||
const { | ||
isError: hasErrorDuringCreatingProject, | ||
isSuccess: hasCreatedProjectSuccessfully, | ||
isPending: isSubmittingCreateProjectForm, | ||
mutate: createNewProject, | ||
} = useMutation({ | ||
mutationFn: createProject, | ||
onSuccess: handleOnCreateProjectSuccess, | ||
}); | ||
|
||
const handleSubmit = React.useCallback((data: TCreateProjectFormData) => { | ||
createNewProject(data); | ||
}, []); | ||
|
||
return ( | ||
<Modal | ||
title="Create a new project" | ||
trigger={<Button>Create Project</Button>} | ||
hasCloseButtonInFooter | ||
actions={[ | ||
<Button className="my-1" type="submit" form={formID}> | ||
Create | ||
</Button>, | ||
]} | ||
> | ||
{hasErrorDuringCreatingProject && ( | ||
<Alert | ||
variant="destructive" | ||
title="Error!" | ||
description=" Something went wrong while creating the project. Please try again after sometime." | ||
/> | ||
)} | ||
|
||
{hasCreatedProjectSuccessfully && ( | ||
<Alert | ||
variant="default" | ||
title="Success!" | ||
description="Project created successfully." | ||
/> | ||
)} | ||
|
||
<CreateProjectForm | ||
onSubmit={handleSubmit} | ||
formID={formID} | ||
isSubmitting={isSubmittingCreateProjectForm} | ||
/> | ||
</Modal> | ||
); | ||
} |
Oops, something went wrong.