diff --git a/components/forms/record-form.tsx b/components/forms/record-form.tsx
index bd28218..0f26bd4 100644
--- a/components/forms/record-form.tsx
+++ b/components/forms/record-form.tsx
@@ -6,6 +6,7 @@ import { User } from "@prisma/client";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
+import { siteConfig } from "@/config/site";
import { CreateDNSRecord, RecordType } from "@/lib/cloudflare";
import { UserRecordFormData } from "@/lib/dto/cloudflare-dns-record";
import { RECORD_TYPE_ENUMS, TTL_ENUMS } from "@/lib/enums";
@@ -30,7 +31,7 @@ export type FormData = CreateDNSRecord;
export type FormType = "add" | "edit";
export interface RecordFormProps {
- user: Pick;
+ user: Pick;
isShowForm: boolean;
setShowForm: Dispatch>;
type: FormType;
@@ -53,24 +54,25 @@ export function RecordForm({
const [currentRecordType, setCurrentRecordType] = useState(
initData?.type || "CNAME",
);
+ const [currentZoneName, setCurrentZoneName] = useState(
+ initData?.zone_name || "wr.do",
+ );
+ const [email, setEmail] = useState(user.email);
const {
handleSubmit,
register,
formState: { errors },
- getValues,
setValue,
} = useForm({
resolver: zodResolver(createRecordSchema),
defaultValues: {
+ zone_name: initData?.zone_name || "wr.do",
type: initData?.type || "CNAME",
ttl: initData?.ttl || 1,
proxied: initData?.proxied || false,
- comment: initData?.comment || "",
- name:
- (initData?.name.endsWith(".wr.do")
- ? initData?.name.slice(0, -6)
- : initData?.name) || "",
+ comment: "Created by wr.do",
+ name: initData?.name ? initData.name.split(".")[0] : "",
content: initData?.content || "",
},
});
@@ -89,6 +91,7 @@ export function RecordForm({
method: "POST",
body: JSON.stringify({
records: [data],
+ email,
}),
});
@@ -161,7 +164,62 @@ export function RecordForm({
{type === "add" ? "Create" : "Edit"} record