summaryrefslogtreecommitdiff
path: root/lib/gtc-contract/gtc-clauses/validations.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gtc-contract/gtc-clauses/validations.ts')
-rw-r--r--lib/gtc-contract/gtc-clauses/validations.ts98
1 files changed, 90 insertions, 8 deletions
diff --git a/lib/gtc-contract/gtc-clauses/validations.ts b/lib/gtc-contract/gtc-clauses/validations.ts
index edbcf612..f60255ba 100644
--- a/lib/gtc-contract/gtc-clauses/validations.ts
+++ b/lib/gtc-contract/gtc-clauses/validations.ts
@@ -1,4 +1,4 @@
-import { type GtcClause } from "@/db/schema/gtc"
+import { GtcClauseTreeView, GtcClauseWithVendorView, GtcVendorClauseView, type GtcClause } from "@/db/schema/gtc"
import {
createSearchParamsCache,
parseAsArrayOf,
@@ -15,13 +15,24 @@ export const searchParamsCache = createSearchParamsCache({
),
page: parseAsInteger.withDefault(1),
perPage: parseAsInteger.withDefault(20),
- sort: getSortingStateParser<GtcClause>().withDefault([
- { id: "sortOrder", desc: false },
+ sort: getSortingStateParser<GtcClauseTreeView>().withDefault([
+ { id: "itemNumber", desc: false },
+ ]),
+ // advanced filter
+ filters: getFiltersStateParser().withDefault([]),
+ joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
+ search: parseAsString.withDefault(""),
+})
+
+export const searchParamsVendorCache = createSearchParamsCache({
+ flags: parseAsArrayOf(z.enum(["advancedTable", "floatingBar"])).withDefault(
+ []
+ ),
+ page: parseAsInteger.withDefault(1),
+ perPage: parseAsInteger.withDefault(20),
+ sort: getSortingStateParser<GtcClauseWithVendorView>().withDefault([
+ { id: "effectiveItemNumber", desc: false },
]),
- // 검색 필터들
- category: parseAsString.withDefault(""),
- depth: parseAsInteger.withDefault(0),
- parentId: parseAsInteger.withDefault(0),
// advanced filter
filters: getFiltersStateParser().withDefault([]),
joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
@@ -117,8 +128,79 @@ export const generateVariableNamesSchema = z.object({
})
export type GetGtcClausesSchema = Awaited<ReturnType<typeof searchParamsCache.parse>>
+export type GetGtcVendorClausesSchema = Awaited<ReturnType<typeof searchParamsVendorCache.parse>>
export type CreateGtcClauseSchema = z.infer<typeof createGtcClauseSchema>
export type UpdateGtcClauseSchema = z.infer<typeof updateGtcClauseSchema>
export type ReorderGtcClausesSchema = z.infer<typeof reorderGtcClausesSchema>
export type BulkUpdateGtcClausesSchema = z.infer<typeof bulkUpdateGtcClausesSchema>
-export type GenerateVariableNamesSchema = z.infer<typeof generateVariableNamesSchema> \ No newline at end of file
+export type GenerateVariableNamesSchema = z.infer<typeof generateVariableNamesSchema>
+
+
+// validations.ts에 추가
+export const updateVendorGtcClauseSchema = z.object({
+ modifiedItemNumber: z.string().optional(),
+ modifiedCategory: z.string().optional(),
+ modifiedSubtitle: z.string().optional(),
+ modifiedContent: z.string().optional(),
+
+ isNumberModified: z.boolean().default(false),
+ isCategoryModified: z.boolean().default(false),
+ isSubtitleModified: z.boolean().default(false),
+ isContentModified: z.boolean().default(false),
+
+ reviewStatus: z.enum([
+ "draft",
+ "pending",
+ "reviewing",
+ "approved",
+ "rejected",
+ "revised"
+ ]).default("draft"),
+
+ negotiationNote: z.string().optional(),
+ isExcluded: z.boolean().default(false),
+})
+
+export type UpdateVendorGtcClauseSchema = z.infer<typeof updateVendorGtcClauseSchema>
+
+// validations.ts
+export const createVendorGtcClauseSchema = z.object({
+ vendorDocumentId: z.number({
+ required_error: "벤더 문서 ID는 필수입니다.",
+ }),
+ baseClauseId: z.number({
+ required_error: "기본 조항 ID는 필수입니다.",
+ }),
+ documentId: z.number({
+ required_error: "문서 ID는 필수입니다.",
+ }),
+ parentId: z.number().nullable().optional(),
+ modifiedItemNumber: z.string().optional().nullable(),
+ modifiedCategory: z.string().optional().nullable(),
+ modifiedSubtitle: z.string().optional().nullable(),
+ modifiedContent: z.string().optional().nullable(),
+ sortOrder: z.number().default(0),
+ reviewStatus: z.enum(["draft", "pending", "reviewing", "approved", "rejected", "revised"]).default("draft"),
+ negotiationNote: z.string().optional().nullable(),
+ isExcluded: z.boolean().default(false),
+ isNumberModified: z.boolean().default(false),
+ isCategoryModified: z.boolean().default(false),
+ isSubtitleModified: z.boolean().default(false),
+ isContentModified: z.boolean().default(false),
+ editReason: z.string().optional().nullable(),
+ images: z.array(
+ z.object({
+ id: z.string(),
+ url: z.string(),
+ fileName: z.string(),
+ size: z.number(),
+ savedName: z.string().optional(),
+ mimeType: z.string().optional(),
+ width: z.number().optional(),
+ height: z.number().optional(),
+ hash: z.string().optional(),
+ })
+ ).optional().nullable(),
+})
+
+export type CreateVendorGtcClauseSchema = z.infer<typeof createVendorGtcClauseSchema> \ No newline at end of file