Skip to content

Commit

Permalink
Refactor: improve the crm code (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
ertugrulcan-ays authored Sep 24, 2024
2 parents b72a45d + e0db25c commit cfd6d01
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 377 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ import {
getAllIndividuals,
getSubCompanyByMerchantId,
} from "../../../actions/merchant";
import { dataConfigOfCrm, localNumber } from "../../../data";
import { updateCRMDetailServer, updateMerchantCRMDetailServer } from "./action";
import { address, email, organization, telephone } from "./data";
import {
address,
dataConfigOfCrm,
email,
localNumber,
organization,
telephone,
} from "../../../data";
import {
updateCRMDetailServer,
updateMerchantCRMDetailServer,
} from "../../../actions/action";

export default function Form({
crmDetailData,
Expand Down Expand Up @@ -375,7 +384,12 @@ export default function Form({
actionList: [
{
cta: languageData.Delete,
type: "Action",
type: "Dialog",
componentType: "ConfimrationDialog",
title: `${languageData.Delete} ${params.data}`,
description: languageData["Delete.Assurance"],
cancelCTA: languageData.Cancel,
variant: "destructive",
callback: (row: { id: string }) => {
void deleteSubMerchant(row.id);
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,109 @@ import AutoForm, {
AutoFormSubmit,
} from "@repo/ayasofyazilim-ui/organisms/auto-form";
import { useRouter } from "next/navigation";
import {
$UniRefund_CRMService_NameCommonDatas_CreateNameCommonDataDto,
$UniRefund_CRMService_PersonalSummaries_CreatePersonalSummaryDto,
} from "@ayasofyazilim/saas/CRMService";
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 type { CreateIndividualDto } from "./data";
import {
createIndividualScheme,
formPositions,
formSubPositions,
} from "./data";
import { telephone, address, email } from "../../../../../data";

export interface CreateIndividualDto {
name: {
salutation: string;
name: string;
suffix: string;
mailingName: string;
officialName: string;
};
personalSummary: {
date: string;
birthDate: string;
ethnicity: string;
maritalStatusCode: string;
religiousAffiliationName: string;
genderTypeCode: 0 | 1;
};

telephone: {
areaCode: string;
localNumber: string;
ituCountryCode: string;
primaryFlag: boolean;
typeCode: 0 | 1 | 2 | 3;
};
address: {
addressLine: string;
city: string;
terriority: string;
postalCode: string;
country: string;
fullAddress: string;
primaryFlag: boolean;
typeCode: 0 | 1;
};
email: {
emailAddress: string;
primaryFlag: boolean;
typeCode: 0 | 1;
};
}

const createIndividualScheme = {
type: "object",
properties: {
name: $UniRefund_CRMService_NameCommonDatas_CreateNameCommonDataDto,
personalSummary: {
...$UniRefund_CRMService_PersonalSummaries_CreatePersonalSummaryDto,
properties: {
...$UniRefund_CRMService_PersonalSummaries_CreatePersonalSummaryDto.properties,
genderTypeCode: {
enum: ["Male", "Female"],
type: "integer",
format: "int32",
},
},
},
telephone,
address,
email,
},
};

const formPositions = [
"name",
"telephone",
"personalSummary",
"address",
"email",
];

const formSubPositions = {
name: ["salutation", "name", "suffix", "mailingName", "officialName"],
personalSummary: [
"date",
"birthDate",
"ethnicity",
"maritalStatusCode",
"religiousAffiliationName",
"genderTypeCode",
],
telephone: ["localNumber", "typeCode"],
address: [
"country",
"terriority",
"city",
"postalCode",
"addressLine",
"fullAddress",
"typeCode",
],
email: ["emailAddress", "typeCode"],
};

export default function Page({
params,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"use server";
import { getCRMDetailServer, getCRMMerchantDetailServer } from "./action";
import {
getCRMDetailServer,
getCRMMerchantDetailServer,
} from "../../../actions/action";
import Form from "./form";

async function getCrmDetailData(data: string, id: string) {
Expand Down
Loading

0 comments on commit cfd6d01

Please sign in to comment.