|
1 | | -import { useState } from "react"; |
| 1 | +import { type ChangeEvent, useState } from "react"; |
2 | 2 |
|
3 | | -import { |
4 | | - Box, |
5 | | - FormControl, |
6 | | - InputLabel, |
7 | | - MenuItem, |
8 | | - Select, |
9 | | - TextField, |
10 | | - Typography, |
11 | | -} from "@mui/material"; |
12 | | -import type { SelectChangeEvent } from "@mui/material"; |
13 | 3 | import type { StepProps } from "~/app/signup/common"; |
14 | 4 | import { facultiesAndDepartments } from "~/app/signup/data"; |
15 | 5 | import { parseStep1UserSchema } from "~/common/zod/methods"; |
16 | 6 | import type { Step1User } from "~/common/zod/types"; |
17 | 7 |
|
| 8 | +function Label({ children }: { children: string }) { |
| 9 | + return <span className="text-gray-500 text-sm">{children}</span>; |
| 10 | +} |
| 11 | + |
| 12 | +const faculties = Object.keys(facultiesAndDepartments); |
18 | 13 | export default function Step1({ onSave, prev, caller }: StepProps<Step1User>) { |
19 | 14 | const [name, setName] = useState(prev?.name ?? ""); |
20 | 15 | const [gender, setGender] = useState(prev?.gender ?? "その他"); |
@@ -59,114 +54,94 @@ export default function Step1({ onSave, prev, caller }: StepProps<Step1User>) { |
59 | 54 | } |
60 | 55 | } |
61 | 56 |
|
62 | | - const handleFacultyChange = (event: SelectChangeEvent<string>) => { |
| 57 | + const handleFacultyChange = (event: ChangeEvent<HTMLSelectElement>) => { |
63 | 58 | setFaculty(event.target.value); |
64 | 59 | }; |
65 | 60 |
|
66 | | - const handleDepartmentChange = (event: SelectChangeEvent<string>) => { |
| 61 | + const handleDepartmentChange = (event: ChangeEvent<HTMLSelectElement>) => { |
67 | 62 | setDepartment(event.target.value); |
68 | 63 | }; |
69 | 64 |
|
70 | 65 | return ( |
71 | 66 | <> |
72 | | - <Box mt={2} mx={2} display="flex" flexDirection="column" gap={2}> |
73 | | - <Typography variant="h6" component="h1"> |
74 | | - アカウント設定 |
75 | | - </Typography> |
76 | | - <Box flex={1} display="flex" flexDirection="column" gap={2}> |
77 | | - <FormControl fullWidth> |
78 | | - <TextField |
79 | | - value={name} |
80 | | - onChange={(e) => setName(e.target.value)} |
81 | | - label="名前" |
82 | | - autoComplete="off" |
83 | | - /> |
84 | | - </FormControl> |
85 | | - <FormControl fullWidth> |
86 | | - <InputLabel>性別</InputLabel> |
87 | | - <Select |
88 | | - value={gender} |
89 | | - label="性別" |
90 | | - onChange={(e) => setGender(e.target.value)} |
91 | | - > |
92 | | - <MenuItem value={"男性"}>男性</MenuItem> |
93 | | - <MenuItem value={"女性"}>女性</MenuItem> |
94 | | - <MenuItem value={"その他"}>その他</MenuItem> |
95 | | - <MenuItem value={"秘密"}>秘密</MenuItem> |
96 | | - </Select> |
97 | | - </FormControl> |
98 | | - <FormControl fullWidth> |
99 | | - <InputLabel>学年</InputLabel> |
100 | | - <Select |
101 | | - value={grade} |
102 | | - label="学年" |
103 | | - onChange={(e) => setGrade(e.target.value)} |
104 | | - > |
105 | | - <MenuItem value={"B1"}>1年生 (B1)</MenuItem> |
106 | | - <MenuItem value={"B2"}>2年生 (B2)</MenuItem> |
107 | | - <MenuItem value={"B3"}>3年生 (B3)</MenuItem> |
108 | | - <MenuItem value={"B4"}>4年生 (B4)</MenuItem> |
109 | | - <MenuItem value={"M1"}>修士1年 (M1)</MenuItem> |
110 | | - <MenuItem value={"M2"}>修士2年 (M2)</MenuItem> |
111 | | - </Select> |
112 | | - </FormControl> |
113 | | - <FormControl fullWidth> |
114 | | - <InputLabel>学部</InputLabel> |
115 | | - <Select value={faculty} label="学部" onChange={handleFacultyChange}> |
116 | | - {Object.keys(facultiesAndDepartments).map((fac) => ( |
117 | | - <MenuItem key={fac} value={fac}> |
118 | | - {fac} |
119 | | - </MenuItem> |
| 67 | + <div className="m-4 mb-8 flex flex-col gap-4 "> |
| 68 | + <h1 className="text-xl">アカウント設定</h1> |
| 69 | + <div className="flex flex-col gap-2"> |
| 70 | + <Label>名前</Label> |
| 71 | + <input |
| 72 | + className="input input-bordered w-full" |
| 73 | + value={name} |
| 74 | + onChange={(e) => setName(e.target.value)} |
| 75 | + autoComplete="off" |
| 76 | + /> |
| 77 | + <Label>性別</Label> |
| 78 | + <select |
| 79 | + className="select select-bordered w-full" |
| 80 | + value={gender} |
| 81 | + onChange={(e) => setGender(e.target.value)} |
| 82 | + > |
| 83 | + <option value={"男性"}>男性</option> |
| 84 | + <option value={"女性"}>女性</option> |
| 85 | + <option value={"その他"}>その他</option> |
| 86 | + <option value={"秘密"}>秘密</option> |
| 87 | + </select> |
| 88 | + <Label>学年</Label> |
| 89 | + <select |
| 90 | + className="select select-bordered w-full" |
| 91 | + value={grade} |
| 92 | + onChange={(e) => setGrade(e.target.value)} |
| 93 | + > |
| 94 | + <option value={"B1"}>1年生 (B1)</option> |
| 95 | + <option value={"B2"}>2年生 (B2)</option> |
| 96 | + <option value={"B3"}>3年生 (B3)</option> |
| 97 | + <option value={"B4"}>4年生 (B4)</option> |
| 98 | + <option value={"M1"}>修士1年 (M1)</option> |
| 99 | + <option value={"M2"}>修士2年 (M2)</option> |
| 100 | + </select> |
| 101 | + <Label>学部</Label> |
| 102 | + <select |
| 103 | + className="select select-bordered w-full" |
| 104 | + value={faculty} |
| 105 | + onChange={handleFacultyChange} |
| 106 | + > |
| 107 | + {faculties.map((fac) => ( |
| 108 | + <option key={fac} value={fac}> |
| 109 | + {fac} |
| 110 | + </option> |
| 111 | + ))} |
| 112 | + </select> |
| 113 | + <Label>学科 (先に学部を選択して下さい)</Label> |
| 114 | + <select |
| 115 | + className="select select-bordered w-full" |
| 116 | + value={department} |
| 117 | + onChange={handleDepartmentChange} |
| 118 | + disabled={!faculty} |
| 119 | + > |
| 120 | + {faculty && |
| 121 | + facultiesAndDepartments[faculty].map((dep) => ( |
| 122 | + <option key={dep} value={dep}> |
| 123 | + {dep} |
| 124 | + </option> |
120 | 125 | ))} |
121 | | - </Select> |
122 | | - </FormControl> |
123 | | - <FormControl fullWidth> |
124 | | - <InputLabel>学科 (先に学部を選択して下さい)</InputLabel> |
125 | | - <Select |
126 | | - value={department} |
127 | | - onChange={handleDepartmentChange} |
128 | | - disabled={!faculty} |
129 | | - label="学科(先に学部を選択して下さい)" |
130 | | - > |
131 | | - {faculty && |
132 | | - facultiesAndDepartments[faculty].map((dep) => ( |
133 | | - <MenuItem key={dep} value={dep}> |
134 | | - {dep} |
135 | | - </MenuItem> |
136 | | - ))} |
137 | | - </Select> |
138 | | - </FormControl> |
139 | | - <FormControl fullWidth> |
140 | | - <TextField |
141 | | - multiline |
142 | | - label="自己紹介" |
143 | | - minRows={3} |
144 | | - placeholder="こんにちは!仲良くして下さい!" |
145 | | - onChange={(e) => setIntro(e.target.value)} |
146 | | - /> |
147 | | - </FormControl> |
| 126 | + </select> |
| 127 | + <Label>自己紹介</Label> |
| 128 | + <textarea |
| 129 | + className="textarea textarea-bordered w-full" |
| 130 | + rows={5} |
| 131 | + placeholder="こんにちは!仲良くして下さい!" |
| 132 | + onChange={(e) => setIntro(e.target.value)} |
| 133 | + /> |
148 | 134 | {errorMessage && ( |
149 | | - <Box color="red" mb={2}> |
150 | | - {errorMessage} |
151 | | - </Box> |
| 135 | + <div className="mb-4 text-error">{errorMessage}</div> |
152 | 136 | )} |
153 | | - </Box> |
154 | | - </Box> |
155 | | - <Box |
156 | | - p={3} |
157 | | - sx={{ |
158 | | - position: "fixed", |
159 | | - display: "flex", |
160 | | - justifyContent: "space-between", |
161 | | - bottom: 0, |
162 | | - width: "100%", |
163 | | - }} |
164 | | - > |
| 137 | + </div> |
| 138 | + </div> |
| 139 | + <div className="fixed bottom-5 flex w-full justify-between p-6"> |
165 | 140 | <span /> |
166 | 141 | <button type="button" onClick={save} className="btn btn-primary"> |
167 | 142 | {caller === "registration" ? "次へ" : "保存"} |
168 | 143 | </button> |
169 | | - </Box> |
| 144 | + </div> |
170 | 145 | </> |
171 | 146 | ); |
172 | 147 | } |
0 commit comments