summaryrefslogtreecommitdiff
path: root/components/documents/RevisionForm.tsx
blob: 9eea04c530f95a853e48506c55b1b17127cffac7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"use client"

import React, { useState } from "react"

// shadcn/ui Components
import { Label } from "@/components/ui/label"
import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"
import { Separator } from "@/components/ui/separator"

type RevisionFormProps = {
  document: any
}

export default function RevisionForm({ document }: RevisionFormProps) {
  const [stage, setStage] = useState("")
  const [revision, setRevision] = useState("")
  const [planDate, setPlanDate] = useState("")
  const [actualDate, setActualDate] = useState("")
  const [file, setFile] = useState<File | null>(null)

  const handleSubmit = async (e: React.FormEvent) => {
    e.preventDefault()
    if (!document?.id) return
    // server action 호출 예시
    // await createDocumentVersion({
    //   documentId: document.id,
    //   stage,
    //   revision,
    //   planDate,
    //   actualDate,
    //   file,
    // });
    alert("리비전이 등록되었습니다.")
    // 이후 상태 초기화나 revalidation 등 필요에 따라 처리
  }

  return (
    <div className="p-3">
      <h2 className="text-lg font-semibold">리비전 등록</h2>
      <Separator className="my-2" />

      <form onSubmit={handleSubmit} className="space-y-4">
        {/* Stage */}
        <div>
          <Label htmlFor="stage" className="mb-1">
            Stage
          </Label>
          <Input
            id="stage"
            type="text"
            value={stage}
            onChange={(e) => setStage(e.target.value)}
          />
        </div>

        {/* Revision */}
        <div>
          <Label htmlFor="revision" className="mb-1">
            Revision
          </Label>
          <Input
            id="revision"
            type="text"
            value={revision}
            onChange={(e) => setRevision(e.target.value)}
          />
        </div>

        {/* 계획일 */}
        <div>
          <Label htmlFor="planDate" className="mb-1">
            계획일
          </Label>
          <Input
            id="planDate"
            type="date"
            value={planDate}
            onChange={(e) => setPlanDate(e.target.value)}
          />
        </div>

        {/* 실제일 */}
        <div>
          <Label htmlFor="actualDate" className="mb-1">
            실제일
          </Label>
          <Input
            id="actualDate"
            type="date"
            value={actualDate}
            onChange={(e) => setActualDate(e.target.value)}
          />
        </div>

        {/* 파일 업로드 */}
        <div>
          <Label htmlFor="file" className="mb-1">
            파일 업로드
          </Label>
          <Input
            id="file"
            type="file"
            onChange={(e) => setFile(e.target.files?.[0] ?? null)}
          />
        </div>

        {/* 제출 버튼 */}
        <Button type="submit" variant="default">
          등록하기
        </Button>
      </form>
    </div>
  )
}