-
Notifications
You must be signed in to change notification settings - Fork 1
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
7eff60c
commit 8c31be2
Showing
11 changed files
with
283 additions
and
8 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
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
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,79 @@ | ||
"use client"; | ||
|
||
import { api } from "@/convex/_generated/api"; | ||
import { useApiMutation } from "@/hooks/use-api-mutations"; | ||
import { UseRenameModal } from "@/store/use-rename-modal"; | ||
import { FormEventHandler, useEffect, useState } from "react"; | ||
import { toast } from "sonner"; | ||
import { Button } from "../ui/button"; | ||
import { | ||
Dialog, | ||
DialogClose, | ||
DialogContent, | ||
DialogDescription, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
} from "../ui/dialog"; | ||
import { Input } from "../ui/input"; | ||
|
||
type Props = {}; | ||
|
||
function RenameModal({}: Props) { | ||
const { mutate, pending } = useApiMutation(api.board.update); | ||
const { isOpen, onClose, initialValues } = UseRenameModal(); | ||
const [title, setTitle] = useState(initialValues.title); | ||
|
||
useEffect(() => { | ||
setTitle(initialValues.title); | ||
}, [initialValues.title]); | ||
|
||
const onSubmit: FormEventHandler<HTMLFormElement> = (e) => { | ||
e.preventDefault(); | ||
|
||
mutate({ | ||
id: initialValues.id, | ||
title, | ||
}) | ||
.then(() => { | ||
toast.success("Board Rename"); | ||
onClose(); | ||
}) | ||
.catch((error) => { | ||
toast.error("failed To Rename To Board"); | ||
}); | ||
}; | ||
|
||
return ( | ||
<Dialog open={isOpen} onOpenChange={onClose}> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>Edit Board Tittle</DialogTitle> | ||
</DialogHeader> | ||
<DialogDescription>Enter New Tittle for this board</DialogDescription> | ||
<form className="space-y-4" onSubmit={onSubmit}> | ||
<Input | ||
disabled={pending} | ||
required | ||
maxLength={60} | ||
value={title} | ||
onChange={(e) => setTitle(e.target.value)} | ||
placeholder="Board Title" | ||
/> | ||
<DialogFooter> | ||
<DialogClose asChild> | ||
<Button type="button" variant="outline"> | ||
Cancel | ||
</Button> | ||
</DialogClose> | ||
<Button disabled={pending} type="submit"> | ||
Save | ||
</Button> | ||
</DialogFooter> | ||
</form> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} | ||
|
||
export default RenameModal; |
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
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,26 @@ | ||
"use client"; | ||
|
||
import RenameModal from "@/components/modal/rename-modal"; | ||
import { useEffect, useState } from "react"; | ||
|
||
type Props = {}; | ||
|
||
function ModelProvider({}: Props) { | ||
const [isMounted, setIsMounted] = useState(false); | ||
|
||
useEffect(() => { | ||
setIsMounted(true); | ||
}, []); | ||
|
||
if (!isMounted) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<RenameModal /> | ||
</> | ||
); | ||
} | ||
|
||
export default ModelProvider; |
Oops, something went wrong.