Skip to content

Commit cd42733

Browse files
committed
Merge remote-tracking branch 'origin/develop' into new-kids-adults-services-schemas
2 parents ea9619e + 5ee9ec3 commit cd42733

60 files changed

Lines changed: 5566 additions & 112 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
88
WORDPRESS_API_URL=http://xxx.com
99
WORDPRESS_USERNAME=mcld-dashboard
1010
WORDPRESS_APP_PASSWORD="xxxx xxxx xxxx xxxx xxxx xxxx"
11-
WORDPRESS_POST_TYPE=posts
11+
WORDPRESS_POST_TYPE=posts
12+
13+
BREVO_SMTP_HOST=
14+
BREVO_SMTP_PORT=
15+
BREVO_SMTP_USER=
16+
BREVO_SMTP_PASSWORD=
17+
EMAIL_FROM=
18+
EMAIL_TIMEZONE=
19+
APP_URL=

app/(authenticated)/checkout/cancel/page.tsx

Lines changed: 0 additions & 35 deletions
This file was deleted.

app/(authenticated)/checkout/success/page.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
"use client";
2+
3+
import * as React from "react";
4+
import { Pencil, Trash2 } from "lucide-react";
5+
import { toast } from "sonner";
6+
7+
import {
8+
AlertDialog,
9+
AlertDialogAction,
10+
AlertDialogCancel,
11+
AlertDialogContent,
12+
AlertDialogDescription,
13+
AlertDialogFooter,
14+
AlertDialogHeader,
15+
AlertDialogTitle,
16+
} from "@/components/ui/alert-dialog";
17+
import { Button } from "@/components/ui/button";
18+
import {
19+
Tooltip,
20+
TooltipContent,
21+
TooltipTrigger,
22+
} from "@/components/ui/tooltip";
23+
import { deleteForm } from "../actions";
24+
import type { FormListItem } from "../queries";
25+
26+
export function FormActionsCell({
27+
form,
28+
onEdit,
29+
}: {
30+
form: FormListItem;
31+
onEdit: (form: FormListItem) => void;
32+
}) {
33+
const [deleteOpen, setDeleteOpen] = React.useState(false);
34+
const [pending, startTransition] = React.useTransition();
35+
36+
const handleDelete = () => {
37+
const fd = new FormData();
38+
fd.set("form_id", form.id);
39+
startTransition(async () => {
40+
const result = await deleteForm(null, fd);
41+
if (result?.errors?._form) {
42+
toast.error("Could not delete form", {
43+
description: result.errors._form.join(" "),
44+
});
45+
return;
46+
}
47+
if (result?.message) {
48+
toast.success(result.message);
49+
setDeleteOpen(false);
50+
}
51+
});
52+
};
53+
54+
return (
55+
<>
56+
<div className="flex items-center justify-end gap-0.5">
57+
<Tooltip>
58+
<TooltipTrigger asChild>
59+
<Button
60+
variant="ghost"
61+
size="icon-sm"
62+
aria-label="Edit form"
63+
onClick={() => onEdit(form)}
64+
>
65+
<Pencil />
66+
</Button>
67+
</TooltipTrigger>
68+
<TooltipContent>Edit</TooltipContent>
69+
</Tooltip>
70+
<Tooltip>
71+
<TooltipTrigger asChild>
72+
<Button
73+
variant="ghost"
74+
size="icon-sm"
75+
aria-label="Delete form"
76+
onClick={() => setDeleteOpen(true)}
77+
>
78+
<Trash2 />
79+
</Button>
80+
</TooltipTrigger>
81+
<TooltipContent>Delete</TooltipContent>
82+
</Tooltip>
83+
</div>
84+
85+
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
86+
<AlertDialogContent className="sm:max-w-md">
87+
<AlertDialogHeader className="place-items-start text-left sm:place-items-start sm:text-left">
88+
<AlertDialogTitle>Delete form?</AlertDialogTitle>
89+
<AlertDialogDescription>
90+
{form.attachedServiceCount > 0
91+
? `This form is attached to ${form.attachedServiceCount} service(s). Detach it from those services before deleting.`
92+
: `Permanently delete "${form.name}" and all of its questions. This cannot be undone.`}
93+
</AlertDialogDescription>
94+
</AlertDialogHeader>
95+
<AlertDialogFooter className="sm:flex-row sm:justify-end">
96+
<AlertDialogCancel disabled={pending}>Cancel</AlertDialogCancel>
97+
<AlertDialogAction
98+
disabled={pending || form.attachedServiceCount > 0}
99+
onClick={(e) => {
100+
e.preventDefault();
101+
handleDelete();
102+
}}
103+
>
104+
{pending ? "Deleting..." : "Delete"}
105+
</AlertDialogAction>
106+
</AlertDialogFooter>
107+
</AlertDialogContent>
108+
</AlertDialog>
109+
</>
110+
);
111+
}

0 commit comments

Comments
 (0)