mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
"completeAction" and custom "trigger" params
This commit is contained in:
@@ -4,7 +4,6 @@ import {
|
|||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogDescription,
|
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
@@ -19,10 +18,15 @@ const slugify = (value: string) =>
|
|||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/[^a-z0-9]+/g, "-")
|
.replace(/[^a-z0-9]+/g, "-")
|
||||||
.replace(/^-+/, "")
|
.replace(/^-+/, "")
|
||||||
.replace(/-+$/, "")
|
|
||||||
.replace(/-{2,}/g, "-");
|
.replace(/-{2,}/g, "-");
|
||||||
|
|
||||||
export function CreateOrganisation() {
|
export function CreateOrganisation({
|
||||||
|
trigger,
|
||||||
|
completeAction,
|
||||||
|
}: {
|
||||||
|
trigger?: React.ReactNode;
|
||||||
|
completeAction?: () => void | Promise<void>;
|
||||||
|
}) {
|
||||||
const serverURL = import.meta.env.VITE_SERVER_URL?.trim() || "http://localhost:3000";
|
const serverURL = import.meta.env.VITE_SERVER_URL?.trim() || "http://localhost:3000";
|
||||||
|
|
||||||
const userId = JSON.parse(localStorage.getItem("user") || "{}").id as number | undefined;
|
const userId = JSON.parse(localStorage.getItem("user") || "{}").id as number | undefined;
|
||||||
@@ -106,7 +110,12 @@ export function CreateOrganisation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
window.location.reload();
|
reset();
|
||||||
|
try {
|
||||||
|
await completeAction?.();
|
||||||
|
} catch (actionErr) {
|
||||||
|
console.error(actionErr);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
setError("failed to create organisation");
|
setError("failed to create organisation");
|
||||||
@@ -117,7 +126,7 @@ export function CreateOrganisation() {
|
|||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<Button variant="outline">Create Organisation</Button>
|
{trigger || <Button variant="outline">Create Organisation</Button>}
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
|
|
||||||
<DialogContent className={cn("w-md", error && "border-destructive")}>
|
<DialogContent className={cn("w-md", error && "border-destructive")}>
|
||||||
|
|||||||
Reference in New Issue
Block a user