mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-28 00:35:32 +08:00
ec1ae7073f
- Add notes field to Provider model (backend and frontend) - Display notes with higher priority than URL in provider card - Style notes as non-clickable text to differentiate from URLs - Add notes input field in provider form - Add i18n support (zh/en) for notes field
66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
import { useTranslation } from "react-i18next";
|
|
import {
|
|
FormControl,
|
|
FormField,
|
|
FormItem,
|
|
FormLabel,
|
|
FormMessage,
|
|
} from "@/components/ui/form";
|
|
import { Input } from "@/components/ui/input";
|
|
import type { UseFormReturn } from "react-hook-form";
|
|
import type { ProviderFormData } from "@/lib/schemas/provider";
|
|
|
|
interface BasicFormFieldsProps {
|
|
form: UseFormReturn<ProviderFormData>;
|
|
}
|
|
|
|
export function BasicFormFields({ form }: BasicFormFieldsProps) {
|
|
const { t } = useTranslation();
|
|
|
|
return (
|
|
<>
|
|
<FormField
|
|
control={form.control}
|
|
name="name"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormLabel>{t("provider.name")}</FormLabel>
|
|
<FormControl>
|
|
<Input {...field} placeholder={t("provider.namePlaceholder")} />
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
|
|
<FormField
|
|
control={form.control}
|
|
name="websiteUrl"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormLabel>{t("provider.websiteUrl")}</FormLabel>
|
|
<FormControl>
|
|
<Input {...field} placeholder="https://" />
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
|
|
<FormField
|
|
control={form.control}
|
|
name="notes"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormLabel>{t("provider.notes")}</FormLabel>
|
|
<FormControl>
|
|
<Input {...field} placeholder={t("provider.notesPlaceholder")} />
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
</>
|
|
);
|
|
}
|