-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add update merchant base to parties (#764)
- Loading branch information
Showing
6 changed files
with
144 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/merchant/form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
"use client"; | ||
|
||
import type { UniRefund_CRMService_Merchants_UpdateMerchantDto } from "@ayasofyazilim/saas/CRMService"; | ||
import { $UniRefund_CRMService_Merchants_MerchantBaseDto } from "@ayasofyazilim/saas/CRMService"; | ||
import { createZodObject } from "@repo/ayasofyazilim-ui/lib/create-zod-object"; | ||
import AutoForm, { | ||
AutoFormSubmit, | ||
} from "@repo/ayasofyazilim-ui/organisms/auto-form"; | ||
import { SectionLayoutContent } from "@repo/ayasofyazilim-ui/templates/section-layout-v2"; | ||
import { getEnumId, getEnumName } from "@repo/ui/utils/table/table-utils"; | ||
import { useRouter } from "next/navigation"; | ||
import type { CRMServiceServiceResource } from "src/language-data/CRMService"; | ||
import type { PutMerchantBase } from "../types"; | ||
import { handleUpdateSubmit } from "../utils"; | ||
|
||
function MerchantForm({ | ||
languageData, | ||
partyName, | ||
partyId, | ||
taxOfficesEnum, | ||
merchantData: individualData, | ||
}: { | ||
languageData: CRMServiceServiceResource; | ||
partyName: "merchants"; | ||
partyId: string; | ||
taxOfficesEnum: { name: string; id: string }[]; | ||
merchantData: UniRefund_CRMService_Merchants_UpdateMerchantDto | undefined; | ||
}) { | ||
const router = useRouter(); | ||
|
||
const schema = createZodObject( | ||
$UniRefund_CRMService_Merchants_MerchantBaseDto, | ||
["typeCode", "taxOfficeId"], | ||
{ | ||
taxOfficeId: { | ||
type: "enum", | ||
data: taxOfficesEnum.map((i) => i.name), | ||
}, | ||
}, | ||
); | ||
return ( | ||
<SectionLayoutContent sectionId="merchant-base"> | ||
<AutoForm | ||
formClassName="pb-40" | ||
formSchema={schema} | ||
onSubmit={(values: PutMerchantBase["data"]["requestBody"]) => { | ||
void handleUpdateSubmit( | ||
partyName, | ||
{ | ||
action: "merchant-base", | ||
data: { | ||
requestBody: { | ||
...values, | ||
taxOfficeId: getEnumId( | ||
taxOfficesEnum, | ||
values?.taxOfficeId || "", | ||
), | ||
}, | ||
id: partyId, | ||
}, | ||
}, | ||
router, | ||
); | ||
}} | ||
values={{ | ||
...individualData, | ||
taxOfficeId: getEnumName( | ||
taxOfficesEnum, | ||
individualData?.taxOfficeId || "", | ||
), | ||
}} | ||
> | ||
<AutoFormSubmit className="float-right"> | ||
{languageData.Save} | ||
</AutoFormSubmit> | ||
</AutoForm> | ||
</SectionLayoutContent> | ||
); | ||
} | ||
|
||
export default MerchantForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters