"use client" import { DatePicker } from "@/components/date-picker" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form" import { Input } from "@/components/ui/input" import { Switch } from "@/components/ui/switch" import { createAdvanceUrl } from "@/lib/actions/url" import { advancedUrlSchema } from "@/lib/schema/url" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" import { toast } from "sonner" import { z } from "zod" type AdvancedUrlFormValues = z.infer export function AdvancedUrlFormCard() { const form = useForm({ resolver: zodResolver(advancedUrlSchema), defaultValues: { url: "", slug: "", title: "", maxVisits: 0, expDate: undefined, forwardQueryParams: true, crawlable: false } }) async function handleSubmit(data: AdvancedUrlFormValues) { const res = await createAdvanceUrl(data) if (res.error) { toast.error(res.message) } else { toast.success(res.message) form.reset() } } return ( Create Advanced Short Link Create a short link with advanced configuration options.
( Original URL The URL you want to shorten. )} /> ( Custom Slug (Optional) A unique identifier for your short link (max 10 characters). )} /> (
Forward Query Parameters Forward query parameters from the short link to the destination URL.
)} /> (
Crawlable (Optional) Allow search engines to crawl and index this link.
)} />
( Title (Optional) A descriptive title for your link (max 100 characters). )} /> ( Max Visits (Optional) field.onChange(e.target.value ? parseInt(e.target.value) : undefined)} /> Maximum number of visits before the link expires. )} /> ( Expiration Date (Optional) When this link should expire and become inaccessible. )} />
) }