diff --git a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/[contractId]/details.tsx b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/[contractId]/details.tsx
new file mode 100644
index 000000000..fb777cbd3
--- /dev/null
+++ b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/[contractId]/details.tsx
@@ -0,0 +1,116 @@
+"use client";
+import type { UniRefund_ContractService_ContractsForMerchant_ContractHeaders_ContractHeaderDetailForMerchantDto as ContractHeaderDetailForMerchantDto } from "@ayasofyazilim/saas/ContractService";
+import { $UniRefund_ContractService_ContractsForMerchant_ContractHeaders_ContractHeaderDetailForMerchantDto as $ContractHeaderDetailForMerchantDto } from "@ayasofyazilim/saas/ContractService";
+import { createZodObject } from "@repo/ayasofyazilim-ui/lib/create-zod-object";
+import AutoForm from "@repo/ayasofyazilim-ui/organisms/auto-form";
+import {
+ SectionLayout,
+ SectionLayoutContent,
+} from "@repo/ayasofyazilim-ui/templates/section-layout-v2";
+import type { ContractServiceResource } from "src/language-data/ContractService";
+
+interface DetailsProp {
+ contractHeaderDetails: ContractHeaderDetailForMerchantDto;
+ partyName: "merchants";
+ partyId: string;
+ languageData: ContractServiceResource;
+}
+export default function Details({ ...props }: DetailsProp) {
+ const { languageData } = props;
+ return (
+
+
+
+ {/* */}
+
+
+ );
+}
+
+function ContractSection({ ...props }: DetailsProp) {
+ const $DetailsSchema = createZodObject(
+ $ContractHeaderDetailForMerchantDto,
+ [
+ "name",
+ "webSite",
+ "merchantClassification",
+ "status",
+ "isDraft",
+ "addressCommonData",
+ "contractHeaderRefundTableHeaders",
+ ],
+ undefined,
+ {
+ merchantBasicInformationDto: ["name", "numberOfStores"],
+ addressCommonData: [
+ "countryId",
+ "regionId",
+ "cityId",
+ "districtId",
+ "neighborhoodId",
+ "addressLine",
+ "type",
+ ],
+ },
+ );
+
+ return (
+
+
+
+ );
+}
+
+function ContractSettingsSection({ languageData }: DetailsProp) {
+ return (
+
+ <>{languageData["Contracts.Create.ContractSettings"]}>
+
+ );
+}
+
+function RebateSettingsSection({ languageData }: DetailsProp) {
+ return (
+
+ <>{languageData["Contracts.Create.RebateSettings"]}>
+
+ );
+}
diff --git a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/[contractId]/page.tsx b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/[contractId]/page.tsx
index 4132c1fc9..84c9f8403 100644
--- a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/[contractId]/page.tsx
+++ b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/[contractId]/page.tsx
@@ -1,18 +1,40 @@
+import { getResourceData } from "src/language-data/ContractService";
import { getBaseLink } from "src/utils";
+import { getMerchantContractHeaderByIdApi } from "src/app/[lang]/app/actions/ContractService/action";
+import Details from "./details";
-export default function Page({
+export default async function Page({
params,
}: {
- params: { contractId: string; partyName: string; partyId: string };
-}): JSX.Element {
+ params: {
+ contractId: string;
+ partyName: "merchants";
+ partyId: string;
+ lang: string;
+ };
+}) {
+ const contractHeaderDetails = await getMerchantContractHeaderByIdApi(
+ params.contractId,
+ );
+ if (contractHeaderDetails.type !== "success") {
+ return <>XS>;
+ }
+
+ const { languageData } = await getResourceData(params.lang);
return (
<>
-
{params.contractId}
+
- Edit Contract - {params.contractId}
+ {languageData["Contracts.Edit.Title"]} - (
+ {contractHeaderDetails.data.name})
- You can edit contract from here.
+ {languageData["Contracts.Edit.Description"]}
{getBaseLink(
diff --git a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/action.ts b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/action.ts
deleted file mode 100644
index 76a3c46c5..000000000
--- a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/action.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-"use server";
-import type {
- GetApiContractServiceMerchantsByIdContractsContractHeadersData,
- GetApiContractServiceMerchantsContractsContractHeadersByIdGetMissingStepsData,
- GetApiContractServiceMerchantsContractsContractHeadersByIdGetMissingStepsResponse,
- PagedResultDto_ContractHeaderDetailForMerchantDto,
- PostApiContractServiceMerchantsByIdContractsContractHeadersData,
- UniRefund_ContractService_ContractsForMerchant_ContractHeaders_ContractHeaderForMerchantDto,
-} from "@ayasofyazilim/saas/ContractService";
-import { revalidatePath } from "next/cache";
-import type { ServerResponse } from "src/lib";
-import { getContractServiceClient, structuredError } from "src/lib";
-
-export async function getContractHeadersByMerchantId(
- body: GetApiContractServiceMerchantsByIdContractsContractHeadersData,
-): Promise
> {
- "use server";
- try {
- const client = await getContractServiceClient();
- const response =
- await client.contractsMerchant.getApiContractServiceMerchantsByIdContractsContractHeaders(
- body,
- );
- revalidatePath("/");
- return {
- type: "success",
- data: response,
- status: 200,
- message: "Contracts fetched successfully",
- };
- } catch (error) {
- return structuredError(error);
- }
-}
-
-export async function postContractHeadersByMerchantId(
- body: PostApiContractServiceMerchantsByIdContractsContractHeadersData,
-): Promise<
- ServerResponse
-> {
- "use server";
- try {
- const client = await getContractServiceClient();
- const response =
- await client.contractsMerchant.postApiContractServiceMerchantsByIdContractsContractHeaders(
- body,
- );
- revalidatePath("/");
- return {
- type: "success",
- data: response,
- status: 200,
- message: "Contract header created successfully.",
- };
- } catch (error) {
- return structuredError(error);
- }
-}
-
-export async function getContractHeaderMissingStepsById(
- body: GetApiContractServiceMerchantsContractsContractHeadersByIdGetMissingStepsData,
-): Promise<
- ServerResponse
-> {
- "use server";
- try {
- const client = await getContractServiceClient();
- const response =
- await client.contractsMerchant.getApiContractServiceMerchantsContractsContractHeadersByIdGetMissingSteps(
- body,
- );
- revalidatePath("/");
- return {
- type: "success",
- data: response,
- status: 200,
- message: "Contracts fetched successfully",
- };
- } catch (error) {
- return structuredError(error);
- }
-}
diff --git a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/form.tsx b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/form.tsx
index d121ad3e7..542479b8e 100644
--- a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/form.tsx
+++ b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/form.tsx
@@ -8,9 +8,9 @@ import DataTable from "@repo/ayasofyazilim-ui/molecules/tables";
import { SectionLayoutContent } from "@repo/ayasofyazilim-ui/templates/section-layout-v2";
import { useRouter } from "next/navigation";
import { useState } from "react";
+import { getMerchantContractHeadersByMerchantIdApi } from "src/app/[lang]/app/actions/ContractService/action";
import type { CRMServiceServiceResource } from "src/language-data/CRMService";
import { getBaseLink } from "src/utils";
-import { getContractHeadersByMerchantId } from "./action";
export default function Contracts({
languageData,
@@ -28,7 +28,7 @@ export default function Contracts({
async function getContractsOfMerchant() {
setLoading(true);
try {
- const response = await getContractHeadersByMerchantId({
+ const response = await getMerchantContractHeadersByMerchantIdApi({
id: partyId,
});
if (response.type === "error" || response.type === "api-error") {
diff --git a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/new/form.tsx b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/new/form.tsx
index 8d71e113b..ea0254bbc 100644
--- a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/new/form.tsx
+++ b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/new/form.tsx
@@ -29,11 +29,11 @@ import type { Dispatch, SetStateAction } from "react";
import { useEffect, useState } from "react";
import Rebate from "src/app/[lang]/app/[type]/settings/templates/rebate/rebate";
import { getRefundTableHeaders } from "src/app/[lang]/app/[type]/settings/templates/refund/action";
-import type { ContractServiceResource } from "src/language-data/ContractService";
import {
- getContractHeaderMissingStepsById,
- postContractHeadersByMerchantId,
-} from "../action";
+ getMerchantContractHeaderMissingStepsByIdApi,
+ postMerchantContractHeadersByMerchantIdApi,
+} from "src/app/[lang]/app/actions/ContractService/action";
+import type { ContractServiceResource } from "src/language-data/ContractService";
export default function ContractHeaderForm({
params,
@@ -92,7 +92,7 @@ export default function ContractHeaderForm({
loading={loading}
setLoading={setLoading}
/>
- {/* TODO IMPLEMENT STORES HERE */}
+ {/* */}
{
setLoading(true);
try {
- const missingStepsResponse = await getContractHeaderMissingStepsById({
- id: partyId,
- });
+ const missingStepsResponse =
+ await getMerchantContractHeaderMissingStepsByIdApi({
+ id: partyId,
+ });
if (missingStepsResponse.type === "success") {
setMissingSteps(missingStepsResponse.data);
} else {
@@ -148,14 +149,12 @@ function ContractSection({
): Promise {
toastOnSubmit(data);
- const postResponse = await postContractHeadersByMerchantId({
+ const postResponse = await postMerchantContractHeadersByMerchantIdApi({
id: partyId,
requestBody: data,
});
- if (postResponse.type !== "success") {
- if (postResponse.type === "api-error") {
- toast.error(postResponse.data);
- }
+ if (postResponse.type === "error" || postResponse.type === "api-error") {
+ toast.error(postResponse.message);
}
toast.success(postResponse.message || postResponse.status);
void fetchContractMissingSteps();
diff --git a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/new/page.tsx b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/new/page.tsx
index 520b45b86..e57543d4d 100644
--- a/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/new/page.tsx
+++ b/apps/web/src/app/[lang]/app/[type]/parties/[partyName]/[partyId]/contracts/new/page.tsx
@@ -1,7 +1,11 @@
-import { getBaseLink } from "src/utils";
-import { getApiRequests } from "src/app/[lang]/app/actions/api-requests";
+import { notFound } from "next/navigation";
+import {
+ getAdressesApi,
+ getBasicInformationApi,
+} from "src/app/[lang]/app/actions/CrmService/actions";
import type { ContractServiceResource } from "src/language-data/ContractService";
import { getResourceData } from "src/language-data/ContractService";
+import { getBaseLink } from "src/utils";
import ContractHeaderForm from "./form";
export default async function Page({
@@ -13,26 +17,27 @@ export default async function Page({
lang: string;
};
}) {
- const req = await getApiRequests();
- const basicInformation = await req[params.partyName].getBasicInformation({
- id: params.partyId,
- });
- const addresses = await req[params.partyName].getAdresses({
- id: params.partyId,
- });
+ const basicInformation = await getBasicInformationApi(
+ params.partyId,
+ params.partyName,
+ );
+ const addresses = await getAdressesApi(params.partyId, params.partyName);
+ if (basicInformation.type !== "success" || addresses.type !== "success") {
+ return notFound();
+ }
const { languageData } = await getResourceData(params.lang);
return (
<>
>
);
diff --git a/apps/web/src/app/[lang]/app/actions/ContractService/action.ts b/apps/web/src/app/[lang]/app/actions/ContractService/action.ts
new file mode 100644
index 000000000..bfef8d0c1
--- /dev/null
+++ b/apps/web/src/app/[lang]/app/actions/ContractService/action.ts
@@ -0,0 +1,71 @@
+import type {
+ GetApiContractServiceMerchantsByIdContractsContractHeadersData,
+ PagedResultDto_ContractHeaderDetailForMerchantDto,
+ PostApiContractServiceMerchantsByIdContractsContractHeadersData,
+} from "@ayasofyazilim/saas/ContractService";
+import type { ServerResponse } from "src/lib";
+import { structuredError } from "src/lib";
+import { getApiRequests } from "../api-requests";
+
+export async function getMerchantContractHeadersByMerchantIdApi(
+ data: GetApiContractServiceMerchantsByIdContractsContractHeadersData,
+) {
+ try {
+ const requests = getApiRequests();
+ return {
+ type: "success",
+ data: await (
+ await requests
+ ).merchants.getContractHeadersByMerchantId(data),
+ status: 200,
+ message: "",
+ } as ServerResponse;
+ } catch (error) {
+ return structuredError(error);
+ }
+}
+export async function getMerchantContractHeaderMissingStepsByIdApi(
+ data: GetApiContractServiceMerchantsByIdContractsContractHeadersData,
+) {
+ try {
+ const requests = getApiRequests();
+ return {
+ type: "success",
+ data: await (
+ await requests
+ ).merchants.getContractHeaderMissingStepsById(data.id),
+ status: 200,
+ message: "",
+ };
+ } catch (error) {
+ return structuredError(error);
+ }
+}
+export async function postMerchantContractHeadersByMerchantIdApi(
+ data: PostApiContractServiceMerchantsByIdContractsContractHeadersData,
+) {
+ try {
+ const requests = getApiRequests();
+ return {
+ type: "success",
+ data: await (await requests).merchants.postContractHeadersById(data),
+ status: 200,
+ message: "",
+ };
+ } catch (error) {
+ return structuredError(error);
+ }
+}
+export async function getMerchantContractHeaderByIdApi(id: string) {
+ try {
+ const requests = getApiRequests();
+ return {
+ type: "success",
+ data: await (await requests).merchants.getContractHeaderById(id),
+ status: 200,
+ message: "",
+ };
+ } catch (error) {
+ return structuredError(error);
+ }
+}
diff --git a/apps/web/src/app/[lang]/app/actions/CrmService/actions.ts b/apps/web/src/app/[lang]/app/actions/CrmService/actions.ts
index 2f8ddd53f..62eb7ef02 100644
--- a/apps/web/src/app/[lang]/app/actions/CrmService/actions.ts
+++ b/apps/web/src/app/[lang]/app/actions/CrmService/actions.ts
@@ -36,3 +36,38 @@ export async function getTaxOfficesApi(
return structuredError(error);
}
}
+
+export async function getBasicInformationApi(
+ id: string,
+ partyName: "merchants",
+) {
+ try {
+ const requests = getApiRequests();
+ return {
+ type: "success",
+ data: await (
+ await requests
+ )[partyName].getBasicInformation({
+ id,
+ }),
+ };
+ } catch (error) {
+ return structuredError(error);
+ }
+}
+
+export async function getAdressesApi(id: string, partyName: "merchants") {
+ try {
+ const requests = getApiRequests();
+ return {
+ type: "success",
+ data: await (
+ await requests
+ )[partyName].getAdresses({
+ id,
+ }),
+ };
+ } catch (error) {
+ return structuredError(error);
+ }
+}
diff --git a/apps/web/src/app/[lang]/app/actions/api-requests.ts b/apps/web/src/app/[lang]/app/actions/api-requests.ts
index 97a56af5e..407a524d5 100644
--- a/apps/web/src/app/[lang]/app/actions/api-requests.ts
+++ b/apps/web/src/app/[lang]/app/actions/api-requests.ts
@@ -1,12 +1,17 @@
"use server";
-import type { GetApiTravellerServiceTravellersData } from "@ayasofyazilim/saas/TravellerService";
-import type { FilterColumnResult } from "@repo/ayasofyazilim-ui/molecules/tables";
+import type {
+ GetApiContractServiceMerchantsContractsContractHeadersByIdData,
+ PostApiContractServiceMerchantsByIdContractsContractHeadersData,
+} from "@ayasofyazilim/saas/ContractService";
import type {
GetApiCrmServiceMerchantsData,
GetApiCrmServiceTaxOfficesData,
} from "@ayasofyazilim/saas/CRMService";
+import type { GetApiTravellerServiceTravellersData } from "@ayasofyazilim/saas/TravellerService";
+import type { FilterColumnResult } from "@repo/ayasofyazilim-ui/molecules/tables";
import {
+ getContractServiceClient,
getCRMServiceClient,
getTravellersServiceClient,
structuredError,
@@ -27,6 +32,7 @@ export type GetDetailTableDataTypes = Exclude;
export async function getApiRequests() {
const crmClient = await getCRMServiceClient();
const travellerClient = await getTravellersServiceClient();
+ const contractsClient = await getContractServiceClient();
const tableRequests = {
merchants: {
getDetail: async (id: string) =>
@@ -64,6 +70,26 @@ export async function getApiRequests() {
),
getAdresses: async (data: { id: string }) =>
await crmClient.merchant.getApiCrmServiceMerchantsByIdAddresses(data),
+ getContractHeadersByMerchantId: async (
+ data: GetApiContractServiceMerchantsContractsContractHeadersByIdData,
+ ) =>
+ await contractsClient.contractsMerchant.getApiContractServiceMerchantsContractsContractHeadersById(
+ data,
+ ),
+ postContractHeadersById: async (
+ data: PostApiContractServiceMerchantsByIdContractsContractHeadersData,
+ ) =>
+ await contractsClient.contractsMerchant.postApiContractServiceMerchantsByIdContractsContractHeaders(
+ data,
+ ),
+ getContractHeaderMissingStepsById: async (id: string) =>
+ await contractsClient.contractsMerchant.getApiContractServiceMerchantsContractsContractHeadersByIdGetMissingSteps(
+ { id },
+ ),
+ getContractHeaderById: async (id: string) =>
+ await contractsClient.contractsMerchant.getApiContractServiceMerchantsContractsContractHeadersById(
+ { id },
+ ),
},
"refund-points": {
getDetail: async (id: string) =>
diff --git a/apps/web/src/language-data/ContractService/resources/en.json b/apps/web/src/language-data/ContractService/resources/en.json
index 2e54aaa4f..ffb33b219 100644
--- a/apps/web/src/language-data/ContractService/resources/en.json
+++ b/apps/web/src/language-data/ContractService/resources/en.json
@@ -12,6 +12,10 @@
"Contracts.Create.Description": "Create a new contract",
"Contracts.Create.Submit": "Save",
+ "Contracts.Edit.Title": "Edit contract",
+ "Contracts.Edit.Description": "Edit selected contract",
+ "Contracts.Edit.Submit": "Save",
+
"Contracts.Create.ContractHeader": "Contract",
"Contracts.Create.RebateSettings": "Rebate settings",
"Contracts.Create.ContractSettings": "Contract settings",
diff --git a/apps/web/src/language-data/ContractService/resources/tr.json b/apps/web/src/language-data/ContractService/resources/tr.json
index a166d16b6..e94102836 100644
--- a/apps/web/src/language-data/ContractService/resources/tr.json
+++ b/apps/web/src/language-data/ContractService/resources/tr.json
@@ -11,6 +11,10 @@
"Contracts.Create.Description": "Yeni bir sözleşme oluşturun",
"Contracts.Create.Submit": "Kaydet",
+ "Contracts.Edit.Title": "Sözleşmeyi düzenle",
+ "Contracts.Edit.Description": "Seçili sözleşmeyi düzenle",
+ "Contracts.Edit.Submit": "Güncelle",
+
"Contracts.Create.ContractHeader": "Sözleşme",
"Contracts.Create.RebateSettings": "İade ayarları",
"Contracts.Create.ContractSettings": "Sözleşme ayarları",