@@ -23,12 +23,14 @@ import { Badge, Button, Divider, Form, Input, NativeSelect, Typography } from "t
2323import AuthLayout from "~/components/AuthLayout" ;
2424import authService from "~/services/authService" ;
2525import cityService from "~/services/cityService" ;
26+ import fileService from "~/services/fileService" ;
2627
2728import RegisterScan from "./RegisterScan" ;
2829
2930const Register = ( ) => {
3031 const [ ocrVisible , setOrcVisible ] = useState ( false ) ;
3132 const [ cities , setCities ] = useState ( [ ] ) ;
33+ const [ success , setSuccess ] = useState ( false ) ;
3234
3335 const formik = useFormik ( {
3436 initialValues : {
@@ -43,8 +45,14 @@ const Register = () => {
4345 try {
4446 const res = await authService . register ( values ) ;
4547
46- console . log ( res . data ) ;
47- } catch ( error ) { }
48+ const key = res . data . keyUrl . split ( / [ . / ] / ) [ 2 ] ;
49+
50+ fileService . downloadFileByKey ( key ) ;
51+
52+ setSuccess ( true ) ;
53+ } catch ( error ) {
54+ } finally {
55+ }
4856 } ,
4957 } ) ;
5058
@@ -71,86 +79,99 @@ const Register = () => {
7179 Đăng ký
7280 </ Typography . Heading >
7381
74- < form onSubmit = { formik . handleSubmit } >
75- < Divider > Nhập thông tin</ Divider >
76- < Form . Item label = "Số CCCD" required >
77- < Input
78- placeholder = "Số CCCD"
79- name = "cccd"
80- required
81- maxLength = { 12 }
82- minLength = { 12 }
83- onInput = { formik . handleChange }
84- />
85- </ Form . Item >
86-
87- < Form . Item label = "Họ tên" required >
88- < Input
89- placeholder = "Họ tên"
90- name = "name"
91- required
92- onInput = { formik . handleChange }
93- />
94- </ Form . Item >
95-
96- < Form . Item label = "Ngày sinh" required >
97- < Input
98- placeholder = "Ngày sinh"
99- name = "birthday"
100- type = "date"
101- required
102- onInput = { formik . handleChange }
103- />
104- </ Form . Item >
105-
106- < Form . Item label = "Giới tính" required >
107- < NativeSelect
108- name = "sex"
109- placeholder = "Giới tính"
110- onInput = { formik . handleChange }
111- required
112- >
113- < NativeSelect . Option value = { 1 } > Nam</ NativeSelect . Option >
114- < NativeSelect . Option value = { 2 } > Nữ</ NativeSelect . Option >
115- </ NativeSelect >
116- </ Form . Item >
117-
118- < Form . Item label = "Quê quán" required >
119- < NativeSelect
120- disabled = { ! cities . length }
121- name = "place"
122- placeholder = "Quê quán"
123- required
124- onInput = { formik . handleChange }
125- >
126- { cities . map ( ( city ) => (
127- < NativeSelect . Option key = { city . code } value = { city . code } >
128- { city . code } - { city . name_with_type }
129- </ NativeSelect . Option >
130- ) ) }
131- </ NativeSelect >
132- </ Form . Item >
133-
134- < Divider > Hoặc</ Divider >
135-
136- < Badge style = { { width : "100%" } } count = "Đang phát triển" >
137- < Button disabled block btnType = "outline" onClick = { ( ) => setOrcVisible ( true ) } >
138- Tải ảnh căn cước công dân
139- </ Button >
140- </ Badge >
141-
142- < Divider />
143-
144- < Button btnType = "primary" block type = "submit" >
145- Đăng ký
146- </ Button >
147- </ form >
148-
149- < RegisterScan visible = { ocrVisible } onCancel = { ( ) => setOrcVisible ( false ) } />
150-
151- < Typography . Paragraph style = { { marginTop : 10 } } >
152- Đã có tài khoản? < Link to = "/login" > Đăng nhập ngay</ Link >
153- </ Typography . Paragraph >
82+ { success ? (
83+ < >
84+ < Typography . Paragraph > Bạn đã tạo tài khoản thành công!</ Typography . Paragraph >
85+ </ >
86+ ) : (
87+ < >
88+ < form onSubmit = { formik . handleSubmit } >
89+ < Divider > Nhập thông tin</ Divider >
90+ < Form . Item label = "Số CCCD" required >
91+ < Input
92+ placeholder = "Số CCCD"
93+ name = "cccd"
94+ required
95+ maxLength = { 12 }
96+ minLength = { 12 }
97+ onInput = { formik . handleChange }
98+ />
99+ </ Form . Item >
100+
101+ < Form . Item label = "Họ tên" required >
102+ < Input
103+ placeholder = "Họ tên"
104+ name = "name"
105+ required
106+ onInput = { formik . handleChange }
107+ />
108+ </ Form . Item >
109+
110+ < Form . Item label = "Ngày sinh" required >
111+ < Input
112+ placeholder = "Ngày sinh"
113+ name = "birthday"
114+ type = "date"
115+ required
116+ onInput = { formik . handleChange }
117+ />
118+ </ Form . Item >
119+
120+ < Form . Item label = "Giới tính" required >
121+ < NativeSelect
122+ name = "sex"
123+ placeholder = "Giới tính"
124+ onInput = { formik . handleChange }
125+ required
126+ >
127+ < NativeSelect . Option value = { 1 } > Nam</ NativeSelect . Option >
128+ < NativeSelect . Option value = { 2 } > Nữ</ NativeSelect . Option >
129+ </ NativeSelect >
130+ </ Form . Item >
131+
132+ < Form . Item label = "Quê quán" required >
133+ < NativeSelect
134+ disabled = { ! cities . length }
135+ name = "place"
136+ placeholder = "Quê quán"
137+ required
138+ onInput = { formik . handleChange }
139+ >
140+ { cities . map ( ( city ) => (
141+ < NativeSelect . Option key = { city . code } value = { city . code } >
142+ { city . code } - { city . name_with_type }
143+ </ NativeSelect . Option >
144+ ) ) }
145+ </ NativeSelect >
146+ </ Form . Item >
147+
148+ < Divider > Hoặc</ Divider >
149+
150+ < Badge style = { { width : "100%" } } count = "Đang phát triển" >
151+ < Button
152+ disabled
153+ block
154+ btnType = "outline"
155+ onClick = { ( ) => setOrcVisible ( true ) }
156+ >
157+ Tải ảnh căn cước công dân
158+ </ Button >
159+ </ Badge >
160+
161+ < Divider />
162+
163+ < Button btnType = "primary" block type = "submit" >
164+ Đăng ký
165+ </ Button >
166+ </ form >
167+
168+ < RegisterScan visible = { ocrVisible } onCancel = { ( ) => setOrcVisible ( false ) } />
169+
170+ < Typography . Paragraph style = { { marginTop : 10 } } >
171+ Đã có tài khoản? < Link to = "/login" > Đăng nhập ngay</ Link >
172+ </ Typography . Paragraph >
173+ </ >
174+ ) }
154175 </ AuthLayout >
155176 ) ;
156177} ;
0 commit comments