Update Biome formatting settings, improved self-hosting capability and reformatted all files

This commit is contained in:
Dries Augustyns
2024-08-02 10:52:42 +02:00
parent b7463af088
commit e8731048c4
59 changed files with 841 additions and 2982 deletions
+21 -71
View File
@@ -7,14 +7,7 @@ import { useRouter } from "next/router";
import React, { useEffect } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import {
Card,
Dropdown,
Editor,
FullscreenLoader,
Input,
Tooltip,
} from "../../components";
import { Card, Dropdown, Editor, FullscreenLoader, Input, Tooltip } from "../../components";
import { Dashboard } from "../../layouts";
import { useActiveProject } from "../../lib/hooks/projects";
import { useTemplate, useTemplates } from "../../lib/hooks/templates";
@@ -63,25 +56,16 @@ export default function Index() {
reset(template);
}, [reset, template]);
if (
!project ||
!template ||
(watch("body") as string | undefined) === undefined
) {
if (!project || !template || (watch("body") as string | undefined) === undefined) {
return <FullscreenLoader />;
}
const update = (data: TemplateValues) => {
toast.promise(
network.mock<Template, typeof TemplateSchemas.update>(
project.secret,
"PUT",
"/v1/templates",
{
id: template.id,
...data,
},
),
network.mock<Template, typeof TemplateSchemas.update>(project.secret, "PUT", "/v1/templates", {
id: template.id,
...data,
}),
{
loading: "Saving your template",
success: () => {
@@ -97,14 +81,9 @@ export default function Index() {
const duplicate = async (e: { preventDefault: () => void }) => {
e.preventDefault();
toast.promise(
network.mock<Template, typeof UtilitySchemas.id>(
project.secret,
"POST",
"/v1/templates/duplicate",
{
id: template.id,
},
),
network.mock<Template, typeof UtilitySchemas.id>(project.secret, "POST", "/v1/templates/duplicate", {
id: template.id,
}),
{
loading: "Duplicating your template",
success: () => {
@@ -122,20 +101,13 @@ export default function Index() {
e.preventDefault();
if (template.actions.length > 0) {
return toast.error(
"You cannot delete a template that is linked to an action!",
);
return toast.error("You cannot delete a template that is linked to an action!");
}
toast.promise(
network.mock<Template, typeof UtilitySchemas.id>(
project.secret,
"DELETE",
"/v1/templates",
{
id: template.id,
},
),
network.mock<Template, typeof UtilitySchemas.id>(project.secret, "DELETE", "/v1/templates", {
id: template.id,
}),
{
loading: "Deleting your template",
success: () => {
@@ -205,23 +177,14 @@ export default function Index() {
strokeWidth="1.5"
d="M9.75 7.5V6.75C9.75 5.64543 10.6454 4.75 11.75 4.75H12.25C13.3546 4.75 14.25 5.64543 14.25 6.75V7.5"
/>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
d="M5 7.75H19"
/>
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.5" d="M5 7.75H19" />
</svg>
Delete
</button>
</>
}
>
<form
onSubmit={handleSubmit(update)}
className="grid gap-6 sm:grid-cols-6"
>
<form onSubmit={handleSubmit(update)} className="grid gap-6 sm:grid-cols-6">
<Input
className={"sm:col-span-4"}
label={"Subject"}
@@ -231,36 +194,25 @@ export default function Index() {
/>
<div className={"sm:col-span-2"}>
<label
htmlFor={"type"}
className="flex items-center text-sm font-medium text-neutral-700"
>
<label htmlFor={"type"} className="flex items-center text-sm font-medium text-neutral-700">
Type
<Tooltip
content={
<>
<p className={"mb-2 text-base font-semibold"}>
What type of email is this?
</p>
<p className={"mb-2 text-base font-semibold"}>What type of email is this?</p>
<ul className={"list-inside"}>
<li className={"mb-6"}>
<span className={"font-semibold"}>Marketing</span>
<br />
Promotional emails with a Plunk-hosted unsubscribe
link
Promotional emails with a Plunk-hosted unsubscribe link
<br />
<span className={"text-neutral-400"}>
(e.g. welcome emails, promotions)
</span>
<span className={"text-neutral-400"}>(e.g. welcome emails, promotions)</span>
</li>
<li>
<span className={"font-semibold"}>Transactional</span>
<br />
Mission critical emails <br />
<span className={"text-neutral-400"}>
{" "}
(e.g. email verification, password reset)
</span>
<span className={"text-neutral-400"}> (e.g. email verification, password reset)</span>
</li>
</ul>
</>
@@ -275,9 +227,7 @@ export default function Index() {
/>
</label>
<Dropdown
onChange={(t) =>
setValue("type", t as "MARKETING" | "TRANSACTIONAL")
}
onChange={(t) => setValue("type", t as "MARKETING" | "TRANSACTIONAL")}
values={[
{ name: "Marketing", value: "MARKETING" },
{ name: "Transactional", value: "TRANSACTIONAL" },