summaryrefslogtreecommitdiff
path: root/pages/api/po/webhook.ts
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api/po/webhook.ts')
-rw-r--r--pages/api/po/webhook.ts33
1 files changed, 13 insertions, 20 deletions
diff --git a/pages/api/po/webhook.ts b/pages/api/po/webhook.ts
index 4a9b6a29..e61246a2 100644
--- a/pages/api/po/webhook.ts
+++ b/pages/api/po/webhook.ts
@@ -3,11 +3,15 @@ export const config = {
bodyParser: true, // ✅ 이게 false면 안 됨!
},
};
+
import type { NextApiRequest, NextApiResponse } from "next";
import path from "path";
import fs from "fs";
import * as z from "zod";
import db from "@/db/db";
+import { GetPOSchema } from "@/lib/po/validations";
+import { unstable_cache } from "@/lib/unstable-cache";
+import { filterColumns } from "@/lib/filter-columns";
import {
asc,
desc,
@@ -21,15 +25,18 @@ import {
eq,
count,
} from "drizzle-orm";
+import { countPos, selectPos } from "@/lib/po/repository";
import {
contractEnvelopes,
+ contractsDetailView,
contractSigners,
contracts,
} from "@/db/schema/contract";
-import {
- downloadContractFile,
- getRecipients,
-} from "@/lib/docuSign/docuSignFns";
+import { vendors, vendorContacts } from "@/db/schema/vendors";
+import dayjs from "dayjs";
+
+import { POContent } from "@/lib/docuSign/types";
+import { downloadContractFile, getRecipients } from "@/lib/docuSign/docuSignFns";
export default async function handler(
req: NextApiRequest,
@@ -45,9 +52,7 @@ export default async function handler(
//recipientId === "1" 첫번째 서명자 서명 완료
//recipientId === "2" 두번쨰 서명자 서명 완료
const { envelopeId, recipientId } = data;
-
- console.log(req.body);
-
+
const contractList = [
{
dbName: "contract_envelopes",
@@ -103,7 +108,7 @@ export default async function handler(
await tx
.update(contracts)
- .set({ status: `FAILED_${safeRole}_SEND_MAIL(${message})` })
+ .set({ status: `$FAILED_${safeRole}_SEND_MAIL(${message})` })
.where(eq(contracts.id, contractId));
await tx
@@ -149,10 +154,6 @@ export default async function handler(
.where(eq(dbSchma.envelopeId, envelopeId))
.limit(1);
- if (!targetContract) {
- continue;
- }
-
const { id, contractId } = targetContract;
if (contractId === null || contractId === undefined) {
@@ -209,10 +210,6 @@ export default async function handler(
.where(eq(dbSchma.envelopeId, envelopeId))
.limit(1);
- if (!targetContract) {
- continue;
- }
-
const { id, contractId, fileName, filePath } = targetContract;
if (contractId === null || contractId === undefined) {
@@ -280,10 +277,6 @@ export default async function handler(
.where(eq(dbSchma.envelopeId, envelopeId))
.limit(1);
- if (!targetContract) {
- continue;
- }
-
const { contractId, fileName, filePath } = targetContract;
if (contractId === null || contractId === undefined) {