mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-09-04 14:35:23 +00:00
Enhance DNS record management by adding support for optional DNS providers.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/996e6e00-8df0-4e11-8054-4bedce75e1d8.jpg
This commit is contained in:
@@ -167,8 +167,12 @@ export default function DnsRecordsPage() {
|
|||||||
mutationFn: async (data: z.infer<typeof dnsRecordSchema>) => {
|
mutationFn: async (data: z.infer<typeof dnsRecordSchema>) => {
|
||||||
if (!domainId) throw new Error("Domain ID is required");
|
if (!domainId) throw new Error("Domain ID is required");
|
||||||
|
|
||||||
|
// Convert empty providerId to null
|
||||||
|
const providerId = data.providerId === "" ? null : data.providerId;
|
||||||
|
|
||||||
const recordData: InsertDnsRecord = {
|
const recordData: InsertDnsRecord = {
|
||||||
...data,
|
...data,
|
||||||
|
providerId,
|
||||||
domainId,
|
domainId,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -199,7 +203,15 @@ export default function DnsRecordsPage() {
|
|||||||
// Update DNS record mutation
|
// Update DNS record mutation
|
||||||
const updateRecordMutation = useMutation({
|
const updateRecordMutation = useMutation({
|
||||||
mutationFn: async ({ id, data }: { id: string, data: z.infer<typeof dnsRecordSchema> }) => {
|
mutationFn: async ({ id, data }: { id: string, data: z.infer<typeof dnsRecordSchema> }) => {
|
||||||
const res = await apiRequest("PUT", `/api/dns-records/${id}`, data);
|
// Convert empty providerId to null
|
||||||
|
const providerId = data.providerId === "" ? null : data.providerId;
|
||||||
|
|
||||||
|
const updatedData = {
|
||||||
|
...data,
|
||||||
|
providerId,
|
||||||
|
};
|
||||||
|
|
||||||
|
const res = await apiRequest("PUT", `/api/dns-records/${id}`, updatedData);
|
||||||
return await res.json();
|
return await res.json();
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
@@ -730,6 +742,41 @@ export default function DnsRecordsPage() {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="providerId"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>DNS Provider</FormLabel>
|
||||||
|
<Select
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
defaultValue={field.value}
|
||||||
|
>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select a DNS provider" />
|
||||||
|
</SelectTrigger>
|
||||||
|
</FormControl>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="">None</SelectItem>
|
||||||
|
{providers.map((provider) => (
|
||||||
|
<SelectItem
|
||||||
|
key={provider.id}
|
||||||
|
value={provider.id}
|
||||||
|
>
|
||||||
|
{provider.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<FormDescription>
|
||||||
|
Select the DNS provider to use for this record
|
||||||
|
</FormDescription>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="type"
|
name="type"
|
||||||
|
|||||||
+17
-11
@@ -204,17 +204,23 @@ export const insertDomainSchema = createInsertSchema(domains)
|
|||||||
providerId: z.string().uuid().optional(),
|
providerId: z.string().uuid().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const insertDnsRecordSchema = createInsertSchema(dnsRecords).pick({
|
export const insertDnsRecordSchema = createInsertSchema(dnsRecords)
|
||||||
domainId: true,
|
.pick({
|
||||||
name: true,
|
domainId: true,
|
||||||
type: true,
|
name: true,
|
||||||
content: true,
|
type: true,
|
||||||
ttl: true,
|
content: true,
|
||||||
proxied: true,
|
ttl: true,
|
||||||
isActive: true,
|
proxied: true,
|
||||||
isAutoIP: true,
|
isActive: true,
|
||||||
notes: true,
|
isAutoIP: true,
|
||||||
});
|
notes: true,
|
||||||
|
providerId: true,
|
||||||
|
})
|
||||||
|
.extend({
|
||||||
|
// Override providerId to make it optional
|
||||||
|
providerId: z.string().uuid().nullable().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
export const insertProviderSchema = createInsertSchema(providers).pick({
|
export const insertProviderSchema = createInsertSchema(providers).pick({
|
||||||
name: true,
|
name: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user