mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 09:32:22 +03:00
ui: close modal after brain creation (#720)
This commit is contained in:
parent
d27504f735
commit
8125d0858c
@ -13,6 +13,7 @@ export const AddBrainModal = (): JSX.Element => {
|
|||||||
const [isPending, setIsPending] = useState(false);
|
const [isPending, setIsPending] = useState(false);
|
||||||
const { publish } = useToast();
|
const { publish } = useToast();
|
||||||
const { createBrain } = useBrainContext();
|
const { createBrain } = useBrainContext();
|
||||||
|
const [isShareModalOpen, setIsShareModalOpen] = useState(false);
|
||||||
|
|
||||||
const handleSubmit = async (e: FormEvent) => {
|
const handleSubmit = async (e: FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -23,6 +24,11 @@ export const AddBrainModal = (): JSX.Element => {
|
|||||||
setIsPending(true);
|
setIsPending(true);
|
||||||
await createBrain(newBrainName);
|
await createBrain(newBrainName);
|
||||||
setNewBrainName("");
|
setNewBrainName("");
|
||||||
|
setIsShareModalOpen(false);
|
||||||
|
publish({
|
||||||
|
variant: "success",
|
||||||
|
text: "Brain created successfully",
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (axios.isAxiosError(err) && err.response?.status === 429) {
|
if (axios.isAxiosError(err) && err.response?.status === 429) {
|
||||||
publish({
|
publish({
|
||||||
@ -56,6 +62,9 @@ export const AddBrainModal = (): JSX.Element => {
|
|||||||
}
|
}
|
||||||
title="Add Brain"
|
title="Add Brain"
|
||||||
desc="Add a new brain"
|
desc="Add a new brain"
|
||||||
|
isOpen={isShareModalOpen}
|
||||||
|
setOpen={setIsShareModalOpen}
|
||||||
|
CloseTrigger={<div />}
|
||||||
>
|
>
|
||||||
<form
|
<form
|
||||||
onSubmit={(e) => void handleSubmit(e)}
|
onSubmit={(e) => void handleSubmit(e)}
|
||||||
|
Loading…
Reference in New Issue
Block a user