Skip to content

Commit

Permalink
refactor: layout (#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
ertugrulcan-ays authored Sep 24, 2024
2 parents cfd6d01 + f9b7f3e commit c6dcc3a
Show file tree
Hide file tree
Showing 36 changed files with 836 additions and 1,701 deletions.
56 changes: 0 additions & 56 deletions apps/web/src/app/[lang]/app/[type]/breadcrumb.tsx

This file was deleted.

109 changes: 0 additions & 109 deletions apps/web/src/app/[lang]/app/[type]/crm/[data]/(main)/layout.tsx

This file was deleted.

115 changes: 115 additions & 0 deletions apps/web/src/app/[lang]/app/[type]/crm/[data]/[id]/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"use server";
import type {
ApiError,
UniRefund_CRMService_AddressTypes_UpdateAddressTypeDto,
UniRefund_CRMService_EmailCommonDatas_UpdateEmailCommonDataDto,
UniRefund_CRMService_Organizations_UpdateOrganizationDto,
UniRefund_CRMService_TelephoneTypes_UpdateTelephoneTypeDto,
} from "@ayasofyazilim/saas/CRMService";
import { revalidatePath } from "next/cache";
import { getCRMServiceClient } from "src/lib";

export async function getCRMMerchantDetailServer(body: { id: string }) {
"use server";
const response = await getCRMServiceClient().then((client) =>
client.merchant
.getApiCrmServiceMerchantsByIdDetail({
id: body.id,
})
.then((apiResponse) => {
return {
data: apiResponse,
status: 200,
};
})
.catch((error: ApiError) => {
return {
data: error,
status: error.status,
};
}),
);
revalidatePath("/");
return response;
}
export async function getCRMDetailServer(data: string, body: { id: string }) {
"use server";
const client = await getCRMServiceClient();
let response;
if (data === "refund-points") {
response = await client.refundPoint.getApiCrmServiceRefundPointsByIdDetail({
id: body.id,
});
} else if (data === "customs") {
response = await client.customs.getApiCrmServiceCustomsByIdDetail({
id: body.id,
});
} else if (data === "tax-free") {
response = await client.taxFree.getApiCrmServiceTaxFreesByIdDetail({
id: body.id,
});
} else if (data === "tax-offices") {
response = await client.taxOffice.getApiCrmServiceTaxOfficesByIdDetail({
id: body.id,
});
}
revalidatePath("/");
return {
data: response,
status: 200,
};
}
export async function updateMerchantCRMDetailServer(
id: string,
organizationId: string,
type: "merchant",
requestBody: UniRefund_CRMService_Organizations_UpdateOrganizationDto,
) {
"use server";
try {
const client = await getCRMServiceClient();
await client.merchant.putApiCrmServiceMerchantsByIdOrganizationsByOrganizationId(
{
id,
organizationId,
requestBody,
},
);
revalidatePath("/");
return true;
} catch (error) {
return error;
}
}
export async function updateCRMDetailServer(
id: string,
requestBody:
| UniRefund_CRMService_EmailCommonDatas_UpdateEmailCommonDataDto
| UniRefund_CRMService_TelephoneTypes_UpdateTelephoneTypeDto
| UniRefund_CRMService_AddressTypes_UpdateAddressTypeDto,
) {
"use server";
try {
const client = await getCRMServiceClient();
if ("emailAddress" in requestBody) {
await client.emailCommonData.putApiCrmServiceEmailsById({
id,
requestBody,
});
} else if ("addressLine" in requestBody) {
await client.addressType.putApiCrmServiceAddressesById({
id,
requestBody,
});
} else if ("localNumber" in requestBody) {
await client.telephoneType.putApiCrmServiceTelephonesById({
id,
requestBody,
});
}
revalidatePath("/");
return true;
} catch (error) {
return error;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
"use client";
import { Card } from "@/components/ui/card";
import { toast } from "@/components/ui/sonner";
import type {
UniRefund_CRMService_AddressTypes_UpdateAddressTypeDto,
UniRefund_CRMService_EmailCommonDatas_UpdateEmailCommonDataDto,
UniRefund_CRMService_Merchants_MerchantDto,
UniRefund_CRMService_Organizations_UpdateOrganizationDto,
UniRefund_CRMService_TelephoneTypes_UpdateTelephoneTypeDto,
Volo_Abp_Application_Dtos_PagedResultDto_15,
Volo_Abp_Application_Dtos_PagedResultDto_18,
} from "@ayasofyazilim/saas/CRMService";
import { $UniRefund_CRMService_Individuals_IndividualProfileDto } from "@ayasofyazilim/saas/CRMService";
import { createZodObject } from "@repo/ayasofyazilim-ui/lib/create-zod-object";
import jsonToCSV from "@repo/ayasofyazilim-ui/lib/json-to-csv";
import { PageHeader } from "@repo/ayasofyazilim-ui/molecules/page-header";
import type { TableAction } from "@repo/ayasofyazilim-ui/molecules/tables";
import DataTable from "@repo/ayasofyazilim-ui/molecules/tables";
import AutoForm, {
Expand All @@ -13,41 +22,29 @@ import {
SectionLayout,
SectionLayoutContent,
} from "@repo/ayasofyazilim-ui/templates/section-layout-v2";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import type {
UniRefund_CRMService_Merchants_MerchantDto,
Volo_Abp_Application_Dtos_PagedResultDto_18,
Volo_Abp_Application_Dtos_PagedResultDto_15,
UniRefund_CRMService_Organizations_UpdateOrganizationDto,
UniRefund_CRMService_EmailCommonDatas_UpdateEmailCommonDataDto,
UniRefund_CRMService_TelephoneTypes_UpdateTelephoneTypeDto,
UniRefund_CRMService_AddressTypes_UpdateAddressTypeDto,
} from "@ayasofyazilim/saas/CRMService";
import { $UniRefund_CRMService_Individuals_IndividualProfileDto } from "@ayasofyazilim/saas/CRMService";
import { getResourceDataClient } from "src/language-data/CRMService";
import { useLocale } from "src/providers/locale";
import type { TableData } from "src/utils";
import { getBaseLink } from "src/utils";
import { isPhoneValid, splitPhone } from "src/utils-phone";
import {
deleteSubMerchantByMerchantId,
getAllIndividuals,
getSubCompanyByMerchantId,
} from "../../../actions/merchant";
} from "../../actions/merchant";
import {
address,
dataConfigOfCrm,
email,
localNumber,
organization,
telephone,
} from "../../../data";
} from "../../data";
import {
updateCRMDetailServer,
updateMerchantCRMDetailServer,
} from "../../../actions/action";
} from "../../actions/action";

export default function Form({
crmDetailData,
Expand All @@ -60,9 +57,6 @@ export default function Form({
lang: string;
};
}) {
const [formData] = useState<TableData>(
dataConfigOfCrm.companies.pages[params.data],
);
const router = useRouter();
const [SubCompaniesData, setSubCompaniesData] =
useState<Volo_Abp_Application_Dtos_PagedResultDto_18>();
Expand Down Expand Up @@ -246,20 +240,6 @@ export default function Form({

return (
<div className="h-full overflow-hidden">
<PageHeader
LinkElement={Link}
description={
languageData[
`${formData.title?.replaceAll(" ", "")}.Edit` as keyof typeof languageData
]
}
href={getBaseLink(`/app/admin/crm/${params.data}`)}
title={
languageData[
`${formData.title?.replaceAll(" ", "")}.Edit` as keyof typeof languageData
]
}
/>
<SectionLayout
sections={[
{ name: languageData.Organization, id: "organization" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { getResourceDataClient } from "src/language-data/CRMService";
import { useLocale } from "src/providers/locale";
import { getBaseLink } from "src/utils";
import { isPhoneValid, splitPhone } from "src/utils-phone";
import { postIndividual } from "../../../../../actions/merchant";
import { telephone, address, email } from "../../../../../data";
import { postIndividual } from "../../../../actions/merchant";
import { telephone, address, email } from "../../../../data";

export interface CreateIndividualDto {
name: {
Expand Down Expand Up @@ -178,7 +178,7 @@ export default function Page({
},
},
}}
formClassName="pb-40 "
formClassName="pb-4"
formSchema={formSchemaByData()}
onSubmit={(val) => {
void handleIndividualSave(val as CreateIndividualDto);
Expand Down
Loading

0 comments on commit c6dcc3a

Please sign in to comment.