Skip to content

Commit

Permalink
chore: saas change & uncomment refund fee details (#901)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusualhashash authored Nov 29, 2024
2 parents 812d383 + 596ee8c commit 12e7748
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 524 deletions.
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@auth/core": "^0.30.0",
"@ayasofyazilim/saas": "0.0.76",
"@ayasofyazilim/saas": "0.0.77",
"@formatjs/intl-localematcher": "^0.5.4",
"@radix-ui/react-icons": "^1.3.0",
"@repo/ayasofyazilim-ui": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export function ContractSettingsSection({
) : (
<SchemaFormForContractSettings
addressList={addresses}
formData={{ isDefault: true }}
formData={{}}
handleFetch={handleFetch}
languageData={languageData}
loading={loading}
Expand Down Expand Up @@ -302,10 +302,7 @@ function SchemaFormForContractSettings({
const response =
await postMerchantContractHeaderContractSettingsByHeaderIdApi({
id: submitId,
requestBody: {
...data,
isDefault: false,
},
requestBody: data,
});
if (response.type === "success") {
toast.success(
Expand Down Expand Up @@ -374,15 +371,13 @@ function SchemaFormForContractSettings({
withScrollArea
>
<div className="sticky bottom-0 z-50 flex justify-end gap-2 bg-white py-4">
{!formData.isDefault && (
<DeleteDialog
handleFetch={handleFetch}
languageData={languageData}
setLoading={setLoading}
setTempSettings={setTempSettings}
submitId={type === "temp" ? "$temp" : submitId}
/>
)}
<DeleteDialog
handleFetch={handleFetch}
languageData={languageData}
setLoading={setLoading}
setTempSettings={setTempSettings}
submitId={type === "temp" ? "$temp" : submitId}
/>
<Button type="submit">
{type === "edit"
? languageData["Contracts.Edit.Submit"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import { createUiSchemaWithResource } from "@repo/ayasofyazilim-ui/organisms/sch
import { toastOnSubmit } from "@repo/ui/toast-on-submit";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { getRefundTableHeaders } from "src/app/[lang]/app/[type]/settings/templates/refund/action";
import { postMerchantContractHeadersByMerchantIdApi } from "src/app/[lang]/app/actions/ContractService/action";
import {
getRefundTableHeadersApi,
postMerchantContractHeadersByMerchantIdApi,
} from "src/app/[lang]/app/actions/ContractService/action";
import type { ContractServiceResource } from "src/language-data/ContractService";
import { getBaseLink } from "src/utils";
import { MerchantAddressWidget, RefundTableWidget } from "./contract-widgets";
Expand Down Expand Up @@ -102,7 +104,7 @@ export default function ContractHeaderForm<
useEffect(() => {
async function fetchRefundTableHeaders() {
setLoading(true);
const response = await getRefundTableHeaders({ maxResultCount: 100 });
const response = await getRefundTableHeadersApi({ maxResultCount: 100 });
if (response.type === "error" || response.type === "api-error") {
toast.error(response.message || response.status);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"use client";
import type {
UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderDto,
UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderUpdateDto,
} from "@ayasofyazilim/saas/ContractService";
import type { UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderDto } from "@ayasofyazilim/saas/ContractService";
import { $UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderUpdateDto } from "@ayasofyazilim/saas/ContractService";
import { SchemaForm } from "@repo/ayasofyazilim-ui/organisms/schema-form";
import { createUiSchemaWithResource } from "@repo/ayasofyazilim-ui/organisms/schema-form/utils";
Expand Down Expand Up @@ -31,8 +28,7 @@ function Form({
onSubmit={(data) => {
const formData = {
id: response.id,
requestBody:
data.formData as UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderUpdateDto,
requestBody: data.formData,
};
void putRefundFeeHeadersApi(formData).then((res) => {
handlePutResponse(res, router);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default async function Page({
<>
<Form languageData={languageData} response={response.data} />
<RefundFeeDetailsForm
// languageData={languageData}
// response={response.data}
languageData={languageData}
response={response.data}
/>
<div className="hidden" id="page-title">
{response.data.name}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,97 +1,86 @@
"use client";
// import { UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderDto } from "@ayasofyazilim/saas/ContractService";
// import type {
// UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateDto,
// UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderDto,
// } from "@ayasofyazilim/saas/ContractService";
import { $UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateByListDto } from "@ayasofyazilim/saas/ContractService";
import type {
UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateDto,
UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderDto,
} from "@ayasofyazilim/saas/ContractService";
import { tanstackTableEditableColumnsByRowData } from "@repo/ayasofyazilim-ui/molecules/tanstack-table/utils";
import { SchemaForm } from "@repo/ayasofyazilim-ui/organisms/schema-form";
import { TableField } from "@repo/ayasofyazilim-ui/organisms/schema-form/fields";
import { PlusCircle, Trash2 } from "lucide-react";
import { useRouter } from "next/navigation";
import { handlePostResponse } from "src/app/[lang]/app/actions/api-utils-client";
import { postRefundFeeHeadersRefundFeeDetailsApi } from "src/app/[lang]/app/actions/ContractService/post-actions";
import type { ContractServiceResource } from "src/language-data/ContractService";

// import { $UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateByListDto } from "@ayasofyazilim/saas/ContractService";
// import { tanstackTableEditableColumnsByRowData } from "@repo/ayasofyazilim-ui/molecules/tanstack-table/utils";
// import { SchemaForm } from "@repo/ayasofyazilim-ui/organisms/schema-form";
// import { TableField } from "@repo/ayasofyazilim-ui/organisms/schema-form/fields";
// import { PlusCircle, Trash2 } from "lucide-react";
// import { useRouter } from "next/navigation";
// import { handlePostResponse } from "src/app/[lang]/app/actions/api-utils-client";
// import { postRefundFeeHeadersRefundFeeDetailsApi } from "src/app/[lang]/app/actions/ContractService/post-actions";
// import type { ContractServiceResource } from "src/language-data/ContractService";
type TypeWithId<Type, IdType = string> = Type & {
id: IdType;
};

// type TypeWithId<Type, IdType = string> = Type & {
// id: IdType;
// };
export default function RefundFeeDetailsForm({
response,
languageData,
}: {
response: UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderDto;
languageData: ContractServiceResource;
}) {
const router = useRouter();
const RebateFeeColumns = tanstackTableEditableColumnsByRowData<
TypeWithId<UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateDto>
>({
rows: $UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateByListDto
.properties.refundFeeDetails.items.properties,
excludeColumns: ["extraProperties"],
});
return (
<SchemaForm
fields={{
RebateTable: TableField<
TypeWithId<UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateDto>
>({
editable: true,
columns: RebateFeeColumns,
data: response.refundFeeDetails || [],
fillerColumn: "id",
tableActions: [
{
type: "create-row",
actionLocation: "table",
cta: languageData["Rebate.Create"],
icon: PlusCircle,
},
],
rowActions: [
{
actionLocation: "row",
cta: languageData.Delete,
icon: Trash2,
type: "delete-row",
},
],
}),
}}
formData={response.refundFeeDetails || []}
onSubmit={(data) => {
const formData = data.formData;

export default function RefundFeeDetailsForm() {
// {
// // response,
// // languageData,
// }: {
// // response: UniRefund_ContractService_Refunds_RefundFeeHeaders_RefundFeeHeaderDto;
// // languageData: ContractServiceResource;
// },
return null;
// const router = useRouter();
// const RebateFeeColumns = tanstackTableEditableColumnsByRowData<
// TypeWithId<UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateDto>
// >({
// rows: $UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateByListDto
// .properties.refundFeeDetails.items.properties,
// excludeColumns: ["extraProperties"],
// });
// return (
// <SchemaForm
// fields={{
// RebateTable: TableField<
// TypeWithId<UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateDto>
// >({
// editable: true,
// showPagination: false,
// columns: RebateFeeColumns,
// data: response.refundFeeDetails || [],
// fillerColumn: "id",
// tableActions: [
// {
// type: "create-row",
// actionLocation: "table",
// cta: languageData[
// "RebateTables.Templates.Form.rebateTableDetails.add"
// ],
// icon: PlusCircle,
// },
// ],
// rowActions: [
// {
// actionLocation: "row",
// cta: languageData[
// "RebateTables.Templates.Form.rebateTableDetails.delete"
// ],
// icon: Trash2,
// type: "delete-row",
// },
// ],
// }),
// }}
// formData={response.refundFeeDetails || []}
// onSubmit={(data) => {
// const formData = (data.formData ||
// []) as UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateDto[];

// void postRefundFeeHeadersRefundFeeDetailsApi({
// id: response.id,
// requestBody: {
// // @ts-expect-error UNI-582
// refundFeeDetails: formData,
// },
// }).then((res) => {
// handlePostResponse(res, router);
// });
// }}
// schema={
// $UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateByListDto
// .properties.refundFeeDetails
// }
// submitText={languageData["RefundTables.Create.Submit"]}
// uiSchema={{
// "ui:field": "RebateTable",
// }}
// />
// );
void postRefundFeeHeadersRefundFeeDetailsApi({
id: response.id,
requestBody: {
refundFeeDetails: formData,
},
}).then((res) => {
handlePostResponse(res, router);
});
}}
schema={
$UniRefund_ContractService_Refunds_RefundFeeDetails_RefundFeeDetailCreateByListDto
.properties.refundFeeDetails
}
submitText={languageData["RefundTables.Create.Submit"]}
uiSchema={{
"ui:field": "RebateTable",
}}
/>
);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"use client";
import type {
UniRefund_ContractService_Refunds_RefundTableHeaders_RefundTableHeaderDto,
UniRefund_ContractService_Refunds_RefundTableHeaders_RefundTableHeaderUpdateDto,
} from "@ayasofyazilim/saas/ContractService";
import type { UniRefund_ContractService_Refunds_RefundTableHeaders_RefundTableHeaderDto } from "@ayasofyazilim/saas/ContractService";
import { $UniRefund_ContractService_Refunds_RefundTableHeaders_RefundTableHeaderUpdateDto } from "@ayasofyazilim/saas/ContractService";
import { SchemaForm } from "@repo/ayasofyazilim-ui/organisms/schema-form";
import { createUiSchemaWithResource } from "@repo/ayasofyazilim-ui/organisms/schema-form/utils";
Expand Down Expand Up @@ -31,8 +28,7 @@ function Form({
onSubmit={(data) => {
const formData = {
id: response.id,
requestBody:
data.formData as UniRefund_ContractService_Refunds_RefundTableHeaders_RefundTableHeaderUpdateDto,
requestBody: data.formData,
};
void putRefundTableHeadersApi(formData).then((res) => {
handlePutResponse(res, router);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { notFound } from "next/navigation";
import { getResourceData } from "src/language-data/ContractService";
import { getRefundTableHeadersById } from "../../refund/action";
import { getRefundTableHeadersById } from "src/app/[lang]/app/actions/ContractService/action";
import Form from "./form";
import RefundTableDetailsForm from "./table";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export default function RefundTableDetailsForm({
TypeWithId<UniRefund_ContractService_Refunds_RefundTableDetails_RefundTableDetailCreateDto>
>({
editable: true,
showPagination: false,
columns: RebateTableColumns,
// @ts-expect-error UNI-577
data: response.refundTableDetails || [],
fillerColumn: "id",
tableActions: [
Expand All @@ -64,8 +62,7 @@ export default function RefundTableDetailsForm({
}}
formData={response.refundTableDetails || []}
onSubmit={(data) => {
const formData = (data.formData ||
[]) as UniRefund_ContractService_Refunds_RefundTableDetails_RefundTableDetailCreateDto[];
const formData = data.formData;

void postRefundTableHeadersRefundTableDetailsApi({
id: response.id,
Expand Down
Loading

0 comments on commit 12e7748

Please sign in to comment.