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