Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
PPL Sosial
pilar
pilar-web
Commits
46d8845f
Commit
46d8845f
authored
Jun 07, 2021
by
Fadhil Pradipta Widyanto
Browse files
Merge branch 'coldfix' into 'dev'
COLDFIX See merge request
!40
parents
930e8d38
c65216fe
Pipeline
#82077
passed with stages
in 2 minutes and 54 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/page/produk/EditProduk.jsx
View file @
46d8845f
...
...
@@ -15,9 +15,9 @@ const EditProduk = ({ productId }) => {
const
onSubmit
=
(
data
)
=>
{
send
(
data
);
};
return
(
<
Fragment
>
{
errorState
||
Object
.
keys
(
initialData
.
length
===
0
)
?
(
<
div
if
(
errorState
||
Object
.
keys
(
initialData
).
length
===
0
)
{
return
(
<
div
data
-
testid
=
"waiting-edit-produk"
css
=
{
css
`
display: flex;
...
...
@@ -27,7 +27,12 @@ const EditProduk = ({ productId }) => {
`
}
>
Fetching data..
</
div
>)
:
(<
div
</
div
>
)
}
return
(
<
Fragment
>
<
div
data
-
testid
=
"edit-produk"
css
=
{
css
`
display: flex;
...
...
@@ -81,7 +86,7 @@ const EditProduk = ({ productId }) => {
</
div
>
</
div
>
<
FormProduk
{
...{
onSubmit
,
initialData
,
error
}
}
/>
</
div
>
)
}
</
div
>
</
Fragment
>
)
};
...
...
src/page/produk/FormProduk.jsx
View file @
46d8845f
...
...
@@ -113,15 +113,13 @@ const FormProduk = ({ onSubmit, initialData = null, error }) => {
}
const
formData
=
new
FormData
();
const
formKey
=
[
"
image
"
];
const
formCurrency
=
[
"
modal
"
,
"
price
"
];
// Loop through every field in form and append to FormData
for
(
const
key
in
data
)
{
if
(
formKey
.
includes
(
key
))
{
if
(
data
.
image
.
length
!==
0
)
formData
.
append
(
"
image
"
,
data
[
"
image
"
][
0
]);
}
else
if
(
formCurrency
.
includes
(
key
))
formData
.
append
(
key
,
formatValue
(
data
[
key
]));
}
else
formData
.
append
(
key
,
data
[
key
]);
isPreorder
===
"
true
"
?
formData
.
set
(
"
stock
"
,
""
)
...
...
@@ -129,6 +127,9 @@ const FormProduk = ({ onSubmit, initialData = null, error }) => {
isHampers
===
"
false
"
?
formData
.
set
(
"
hampers_price
"
,
""
)
:
formData
.
set
(
"
hampers_price
"
,
data
[
"
hampers_price
"
]);
formData
.
set
(
"
modal
"
,
formatValue
(
valueModal
))
formData
.
set
(
"
price
"
,
formatValue
(
valueHarga
))
}
onSubmit
(
formData
);
},
...
...
@@ -182,30 +183,28 @@ const FormProduk = ({ onSubmit, initialData = null, error }) => {
{
/* NAME SECTION END */
}
{
/*
MODAL
SECTION START */
}
{
/*
SATUAN
SECTION START */
}
<
RowInput
>
<
LabelInput
htmlFor
=
"modal"
>
Modal/Satuan
</
LabelInput
>
<
MaskedInput
data
-
testid
=
"modal-produk-input"
type
=
"text"
name
=
"modal"
<
RowInput
>
<
LabelInput
htmlFor
=
"unit"
>
Satuan
<
span
css
=
{
css
`
color: red;
`
}
>
*
</
span
>
</
LabelInput
>
<
InputForm
data
-
testid
=
"unit-produk-input"
name
=
"unit"
ref
=
{
register
({
required
:
true
})
}
onChange
=
{
onChangeModal
}
mask
=
{
currencyMask
}
css
=
{
css
`
flex-grow: 4;
border: 1px solid #e0e1e2;
box-sizing: border-box;
border-radius: 4px;
font-size: 1rem;
padding-left: 1rem;
`
}
/>
{
error
Modal
===
1
&&
<
ErrorDiv
>
Modal
tidak boleh kosong
</
ErrorDiv
>
}
{
error
s
.
unit
&&
<
ErrorDiv
>
Satuan Produk
tidak boleh kosong
</
ErrorDiv
>
}
</
RowInput
>
{
/*
MODAL
SECTION END */
}
{
/*
SATUAN
SECTION END */
}
{
/* CATEGORY SECTION START */
}
...
...
@@ -303,6 +302,31 @@ const FormProduk = ({ onSubmit, initialData = null, error }) => {
{
/* DESCRIPTION SECTION END */
}
{
/* MODAL SECTION START */
}
<
RowInput
>
<
LabelInput
htmlFor
=
"modal"
>
Modal/Satuan
</
LabelInput
>
<
MaskedInput
data
-
testid
=
"modal-produk-input"
type
=
"text"
name
=
"modal"
ref
=
{
register
({
required
:
true
})
}
onChange
=
{
onChangeModal
}
mask
=
{
currencyMask
}
css
=
{
css
`
flex-grow: 4;
border: 1px solid #e0e1e2;
box-sizing: border-box;
border-radius: 4px;
font-size: 1rem;
padding-left: 1rem;
`
}
/>
{
errorModal
===
1
&&
<
ErrorDiv
>
Modal tidak boleh kosong
</
ErrorDiv
>
}
</
RowInput
>
{
/* MODAL SECTION END */
}
{
/* HARGA SECTION START */
}
<
RowInput
>
...
...
@@ -505,29 +529,6 @@ const FormProduk = ({ onSubmit, initialData = null, error }) => {
{
/* PREORDER SECTION END */
}
{
/* SATUAN SECTION START */
}
<
RowInput
>
<
LabelInput
htmlFor
=
"unit"
>
Satuan
<
span
css
=
{
css
`
color: red;
`
}
>
*
</
span
>
</
LabelInput
>
<
InputForm
data
-
testid
=
"unit-produk-input"
name
=
"unit"
ref
=
{
register
({
required
:
true
})
}
/>
{
errors
.
unit
&&
<
ErrorDiv
>
Satuan Produk tidak boleh kosong
</
ErrorDiv
>
}
</
RowInput
>
{
/* SATUAN SECTION END */
}
{
/* IMAGE SECTION START */
}
<
RowInput
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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