forked from coaidev/coai
-
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.
update user operation and fix api connection
- Loading branch information
1 parent
b40c60e
commit 38dad63
Showing
15 changed files
with
333 additions
and
16 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
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 @@ | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
} from "@/components/ui/dialog.tsx"; | ||
import { useTranslation } from "react-i18next"; | ||
import { Button } from "@/components/ui/button.tsx"; | ||
import { Input } from "@/components/ui/input.tsx"; | ||
import { useState } from "react"; | ||
|
||
export type PopupDialogProps = { | ||
title: string; | ||
description?: string; | ||
name: string; | ||
defaultValue?: string; | ||
onValueChange?: (value: string) => string; | ||
onSubmit?: (value: string) => Promise<boolean>; | ||
|
||
open: boolean; | ||
setOpen: (open: boolean) => void; | ||
}; | ||
|
||
function PopupDialog({ | ||
title, | ||
description, | ||
name, | ||
defaultValue, | ||
onValueChange, | ||
onSubmit, | ||
open, | ||
setOpen, | ||
}: PopupDialogProps) { | ||
const { t } = useTranslation(); | ||
const [value, setValue] = useState<string>(defaultValue || ""); | ||
|
||
return ( | ||
<Dialog open={open} onOpenChange={setOpen}> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>{title}</DialogTitle> | ||
<DialogDescription className={`pt-1.5`}>{description}</DialogDescription> | ||
</DialogHeader> | ||
<div className={`pt-1 flex flex-row items-center justify-center`}> | ||
<span className={`mr-4 whitespace-nowrap`}>{name}</span> | ||
<Input | ||
onChange={(e) => { | ||
setValue( | ||
onValueChange ? onValueChange(e.target.value) : e.target.value, | ||
); | ||
}} | ||
value={value} | ||
/> | ||
</div> | ||
<DialogFooter> | ||
<Button variant={`outline`} onClick={() => setOpen(false)}> | ||
{t("cancel")} | ||
</Button> | ||
<Button | ||
onClick={() => { | ||
onSubmit && onSubmit(value).then((success) => { | ||
if (success) { | ||
setOpen(false); | ||
setValue(defaultValue || ""); | ||
} | ||
}); | ||
}} | ||
> | ||
{t("confirm")} | ||
</Button> | ||
</DialogFooter> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} | ||
|
||
export default PopupDialog; |
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.