started connect with api
This commit is contained in:
1 parent
0ca218505d
commit
6da59f42d9
112 files changed
+7091
-6989
No files matched your search
@@ -5,7 +5,6 @@ import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { FormActions } from "@/components/formActions";
|
||||
import { FormInput } from "@/components/formInput";
|
||||
import { MultiLangInput } from "@/components/multiLangInput";
|
||||
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||
import type { District } from "../api/districtsApi";
|
||||
@@ -31,11 +30,13 @@ export interface DistrictFormProps {
|
||||
|
||||
function mapInitial(data: District): DistrictFormData {
|
||||
return {
|
||||
nameTk: data.name.tk,
|
||||
nameTk: data.name.tm,
|
||||
nameRu: data.name.ru,
|
||||
nameEn: data.name.en,
|
||||
description: data.description ?? "",
|
||||
isActive: data.isActive,
|
||||
regionTk: data.region.tm,
|
||||
regionRu: data.region.ru,
|
||||
regionEn: data.region.en,
|
||||
isActive: data.active,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,6 +106,12 @@ export function DistrictForm({ mode, initialData }: DistrictFormProps) {
|
||||
en: { value: form.nameEn, onChange: set("nameEn"), error: errors.nameEn },
|
||||
};
|
||||
|
||||
const regionFields = {
|
||||
tk: { value: form.regionTk, onChange: set("regionTk"), error: errors.regionTk },
|
||||
ru: { value: form.regionRu, onChange: set("regionRu"), error: errors.regionRu },
|
||||
en: { value: form.regionEn, onChange: set("regionEn"), error: errors.regionEn },
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
@@ -118,14 +125,12 @@ export function DistrictForm({ mode, initialData }: DistrictFormProps) {
|
||||
</p>
|
||||
<MultiLangInput fields={nameFields} placeholder={t("districts.fields.name", "Ady")} />
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("districts.fields.description", "Bellikler")}
|
||||
value={form.description}
|
||||
onChange={set("description")}
|
||||
placeholder={t("districts.fields.description", "Bellikler")}
|
||||
/>
|
||||
<BentoCard span="full">
|
||||
<p className="text-sm font-semibold text-muted-foreground mb-1">
|
||||
{t("districts.fields.region", "Region")}
|
||||
<span className="text-destructive ml-0.5">*</span>
|
||||
</p>
|
||||
<MultiLangInput fields={regionFields} placeholder={t("districts.fields.region", "Region")} />
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<div className="flex items-center gap-3 pt-1">
|
||||
@@ -138,7 +143,6 @@ export function DistrictForm({ mode, initialData }: DistrictFormProps) {
|
||||
isPending={isPending}
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => navigate("/settings/location/districts")}
|
||||
cancelVariant="ghost"
|
||||
submitLabel={mode === "create" ? t("districts.actions.create", "Etrap döret") : t("districts.actions.update", "Täzelemek")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user