Fakultas Ilmu Komputer UI

Commit a45c2454 authored by Wan Muhammad Rayhan Arwindra's avatar Wan Muhammad Rayhan Arwindra 🤸🏽
Browse files

Pbi 3 batch transaksi

parent e78125b8
...@@ -51,7 +51,7 @@ test(" Test List transaksi", async () => { ...@@ -51,7 +51,7 @@ test(" Test List transaksi", async () => {
created_at: "2020-04-18T10:59:42.074386+07:00", created_at: "2020-04-18T10:59:42.074386+07:00",
updated_at: "2020-04-18T11:00:18.150633+07:00", updated_at: "2020-04-18T11:00:18.150633+07:00",
subtotal: "370000.00", subtotal: "370000.00",
batch: "Batch 1" batch_name: "Batch 1"
}, },
], ],
}) })
...@@ -114,7 +114,7 @@ test(" Test List transaksi filter", async () => { ...@@ -114,7 +114,7 @@ test(" Test List transaksi filter", async () => {
created_at: "2020-04-18T10:59:42.074386+07:00", created_at: "2020-04-18T10:59:42.074386+07:00",
updated_at: "2020-04-18T11:00:18.150633+07:00", updated_at: "2020-04-18T11:00:18.150633+07:00",
subtotal: "370000.00", subtotal: "370000.00",
batch: "Batch 2", batch_name: "Batch 2",
}, },
], ],
}) })
...@@ -161,7 +161,7 @@ test(" Test List transaksi filter", async () => { ...@@ -161,7 +161,7 @@ test(" Test List transaksi filter", async () => {
created_at: "2020-04-18T10:59:42.074386+07:00", created_at: "2020-04-18T10:59:42.074386+07:00",
updated_at: "2020-04-18T11:00:18.150633+07:00", updated_at: "2020-04-18T11:00:18.150633+07:00",
subtotal: "370000.00", subtotal: "370000.00",
batch: "Batch 1", batch_name: "Batch 1",
}, },
], ],
}) })
......
...@@ -27,6 +27,8 @@ const FormBatch = ({ onSubmit, initialData = null }) => { ...@@ -27,6 +27,8 @@ const FormBatch = ({ onSubmit, initialData = null }) => {
flex-direction: column; flex-direction: column;
`} `}
> >
{errors.batch_name && <ErrorDiv>Nama batch tidak boleh kosong</ErrorDiv>}
<RowInput> <RowInput>
<LabelInput htmlFor="batch_name">Nama batch </LabelInput> <LabelInput htmlFor="batch_name">Nama batch </LabelInput>
<InputForm <InputForm
...@@ -34,26 +36,18 @@ const FormBatch = ({ onSubmit, initialData = null }) => { ...@@ -34,26 +36,18 @@ const FormBatch = ({ onSubmit, initialData = null }) => {
name="batch_name" name="batch_name"
ref={register({ required: true })} ref={register({ required: true })}
/> />
{errors.batch_name && <ErrorDiv>Nama batch tidak boleh kosong</ErrorDiv>}
</RowInput> </RowInput>
{/* {initialData !== null && initialData["image"] != null ? (
<img
css={css`
height: 10rem;
object-fit: contain;
`}
alt={initialData["name"]}
src={initialData["image"]}
/>
) : null} */}
<RowInput> <RowInput>
<LabelInput htmlFor="start_date">Tanggal Dimulai</LabelInput> <LabelInput htmlFor="start_date">Tanggal Dimulai</LabelInput>
<InputForm type="date" name="start_date" ref={register} readOnly={initialData !== null} /> <InputForm type="date" name="start_date" ref={register} readOnly={initialData !== null} />
</RowInput> </RowInput>
<RowInput> <RowInput>
<LabelInput htmlFor="end_date">Tanggal Berakhir</LabelInput> <LabelInput htmlFor="end_date">Tanggal Berakhir</LabelInput>
<InputForm type="date" name="end_date" ref={register} readOnly={initialData !== null} /> <InputForm type="date" name="end_date" ref={register} readOnly={initialData !== null} />
</RowInput> </RowInput>
<RowInput> <RowInput>
<LabelInput htmlFor="shipping_cost">Ongkos Kirim</LabelInput> <LabelInput htmlFor="shipping_cost">Ongkos Kirim</LabelInput>
<InputForm type="text" name="shipping_cost" ref={register} /> <InputForm type="text" name="shipping_cost" ref={register} />
......
...@@ -9,8 +9,14 @@ const ListBatch = () =>{ ...@@ -9,8 +9,14 @@ const ListBatch = () =>{
const [batches, error] = useFetchSingleData(`${process.env.REACT_APP_BASE_URL}/batch/`); const [batches, error] = useFetchSingleData(`${process.env.REACT_APP_BASE_URL}/batch/`);
if (!error && batches.results !== undefined){ if (!error && batches.results !== undefined){
const shippingCosts = batches.results.map( (batch) => batch.shipping_cost); const shippingCosts = batches.results.map( (batch) => batch.shipping_cost);
const cost = shippingCosts.reduce( (acc, curr) => acc + curr); if (shippingCosts){
totalCost = cost; const cost = shippingCosts.reduce( (acc, curr) => acc + curr);
totalCost = cost;
}else{
totalCost = "0";
}
} }
const data = { const data = {
url: `${process.env.REACT_APP_BASE_URL}/batch/`, url: `${process.env.REACT_APP_BASE_URL}/batch/`,
......
...@@ -21,7 +21,7 @@ const ListTransaksi = () => { ...@@ -21,7 +21,7 @@ const ListTransaksi = () => {
["updated_at", "Tanggal Update", stringToDate], ["updated_at", "Tanggal Update", stringToDate],
["", "Status", transactionToColoredStatus], ["", "Status", transactionToColoredStatus],
["subtotal", "Total", stringToCurrency], ["subtotal", "Total", stringToCurrency],
["batch","Batch"] ["batch_name","Batch"]
], ],
link: "/transaksi/", link: "/transaksi/",
filter: [ filter: [
......
...@@ -21,7 +21,7 @@ const useDownloadFile = (urlString) => { ...@@ -21,7 +21,7 @@ const useDownloadFile = (urlString) => {
: url; : url;
url = url =
batch !== "" batch !== ""
? url.concat(`batch_name${batch}&`) ? url.concat(`batch_name=${batch}&`)
: url; : url;
trackPromise( trackPromise(
fetch(url, { fetch(url, {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment