fix: incorrect domain verification records
This commit is contained in:
@@ -12,305 +12,308 @@ import { useActiveProject, useActiveProjectVerifiedIdentity, useProjects } from
|
|||||||
import { network } from "../../lib/network";
|
import { network } from "../../lib/network";
|
||||||
|
|
||||||
interface EmailValues {
|
interface EmailValues {
|
||||||
email: string;
|
email: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FromValues {
|
interface FromValues {
|
||||||
from: string;
|
from: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
const activeProject = useActiveProject();
|
const activeProject = useActiveProject();
|
||||||
const { mutate: projectsMutate } = useProjects();
|
const { mutate: projectsMutate } = useProjects();
|
||||||
const { data: identity, mutate: identityMutate } = useActiveProjectVerifiedIdentity();
|
const { data: identity, mutate: identityMutate } = useActiveProjectVerifiedIdentity();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = useForm<EmailValues>({
|
} = useForm<EmailValues>({
|
||||||
resolver: zodResolver(IdentitySchemas.create.omit({ id: true })),
|
resolver: zodResolver(IdentitySchemas.create.omit({ id: true })),
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register: registerUpdate,
|
register: registerUpdate,
|
||||||
handleSubmit: handleSubmitUpdate,
|
handleSubmit: handleSubmitUpdate,
|
||||||
formState: { errors: errorsUpdate },
|
formState: { errors: errorsUpdate },
|
||||||
reset,
|
reset,
|
||||||
} = useForm<FromValues>({
|
} = useForm<FromValues>({
|
||||||
resolver: zodResolver(IdentitySchemas.update.omit({ id: true })),
|
resolver: zodResolver(IdentitySchemas.update.omit({ id: true })),
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!activeProject) {
|
if (!activeProject) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
reset({ from: activeProject.from ?? undefined });
|
reset({ from: activeProject.from ?? undefined });
|
||||||
}, [reset, activeProject]);
|
}, [reset, activeProject]);
|
||||||
|
|
||||||
if (!activeProject || !identity) {
|
if (!activeProject || !identity) {
|
||||||
return <FullscreenLoader />;
|
return <FullscreenLoader />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const create = async (data: EmailValues) => {
|
const create = async (data: EmailValues) => {
|
||||||
toast.promise(
|
toast.promise(
|
||||||
network.fetch<
|
network.fetch<
|
||||||
{
|
{
|
||||||
success: true;
|
success: true;
|
||||||
tokens: string[];
|
tokens: string[];
|
||||||
},
|
},
|
||||||
typeof IdentitySchemas.create
|
typeof IdentitySchemas.create
|
||||||
>("POST", "/identities/create", {
|
>("POST", "/identities/create", {
|
||||||
id: activeProject.id,
|
id: activeProject.id,
|
||||||
...data,
|
...data,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
loading: "Adding your domain",
|
loading: "Adding your domain",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
void identityMutate({ tokens: res.tokens }, { revalidate: false });
|
void identityMutate({ tokens: res.tokens }, { revalidate: false });
|
||||||
void projectsMutate();
|
void projectsMutate();
|
||||||
|
|
||||||
return "Added your domain";
|
return "Added your domain";
|
||||||
},
|
},
|
||||||
error: "Could not add domain",
|
error: "Could not add domain",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const update = async (data: FromValues) => {
|
const update = async (data: FromValues) => {
|
||||||
toast.promise(
|
toast.promise(
|
||||||
network.fetch<
|
network.fetch<
|
||||||
{
|
{
|
||||||
success: true;
|
success: true;
|
||||||
},
|
},
|
||||||
typeof IdentitySchemas.update
|
typeof IdentitySchemas.update
|
||||||
>("PUT", "/projects/update/identity", {
|
>("PUT", "/projects/update/identity", {
|
||||||
id: activeProject.id,
|
id: activeProject.id,
|
||||||
...data,
|
...data,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
loading: "Updating your sender name",
|
loading: "Updating your sender name",
|
||||||
success: "Updated your sender name",
|
success: "Updated your sender name",
|
||||||
error: "Could not update sender name",
|
error: "Could not update sender name",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await identityMutate();
|
await identityMutate();
|
||||||
await projectsMutate();
|
await projectsMutate();
|
||||||
};
|
};
|
||||||
|
|
||||||
const unlink = async () => {
|
const unlink = async () => {
|
||||||
toast.promise(
|
toast.promise(
|
||||||
network.fetch<
|
network.fetch<
|
||||||
{
|
{
|
||||||
success: true;
|
success: true;
|
||||||
},
|
},
|
||||||
typeof UtilitySchemas.id
|
typeof UtilitySchemas.id
|
||||||
>("POST", "/identities/reset", {
|
>("POST", "/identities/reset", {
|
||||||
id: activeProject.id,
|
id: activeProject.id,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
loading: "Unlinking your domain",
|
loading: "Unlinking your domain",
|
||||||
success: "Unlinked your domain",
|
success: "Unlinked your domain",
|
||||||
error: "Could not unlink domain",
|
error: "Could not unlink domain",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
const domain = activeProject.email?.split("@")[1] ?? "";
|
||||||
<>
|
const subdomain = domain.split(".").length > 2 ? domain.split(".")[0] : "";
|
||||||
<Dashboard>
|
|
||||||
<SettingTabs />
|
|
||||||
|
|
||||||
<Card
|
return (
|
||||||
title={"Domain"}
|
<>
|
||||||
description={"By sending emails from your own domain you build up domain authority and trust."}
|
<Dashboard>
|
||||||
actions={
|
<SettingTabs />
|
||||||
activeProject.email && (
|
|
||||||
<>
|
|
||||||
<button
|
|
||||||
onClick={unlink}
|
|
||||||
className={
|
|
||||||
"flex items-center gap-x-2 rounded bg-red-600 px-8 py-2 text-center text-sm font-medium text-white transition ease-in-out hover:bg-red-700"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Unlink strokeWidth={1.5} size={18} />
|
|
||||||
Unlink domain
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{activeProject.email && !activeProject.verified ? (
|
|
||||||
<>
|
|
||||||
<Alert type={"warning"} title={"Waiting for DNS verification"}>
|
|
||||||
Please add the following records to {activeProject.email.split("@")[1]} to verify {activeProject.email}, this
|
|
||||||
may take up to 15 minutes to register. <br />
|
|
||||||
In the meantime you can already start sending emails, we will automatically switch to your domain once it is
|
|
||||||
verified.
|
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<div className="mt-6">
|
<Card
|
||||||
<Table
|
title={"Domain"}
|
||||||
values={[
|
description={"By sending emails from your own domain you build up domain authority and trust."}
|
||||||
{
|
actions={
|
||||||
Type: <Badge type={"info"}>TXT</Badge>,
|
activeProject.email && (
|
||||||
Key: (
|
<>
|
||||||
<div
|
<button
|
||||||
className={"flex cursor-pointer items-center gap-3"}
|
onClick={unlink}
|
||||||
onClick={() => {
|
className={
|
||||||
void navigator.clipboard.writeText("plunk");
|
"flex items-center gap-x-2 rounded bg-red-600 px-8 py-2 text-center text-sm font-medium text-white transition ease-in-out hover:bg-red-700"
|
||||||
toast.success("Copied key to clipboard");
|
}
|
||||||
}}
|
>
|
||||||
>
|
<Unlink strokeWidth={1.5} size={18} />
|
||||||
<p className={"font-mono text-sm"}>plunk</p>
|
Unlink domain
|
||||||
<Copy size={14} />
|
</button>
|
||||||
</div>
|
</>
|
||||||
),
|
)
|
||||||
Value: (
|
}
|
||||||
<div
|
>
|
||||||
className={"flex cursor-pointer items-center gap-3"}
|
{activeProject.email && !activeProject.verified ? (
|
||||||
onClick={() => {
|
<>
|
||||||
void navigator.clipboard.writeText("v=spf1 include:amazonses.com ~all");
|
<Alert type={"warning"} title={"Waiting for DNS verification"}>
|
||||||
toast.success("Copied value to clipboard");
|
Please add the following records to {activeProject.email.split("@")[1]} to verify {activeProject.email}, this
|
||||||
}}
|
may take up to 15 minutes to register. <br />
|
||||||
>
|
In the meantime you can already start sending emails, we will automatically switch to your domain once it is
|
||||||
<p className={"font-mono text-sm"}>v=spf1 include:amazonses.com ~all</p> <Copy size={14} />
|
verified.
|
||||||
</div>
|
</Alert>
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: <Badge type={"info"}>MX</Badge>,
|
|
||||||
Key: (
|
|
||||||
<div
|
|
||||||
className={"flex cursor-pointer items-center gap-3"}
|
|
||||||
onClick={() => {
|
|
||||||
void navigator.clipboard.writeText("plunk");
|
|
||||||
toast.success("Copied key to clipboard");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<p className={"font-mono text-sm"}>plunk</p>
|
|
||||||
<Copy size={14} />
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
Value: (
|
|
||||||
<div
|
|
||||||
className={"flex cursor-pointer items-center gap-3"}
|
|
||||||
onClick={() => {
|
|
||||||
void navigator.clipboard.writeText(`10 feedback-smtp.${AWS_REGION}.amazonses.com`);
|
|
||||||
toast.success("Copied value to clipboard");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<p className={"font-mono text-sm"}>10 feedback-smtp.{AWS_REGION}.amazonses.com</p>
|
|
||||||
<Copy size={14} />
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
...identity.tokens.map((token) => {
|
|
||||||
return {
|
|
||||||
Type: <Badge type={"info"}>CNAME</Badge>,
|
|
||||||
Key: (
|
|
||||||
<div
|
|
||||||
className={"flex cursor-pointer items-center gap-3"}
|
|
||||||
onClick={() => {
|
|
||||||
void navigator.clipboard.writeText(`${token}._domainkey`);
|
|
||||||
toast.success("Copied key to clipboard");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<p className={"font-mono text-sm"}>{token}._domainkey</p>
|
|
||||||
<Copy size={14} />
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
Value: (
|
|
||||||
<div
|
|
||||||
className={"flex cursor-pointer items-center gap-3"}
|
|
||||||
onClick={() => {
|
|
||||||
void navigator.clipboard.writeText(`${token}.dkim.amazonses.com`);
|
|
||||||
toast.success("Copied value to clipboard");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<p className={"font-mono text-sm"}>{token}.dkim.amazonses.com</p>
|
|
||||||
<Copy size={14} />
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : activeProject.email && activeProject.verified ? (
|
|
||||||
<>
|
|
||||||
<Alert type={"success"} title={"Domain verified"}>
|
|
||||||
You have confirmed {activeProject.email} as your domain. Any emails sent by Plunk will now use this address.
|
|
||||||
</Alert>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<form onSubmit={handleSubmit(create)} className="space-y-6">
|
|
||||||
<Input register={register("email")} error={errors.email} placeholder={"hello@example.com"} label={"Email"} />
|
|
||||||
<motion.button
|
|
||||||
whileHover={{ scale: 1.05 }}
|
|
||||||
whileTap={{ scale: 0.9 }}
|
|
||||||
className={
|
|
||||||
"ml-auto flex items-center gap-x-0.5 rounded bg-neutral-800 px-8 py-2 text-center text-sm font-medium text-white"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<svg width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
||||||
<path
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth="1.5"
|
|
||||||
d="M12 5.75V18.25"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth="1.5"
|
|
||||||
d="M18.25 12L5.75 12"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
Verify domain
|
|
||||||
</motion.button>
|
|
||||||
</form>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card
|
<div className="mt-6">
|
||||||
title={"Sender name"}
|
<Table
|
||||||
description={
|
values={[
|
||||||
"The name that will be used when sending emails from Plunk. Your project name will be used by default"
|
{
|
||||||
}
|
Type: <Badge type={"info"}>TXT</Badge>,
|
||||||
>
|
Key: (
|
||||||
<form onSubmit={handleSubmitUpdate(update)} className="space-y-6">
|
<div
|
||||||
<Input
|
className={"flex cursor-pointer items-center gap-3"}
|
||||||
register={registerUpdate("from")}
|
onClick={() => {
|
||||||
placeholder={activeProject.name}
|
void navigator.clipboard.writeText("plunk");
|
||||||
label={"Name"}
|
toast.success("Copied key to clipboard");
|
||||||
error={errorsUpdate.from}
|
}}
|
||||||
/>
|
>
|
||||||
|
<p className={"font-mono text-sm"}>plunk</p>
|
||||||
|
<Copy size={14} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
Value: (
|
||||||
|
<div
|
||||||
|
className={"flex cursor-pointer items-center gap-3"}
|
||||||
|
onClick={() => {
|
||||||
|
void navigator.clipboard.writeText("v=spf1 include:amazonses.com ~all");
|
||||||
|
toast.success("Copied value to clipboard");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p className={"font-mono text-sm"}>v=spf1 include:amazonses.com ~all</p> <Copy size={14} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: <Badge type={"info"}>MX</Badge>,
|
||||||
|
Key: (
|
||||||
|
<div
|
||||||
|
className={"flex cursor-pointer items-center gap-3"}
|
||||||
|
onClick={() => {
|
||||||
|
void navigator.clipboard.writeText("plunk");
|
||||||
|
toast.success("Copied key to clipboard");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p className={"font-mono text-sm"}>plunk</p>
|
||||||
|
<Copy size={14} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
Value: (
|
||||||
|
<div
|
||||||
|
className={"flex cursor-pointer items-center gap-3"}
|
||||||
|
onClick={() => {
|
||||||
|
void navigator.clipboard.writeText(`10 feedback-smtp.${AWS_REGION}.amazonses.com`);
|
||||||
|
toast.success("Copied value to clipboard");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p className={"font-mono text-sm"}>10 feedback-smtp.{AWS_REGION}.amazonses.com</p>
|
||||||
|
<Copy size={14} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
...identity.tokens.map((token) => {
|
||||||
|
return {
|
||||||
|
Type: <Badge type={"info"}>CNAME</Badge>,
|
||||||
|
Key: (
|
||||||
|
<div
|
||||||
|
className={"flex cursor-pointer items-center gap-3"}
|
||||||
|
onClick={() => {
|
||||||
|
void navigator.clipboard.writeText(`${token}._domainkey${subdomain ? '.' + subdomain : ''}`);
|
||||||
|
toast.success("Copied key to clipboard");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p className={"font-mono text-sm"}>{token}._domainkey{subdomain ? '.' + subdomain : ''}</p>
|
||||||
|
<Copy size={14} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
Value: (
|
||||||
|
<div
|
||||||
|
className={"flex cursor-pointer items-center gap-3"}
|
||||||
|
onClick={() => {
|
||||||
|
void navigator.clipboard.writeText(`${token}.dkim.amazonses.com`);
|
||||||
|
toast.success("Copied value to clipboard");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p className={"font-mono text-sm"}>{token}.dkim.amazonses.com</p>
|
||||||
|
<Copy size={14} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : activeProject.email && activeProject.verified ? (
|
||||||
|
<>
|
||||||
|
<Alert type={"success"} title={"Domain verified"}>
|
||||||
|
You have confirmed {activeProject.email} as your domain. Any emails sent by Plunk will now use this address.
|
||||||
|
</Alert>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<form onSubmit={handleSubmit(create)} className="space-y-6">
|
||||||
|
<Input register={register("email")} error={errors.email} placeholder={"hello@example.com"} label={"Email"} />
|
||||||
|
<motion.button
|
||||||
|
whileHover={{ scale: 1.05 }}
|
||||||
|
whileTap={{ scale: 0.9 }}
|
||||||
|
className={
|
||||||
|
"ml-auto flex items-center gap-x-0.5 rounded bg-neutral-800 px-8 py-2 text-center text-sm font-medium text-white"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<svg width="24" height="24" fill="none" viewBox="0 0 24 24">
|
||||||
|
<path
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth="1.5"
|
||||||
|
d="M12 5.75V18.25"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth="1.5"
|
||||||
|
d="M18.25 12L5.75 12"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
Verify domain
|
||||||
|
</motion.button>
|
||||||
|
</form>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Card>
|
||||||
|
|
||||||
<motion.button
|
<Card
|
||||||
whileHover={{ scale: 1.05 }}
|
title={"Sender name"}
|
||||||
whileTap={{ scale: 0.9 }}
|
description={
|
||||||
className={
|
"The name that will be used when sending emails from Plunk. Your project name will be used by default"
|
||||||
"ml-auto flex items-center gap-x-0.5 rounded bg-neutral-800 px-8 py-2 text-center text-sm font-medium text-white"
|
}
|
||||||
}
|
>
|
||||||
>
|
<form onSubmit={handleSubmitUpdate(update)} className="space-y-6">
|
||||||
Save
|
<Input
|
||||||
</motion.button>
|
register={registerUpdate("from")}
|
||||||
</form>
|
placeholder={activeProject.name}
|
||||||
</Card>
|
label={"Name"}
|
||||||
</Dashboard>
|
error={errorsUpdate.from}
|
||||||
</>
|
/>
|
||||||
);
|
|
||||||
|
<motion.button
|
||||||
|
whileHover={{ scale: 1.05 }}
|
||||||
|
whileTap={{ scale: 0.9 }}
|
||||||
|
className={
|
||||||
|
"ml-auto flex items-center gap-x-0.5 rounded bg-neutral-800 px-8 py-2 text-center text-sm font-medium text-white"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</motion.button>
|
||||||
|
</form>
|
||||||
|
</Card>
|
||||||
|
</Dashboard>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user