Skip to content

Commit

Permalink
feat(Contract):contract settings resources & actions (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
ertugrulcan-ays authored Nov 22, 2024
2 parents ec92c2b + 5488024 commit ded32e0
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Button } from "@/components/ui/button";
import {
getMerchantContractHeaderContractSettingsByHeaderIdApi as getContractSettings,
postMerchantContractHeaderContractSettingsByHeaderIdApi,
putContractHeaderSetDefaultContractSettingByHeaderIdApi,
putMerchantContractContractHeaderSetDefaultContractSettingByHeaderIdApi,
} from "src/app/[lang]/app/actions/ContractService/action";
import type { ContractServiceResource } from "src/language-data/ContractService";
import { MerchantAddressWidget } from "../contract-widgets";
Expand Down Expand Up @@ -57,10 +57,12 @@ export function ContractSettingsSection({
async function setContractSettingDefault(id: string) {
setLoading(true);
const response =
await putContractHeaderSetDefaultContractSettingByHeaderIdApi({
id: contractHeaderDetails.id,
requestBody: { contractSettingId: id },
});
await putMerchantContractContractHeaderSetDefaultContractSettingByHeaderIdApi(
{
id: contractHeaderDetails.id,
requestBody: { contractSettingId: id },
},
);
if (response.type === "success") {
toast.success(response.message);
void handleFetch();
Expand Down
27 changes: 26 additions & 1 deletion apps/web/src/app/[lang]/app/actions/ContractService/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
PostApiContractServiceMerchantsByIdContractsContractHeadersData,
PostApiContractServiceMerchantsContractsContractHeadersByIdContractSettingsData,
PutApiContractServiceMerchantsContractsContractHeadersByIdSetDefaultSettingData,
PutApiContractServiceMerchantsContractsContractSettingsByIdData,
} from "@ayasofyazilim/saas/ContractService";
import { structuredError, structuredResponse } from "src/lib";
import { getApiRequests } from "../api-requests";
Expand Down Expand Up @@ -92,7 +93,31 @@ export async function postMerchantContractHeaderContractSettingsByHeaderIdApi(
return structuredError(error);
}
}
export async function putContractHeaderSetDefaultContractSettingByHeaderIdApi(
export async function putMerchantContractContractSettingsByIdApi(
data: PutApiContractServiceMerchantsContractsContractSettingsByIdData,
) {
try {
const requests = await getApiRequests();
return structuredResponse(
await requests.merchants.putContractSettingsById(data),
);
} catch (error) {
return structuredError(error);
}
}
export async function deleteMerchantContractContractSettingsByIdApi(
id: string,
) {
try {
const requests = await getApiRequests();
return structuredResponse(
await requests.merchants.deleteContractSettingsById(id),
);
} catch (error) {
return structuredError(error);
}
}
export async function putMerchantContractContractHeaderSetDefaultContractSettingByHeaderIdApi(
data: PutApiContractServiceMerchantsContractsContractHeadersByIdSetDefaultSettingData,
) {
try {
Expand Down
11 changes: 11 additions & 0 deletions apps/web/src/app/[lang]/app/actions/api-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
PostApiContractServiceMerchantsByIdContractsContractHeadersData,
PostApiContractServiceMerchantsContractsContractHeadersByIdContractSettingsData,
PutApiContractServiceMerchantsContractsContractHeadersByIdSetDefaultSettingData,
PutApiContractServiceMerchantsContractsContractSettingsByIdData,
} from "@ayasofyazilim/saas/ContractService";
import type {
GetApiCrmServiceCustomsData,
Expand Down Expand Up @@ -193,6 +194,16 @@ export async function getApiRequests() {
await contractsClient.contractsMerchant.getApiContractServiceMerchantsContractsContractHeadersById(
{ id },
),
putContractSettingsById: async (
data: PutApiContractServiceMerchantsContractsContractSettingsByIdData,
) =>
await contractsClient.contractsMerchant.putApiContractServiceMerchantsContractsContractSettingsById(
data,
),
deleteContractSettingsById: async (id: string) =>
await contractsClient.contractsMerchant.deleteApiContractServiceMerchantsContractsContractSettingsById(
{ id },
),
getContractHeaderContractSettingsByHeaderId: async (
data: GetApiContractServiceMerchantsContractsContractHeadersByIdContractSettingsData,
) =>
Expand Down
12 changes: 12 additions & 0 deletions apps/web/src/language-data/ContractService/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"Contracts.Form.refundTableHeaders.validFrom": "Begin Date",
"Contracts.Form.refundTableHeaders.validTo": "End Date",

"Contracts.Settings.Form.Delete": "Delete",
"Contracts.Settings.Form.Delete.Title": "Delete contract setting",
"Contracts.Settings.Form.Delete.Description": "Are you sure you want to delete this setting?",
"Contracts.Settings.Form.name": "Setting name",
"Contracts.Settings.Form.referenceNumber": "Reference number",
"Contracts.Settings.Form.termOfPayment": "Payment term",
Expand Down Expand Up @@ -112,6 +115,15 @@
"Contracts.Settings.Form.factoring": "Factoring",
"Contracts.Settings.Form.setIsDefault": "Set as Default",

"Contracts.Settings.SetIsDefault.Success": "Contract setting successfully set.",
"Contracts.Settings.SetIsDefault.Fail": "Contract setting could not be set as default.",
"Contracts.Settings.Delete.Success": "Contract setting deleted successfully.",
"Contracts.Settings.Delete.Fail": "Error while deleting contract setting.",
"Contracts.Settings.Create.Success": "Contract setting created successfully.",
"Contracts.Settings.Create.Fail": "Error while creating contract setting.",
"Contracts.Settings.Edit.Success": "Contract setting saved successfully.",
"Contracts.Settings.Edit.Fail": "Error while saving contract setting.",

"RefundTables.Title": "Refund tables",
"RefundTables.Description": "Manage refund tables",

Expand Down
12 changes: 12 additions & 0 deletions apps/web/src/language-data/ContractService/resources/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"Contracts.Form.refundTableHeaders.validFrom": "Başlangıç Tarihi",
"Contracts.Form.refundTableHeaders.validTo": "Bitiş Tarihi",

"Contracts.Settings.Form.Delete": "Sil",
"Contracts.Settings.Form.Delete.Description": "Bu kontrat ayarını silmek istediğinize emin misiniz?",
"Contracts.Settings.Form.Delete.Title": "Kontrat ayarını sil",
"Contracts.Settings.Form.name": "Ayar adı",
"Contracts.Settings.Form.referenceNumber": "Referans numarası",
"Contracts.Settings.Form.termOfPayment": "Ödeme sıklığı",
Expand Down Expand Up @@ -112,6 +115,15 @@
"Contracts.Settings.Form.factoring": "Faktoring",
"Contracts.Settings.Form.setIsDefault": "Varsayılan olarak ayarla",

"Contracts.Settings.SetIsDefault.Success": "Sözleşme ayarı başarıyla varsayılan olarak ayarlandı.",
"Contracts.Settings.SetIsDefault.Fail": "Sözleşme ayarı varsayılan olarak ayarlanamadı.",
"Contracts.Settings.Delete.Success": "Sözleşme ayarı başarıyla silindi.",
"Contracts.Settings.Delete.Fail": "Sözleşme ayarı silinirken bir hata oluştu.",
"Contracts.Settings.Create.Success": "Sözleşme ayarı başarıyla oluşturuldu.",
"Contracts.Settings.Create.Fail": "Sözleşme ayarı oluşturulurken bir hata oluştu.",
"Contracts.Settings.Edit.Success": "Sözleşme ayarı başarıyla kaydedildi.",
"Contracts.Settings.Edit.Fail": "Sözleşme ayarı kaydedilirken bir hata oluştu.",

"RefundTables.Title": "İade Tabloları",
"RefundTables.Description": "İade tablolarını yönetin",

Expand Down

0 comments on commit ded32e0

Please sign in to comment.