Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2021
Kelas D
Justika - Pengembangan Platform untuk UMKM
Justika UMKM Legal - Frontend
Commits
1378d845
Commit
1378d845
authored
Apr 26, 2021
by
Lia Yuliana
Browse files
[GREEN] connect formiumk to backend
parent
6df1ec8a
Pipeline
#72907
passed with stages
in 12 minutes and 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/pages/formiumk.js
View file @
1378d845
...
...
@@ -5,9 +5,14 @@ import FormIUMK2 from '../components/FormIUMK/FormIUMK2'
import
FormIUMK3
from
'
../components/FormIUMK/FormIUMK3
'
import
Stepper
from
'
../components/Stepper/Stepper
'
import
{
useSelector
}
from
'
react-redux
'
import
{
getEmail
,
isLoggedIn
}
from
'
../store/auth/authSlice
'
import
{
getEmail
,
isLoggedIn
,
getToken
}
from
'
../store/auth/authSlice
'
import
{
useState
}
from
'
react
'
import
{
useForm
}
from
'
react-hook-form
'
import
axios
from
'
axios
'
import
BASE_URL
from
'
../api/config
'
import
{
navigate
}
from
'
@reach/router
'
import
toast
,
{
Toaster
}
from
'
react-hot-toast
'
const
FormIUMK
=
()
=>
{
const
{
register
,
handleSubmit
,
errors
,
setValue
}
=
useForm
({
...
...
@@ -16,6 +21,7 @@ const FormIUMK = () => {
})
const
name
=
useSelector
(
getEmail
)
const
loggedIn
=
useSelector
(
isLoggedIn
)
const
token
=
useSelector
(
getToken
)
const
[
pageNumber
,
setPageNumber
]
=
useState
(
1
)
const
[
data
,
setData
]
=
useState
({})
const
[
employeeData
,
setEmployeeData
]
=
useState
(
null
)
...
...
@@ -28,6 +34,43 @@ const FormIUMK = () => {
}
else
{
setData
({...
data
,
...
input
,
...{
karyawan
:
employeeData
}})
}
}
else
{
axios
.
post
(
`
${
BASE_URL
.
API_BASE_URL
}
/api/v1/iumk/`
,
{
nama_usaha
:
data
.
nama
,
alamat
:
data
.
alamat
,
barang_jasa
:
data
.
barangJasa
,
status_entitas
:
data
.
status
,
jumlah_karyawan
:
data
.
karyawan
,
kode_kbli
:
data
.
kbli
,
catatan
:
data
.
catatan
,
},
{
headers
:
{
Authorization
:
`Token
${
token
}
`
,
},
},
)
.
then
(()
=>
{
navigate
(
'
/
'
,
{
state
:
{
message
:
'
Pengajuan Izin UMK berhasil terkirim
'
,
showToast
:
true
,
},
replace
:
false
,
})
})
.
catch
((
error
)
=>
{
if
(
error
.
response
.
data
.
non_field_errors
)
{
toast
.
error
(
<
span
data
-
testid
=
"
toast-error
"
>
{
error
.
response
.
data
.
non_field_errors
}
<
/span>
,
)
}
})
}
}
...
...
@@ -68,9 +111,16 @@ const FormIUMK = () => {
/
>
)}
{
pageNumber
==
3
&&
<
FormIUMK3
data
=
{
data
}
/>
}
{
pageNumber
==
3
&&
(
<
FormIUMK3
data
=
{
data
}
onSubmit
=
{
onSubmit
}
handleSubmit
=
{
handleSubmit
}
/
>
)}
<
/div
>
<
/div
>
<
Toaster
/>
<
/div
>
)
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment