-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
836 additions
and
1,701 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
109 changes: 0 additions & 109 deletions
109
apps/web/src/app/[lang]/app/[type]/crm/[data]/(main)/layout.tsx
This file was deleted.
Oops, something went wrong.
115 changes: 115 additions & 0 deletions
115
apps/web/src/app/[lang]/app/[type]/crm/[data]/[id]/action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.