Skip to content

Commit

Permalink
feat(Contract): update & edit (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
eren-ayasofyazilim authored Dec 3, 2024
2 parents b27675b + 42baf64 commit 24d153a
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import type {
UniRefund_ContractService_ContractsForMerchant_ContractHeaders_ContractHeaderDetailForMerchantDto as ContractHeaderDetailForMerchantDto,
UniRefund_ContractService_ContractsForMerchant_ContractHeaders_ContractHeaderForMerchantUpdateDto as ContractHeaderForMerchantUpdateDto,
UniRefund_ContractService_Refunds_RefundTableHeaders_RefundTableHeaderDto as RefundTableHeaderDto,
} from "@ayasofyazilim/saas/ContractService";
import type { UniRefund_LocationService_AddressCommonDatas_AddressCommonDataDto as AddressCommonDataDto } from "@ayasofyazilim/saas/LocationService";
import type { ContractServiceResource } from "src/language-data/ContractService";
Expand All @@ -14,35 +14,29 @@ export function ContractHeader({
partyId,
addressList,
languageData,
refundTableHeaders,
}: {
contractHeaderDetails: ContractHeaderDetailForMerchantDto;
partyName: "merchants";
partyId: string;
addressList: AddressCommonDataDto[];
refundTableHeaders: RefundTableHeaderDto[];
languageData: ContractServiceResource;
}) {
const refundTableHeaders =
contractHeaderDetails.contractHeaderRefundTableHeaders.map((header) => {
return {
refundTableHeaderId: header.refundTableHeader.id,
validFrom: header.validFrom,
validTo: header.validTo,
isDefault: header.isDefault,
};
});
return (
<ContractHeaderForm<ContractHeaderForMerchantUpdateDto>
<ContractHeaderForm
addresses={addressList}
contractId={contractHeaderDetails.id}
formData={{
...contractHeaderDetails,
status: contractHeaderDetails.status || "None",
addressCommonDataId: contractHeaderDetails.addressCommonData.id,
refundTableHeaders,
}}
formType="Update"
formType="update"
languageData={languageData}
partyId={partyId}
partyName={partyName}
refundTableHeaders={refundTableHeaders}
/>
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { UniRefund_ContractService_ContractsForMerchant_ContractHeaders_ContractHeaderDetailForMerchantDto as ContractHeaderDetailForMerchantDto } from "@ayasofyazilim/saas/ContractService";
import type { UniRefund_LocationService_AddressCommonDatas_AddressCommonDataDto as AddressCommonDataDto } from "@ayasofyazilim/saas/LocationService";
import { notFound } from "next/navigation";
import { getResourceData } from "src/language-data/ContractService";
import { getRefundTableHeadersApi } from "src/app/[lang]/app/actions/ContractService/action";
import { ContractHeader } from "./contract-header";

export default async function ContractPage({
Expand All @@ -17,13 +19,16 @@ export default async function ContractPage({
addressList: AddressCommonDataDto[];
}) {
const { languageData } = await getResourceData(lang);
const refundTableHeaders = await getRefundTableHeadersApi({});
if (refundTableHeaders.type !== "success") return notFound();
return (
<ContractHeader
addressList={addressList}
contractHeaderDetails={contractHeaderDetails}
languageData={languageData}
partyId={partyId}
partyName={partyName}
refundTableHeaders={refundTableHeaders.data.items || []}
/>
);
}
Loading

0 comments on commit 24d153a

Please sign in to comment.