summaryrefslogtreecommitdiff
path: root/components/signup/join-form.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-04-02 09:54:08 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-04-02 09:54:08 +0000
commitdfdfae3018f8499240f48d28ce634f4a5c56e006 (patch)
tree4493b172c061fa5bf4e94c083788110eb1507f6d /components/signup/join-form.tsx
parent21a72eeddc74cf775e2a76e2c569de970bd62a7f (diff)
벤더 코멘트 처리
Diffstat (limited to 'components/signup/join-form.tsx')
-rw-r--r--components/signup/join-form.tsx329
1 files changed, 5 insertions, 324 deletions
diff --git a/components/signup/join-form.tsx b/components/signup/join-form.tsx
index 06aee3b5..6f9ad891 100644
--- a/components/signup/join-form.tsx
+++ b/components/signup/join-form.tsx
@@ -81,35 +81,19 @@ const countryArray = Object.entries(countryMap).map(([code, label]) => ({
label,
}))
-// Example agencies + rating scales
-const creditAgencies = [
- { value: "NICE", label: "NICE평가정보" },
- { value: "KIS", label: "KIS (한국신용평가)" },
- { value: "KED", label: "KED (한국기업데이터)" },
- { value: "SCI", label: "SCI평가정보" },
-]
-const creditRatingScaleMap: Record<string, string[]> = {
- NICE: ["AAA", "AA", "A", "BBB", "BB", "B", "C", "D"],
- KIS: ["AAA", "AA+", "AA", "A+", "A", "BBB+", "BBB", "BB", "B", "C"],
- KED: ["AAA", "AA", "A", "BBB", "BB", "B", "CCC", "CC", "C", "D"],
- SCI: ["AAA", "AA+", "AA", "AA-", "A+", "A", "A-", "BBB+", "BBB-", "B"],
-}
-
const MAX_FILE_SIZE = 3e9
export function JoinForm() {
- const params = useParams()
- const lng = (params.lng as string) || "ko"
+ const params = useParams() || {};
+ const lng = params.lng ? String(params.lng) : "ko";
const { t } = useTranslation(lng, "translation")
const router = useRouter()
- const searchParams = useSearchParams()
+ const searchParams = useSearchParams() || new URLSearchParams();
const defaultTaxId = searchParams.get("taxID") ?? ""
// File states
const [selectedFiles, setSelectedFiles] = React.useState<File[]>([])
- const [creditRatingFile, setCreditRatingFile] = React.useState<File[]>([])
- const [cashFlowRatingFile, setCashFlowRatingFile] = React.useState<File[]>([])
const [isSubmitting, setIsSubmitting] = React.useState(false)
@@ -128,12 +112,7 @@ export function JoinForm() {
representativeEmail: "",
representativePhone: "",
corporateRegistrationNumber: "",
- creditAgency: "",
- creditRating: "",
- cashFlowRating: "",
attachedFiles: undefined,
- creditRatingAttachment: undefined,
- cashFlowRatingAttachment: undefined,
// contacts (no isPrimary)
contacts: [
{
@@ -157,7 +136,7 @@ export function JoinForm() {
name: "contacts",
})
- // Dropzone handlers (same as before)...
+ // Dropzone handlers
const handleDropAccepted = (acceptedFiles: File[]) => {
const newFiles = [...selectedFiles, ...acceptedFiles]
setSelectedFiles(newFiles)
@@ -179,48 +158,6 @@ export function JoinForm() {
form.setValue("attachedFiles", updated, { shouldValidate: true })
}
- const handleCreditDropAccepted = (acceptedFiles: File[]) => {
- const newFiles = [...creditRatingFile, ...acceptedFiles]
- setCreditRatingFile(newFiles)
- form.setValue("creditRatingAttachment", newFiles, { shouldValidate: true })
- }
- const handleCreditDropRejected = (fileRejections: any[]) => {
- fileRejections.forEach((rej) => {
- toast({
- variant: "destructive",
- title: "File Error",
- description: `${rej.file.name}: ${rej.errors[0]?.message || "Upload failed"}`,
- })
- })
- }
- const removeCreditFile = (index: number) => {
- const updated = [...creditRatingFile]
- updated.splice(index, 1)
- setCreditRatingFile(updated)
- form.setValue("creditRatingAttachment", updated, { shouldValidate: true })
- }
-
- const handleCashFlowDropAccepted = (acceptedFiles: File[]) => {
- const newFiles = [...cashFlowRatingFile, ...acceptedFiles]
- setCashFlowRatingFile(newFiles)
- form.setValue("cashFlowRatingAttachment", newFiles, { shouldValidate: true })
- }
- const handleCashFlowDropRejected = (fileRejections: any[]) => {
- fileRejections.forEach((rej) => {
- toast({
- variant: "destructive",
- title: "File Error",
- description: `${rej.file.name}: ${rej.errors[0]?.message || "Upload failed"}`,
- })
- })
- }
- const removeCashFlowFile = (index: number) => {
- const updated = [...cashFlowRatingFile]
- updated.splice(index, 1)
- setCashFlowRatingFile(updated)
- form.setValue("cashFlowRatingAttachment", updated, { shouldValidate: true })
- }
-
// Submit
async function onSubmit(values: CreateVendorSchema) {
setIsSubmitting(true)
@@ -228,12 +165,6 @@ export function JoinForm() {
const mainFiles = values.attachedFiles
? Array.from(values.attachedFiles as FileList)
: []
- const creditRatingFiles = values.creditRatingAttachment
- ? Array.from(values.creditRatingAttachment as FileList)
- : []
- const cashFlowRatingFiles = values.cashFlowRatingAttachment
- ? Array.from(values.cashFlowRatingAttachment as FileList)
- : []
const vendorData = {
vendorName: values.vendorName,
@@ -249,17 +180,12 @@ export function JoinForm() {
representativeBirth: values.representativeBirth || "",
representativeEmail: values.representativeEmail || "",
representativePhone: values.representativePhone || "",
- corporateRegistrationNumber: values.corporateRegistrationNumber || "",
- creditAgency: values.creditAgency || "",
- creditRating: values.creditRating || "",
- cashFlowRating: values.cashFlowRating || "",
+ corporateRegistrationNumber: values.corporateRegistrationNumber || ""
}
const result = await createVendor({
vendorData,
files: mainFiles,
- creditRatingFiles,
- cashFlowRatingFiles,
contacts: values.contacts,
})
@@ -671,251 +597,6 @@ export function JoinForm() {
)}
/>
</div>
-
- <Separator />
-
- {/* 신용/현금 흐름 */}
- <div className="space-y-2">
- <FormField
- control={form.control}
- name="creditAgency"
- render={({ field }) => {
- const agencyValue = field.value
- return (
- <FormItem>
- <FormLabel className="after:content-['*'] after:ml-0.5 after:text-red-500">
- 평가사
- </FormLabel>
- <Select
- onValueChange={field.onChange}
- defaultValue={agencyValue}
- >
- <FormControl>
- <SelectTrigger disabled={isSubmitting}>
- <SelectValue placeholder="평가사 선택" />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {creditAgencies.map((agency) => (
- <SelectItem
- key={agency.value}
- value={agency.value}
- >
- {agency.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormDescription>
- 신용평가 및 현금흐름등급에 사용할 평가사
- </FormDescription>
- <FormMessage />
- </FormItem>
- )
- }}
- />
- {form.watch("creditAgency") && (
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- {/* 신용평가등급 */}
- <FormField
- control={form.control}
- name="creditRating"
- render={({ field }) => {
- const selectedAgency = form.watch("creditAgency")
- const ratingScale =
- creditRatingScaleMap[
- selectedAgency as keyof typeof creditRatingScaleMap
- ] || []
- return (
- <FormItem>
- <FormLabel className="after:content-['*'] after:ml-0.5 after:text-red-500">
- 신용평가등급
- </FormLabel>
- <Select
- onValueChange={field.onChange}
- defaultValue={field.value}
- >
- <FormControl>
- <SelectTrigger disabled={isSubmitting}>
- <SelectValue placeholder="등급 선택" />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {ratingScale.map((r) => (
- <SelectItem key={r} value={r}>
- {r}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormMessage />
- </FormItem>
- )
- }}
- />
- {/* 현금흐름등급 */}
- <FormField
- control={form.control}
- name="cashFlowRating"
- render={({ field }) => {
- const selectedAgency = form.watch("creditAgency")
- const ratingScale =
- creditRatingScaleMap[
- selectedAgency as keyof typeof creditRatingScaleMap
- ] || []
- return (
- <FormItem>
- <FormLabel className="after:content-['*'] after:ml-0.5 after:text-red-500">
- 현금흐름등급
- </FormLabel>
- <Select
- onValueChange={field.onChange}
- defaultValue={field.value}
- >
- <FormControl>
- <SelectTrigger disabled={isSubmitting}>
- <SelectValue placeholder="등급 선택" />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {ratingScale.map((r) => (
- <SelectItem key={r} value={r}>
- {r}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormMessage />
- </FormItem>
- )
- }}
- />
- </div>
- )}
- </div>
-
- {/* Credit/CashFlow Attachments */}
- {form.watch("creditAgency") && (
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- <FormField
- control={form.control}
- name="creditRatingAttachment"
- render={() => (
- <FormItem>
- <FormLabel className="after:content-['*'] after:ml-0.5 after:text-red-500">
- 신용평가등급 첨부</FormLabel>
- <Dropzone
- maxSize={MAX_FILE_SIZE}
- multiple
- onDropAccepted={handleCreditDropAccepted}
- onDropRejected={handleCreditDropRejected}
- disabled={isSubmitting}
- >
- {({ maxSize }) => (
- <DropzoneZone className="flex justify-center">
- <DropzoneInput />
- <div className="flex items-center gap-4">
- <DropzoneUploadIcon />
- <div className="grid gap-1">
- <DropzoneTitle>드래그 또는 클릭</DropzoneTitle>
- <DropzoneDescription>
- 최대: {maxSize ? prettyBytes(maxSize) : "무제한"}
- </DropzoneDescription>
- </div>
- </div>
- </DropzoneZone>
- )}
- </Dropzone>
- {creditRatingFile.length > 0 && (
- <div className="mt-2">
- <ScrollArea className="max-h-32">
- <FileList className="gap-2">
- {creditRatingFile.map((file, i) => (
- <FileListItem key={file.name + i}>
- <FileListHeader>
- <FileListIcon />
- <FileListInfo>
- <FileListName>{file.name}</FileListName>
- <FileListDescription>
- {prettyBytes(file.size)}
- </FileListDescription>
- </FileListInfo>
- <FileListAction
- onClick={() => removeCreditFile(i)}
- >
- <X className="h-4 w-4" />
- </FileListAction>
- </FileListHeader>
- </FileListItem>
- ))}
- </FileList>
- </ScrollArea>
- </div>
- )}
- </FormItem>
- )}
- />
- {/* Cash Flow Attachment */}
- <FormField
- control={form.control}
- name="cashFlowRatingAttachment"
- render={() => (
- <FormItem>
- <FormLabel className="after:content-['*'] after:ml-0.5 after:text-red-500">
- 현금흐름등급 첨부</FormLabel>
- <Dropzone
- maxSize={MAX_FILE_SIZE}
- multiple
- onDropAccepted={handleCashFlowDropAccepted}
- onDropRejected={handleCashFlowDropRejected}
- disabled={isSubmitting}
- >
- {({ maxSize }) => (
- <DropzoneZone className="flex justify-center">
- <DropzoneInput />
- <div className="flex items-center gap-4">
- <DropzoneUploadIcon />
- <div className="grid gap-1">
- <DropzoneTitle>드래그 또는 클릭</DropzoneTitle>
- <DropzoneDescription>
- 최대: {maxSize ? prettyBytes(maxSize) : "무제한"}
- </DropzoneDescription>
- </div>
- </div>
- </DropzoneZone>
- )}
- </Dropzone>
- {cashFlowRatingFile.length > 0 && (
- <div className="mt-2">
- <ScrollArea className="max-h-32">
- <FileList className="gap-2">
- {cashFlowRatingFile.map((file, i) => (
- <FileListItem key={file.name + i}>
- <FileListHeader>
- <FileListIcon />
- <FileListInfo>
- <FileListName>{file.name}</FileListName>
- <FileListDescription>
- {prettyBytes(file.size)}
- </FileListDescription>
- </FileListInfo>
- <FileListAction
- onClick={() => removeCashFlowFile(i)}
- >
- <X className="h-4 w-4" />
- </FileListAction>
- </FileListHeader>
- </FileListItem>
- ))}
- </FileList>
- </ScrollArea>
- </div>
- )}
- </FormItem>
- )}
- />
- </div>
- )}
</div>
)}