Fakultas Ilmu Komputer UI

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

Merge branch 'pbi-9' into 'staging'

Pbi 9

See merge request !101
parents 25baf858 db518049
/* /index.html 200
......@@ -28,7 +28,7 @@
},
"scripts": {
"start": "cross-env REACT_APP_BASE_URL=https://industripilar-staging.herokuapp.com parcel public/index.html",
"build": "parcel build public/index.html",
"build": "cross-env REACT_APP_BASE_URL=https://industripilar-staging.herokuapp.com parcel build public/index.html",
"test": "jest",
"test:coverage": "jest --coverage",
"lint": "eslint \"src/**/*.{js,jsx}\" --quiet",
......
......@@ -63,7 +63,7 @@ test("Test tambah produk renders", async () => {
)
.once(JSON.stringify({}), { statusCode: 200 });
const { getByTestId, getByLabelText } = render(
const { getByTestId} = render(
<AuthContext.Provider value={{ profile: { token: "BEBAS" } }}>
<TambahProduk />
</AuthContext.Provider>
......@@ -88,11 +88,6 @@ test("Test tambah produk renders", async () => {
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
await act(async () => {
await fireEvent.click(getByLabelText("Biasa"), {
target: { value: "false" },
});
});
await act(async () => {
await fireEvent.submit(getByTestId("submit-produk"));
});
......@@ -224,7 +219,7 @@ test("Test tambah produk error", async () => {
)
.once(JSON.stringify({}), { status: 400 });
const { getByTestId, getByLabelText } = render(
const { getByTestId } = render(
<AuthContext.Provider value={{ profile: { token: "BEBAS" } }}>
<TambahProduk />
</AuthContext.Provider>
......@@ -249,11 +244,6 @@ test("Test tambah produk error", async () => {
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
await act(async () => {
await fireEvent.click(getByLabelText("Biasa"), {
target: { value: "false" },
});
});
await act(async () => {
await fireEvent.submit(getByTestId("submit-produk"));
});
......@@ -319,7 +309,7 @@ test("Test modal produk required", async () => {
)
.once(JSON.stringify({}), { statusCode: 200 });
const { getByTestId, getByLabelText } = render(
const { getByTestId } = render(
<AuthContext.Provider value={{ profile: { token: "BEBAS" } }}>
<TambahProduk />
</AuthContext.Provider>
......@@ -340,11 +330,6 @@ test("Test modal produk required", async () => {
await act(async () => {
await fireEvent.input(stock_produk, { target: { value: "1" } });
});
await act(async () => {
await fireEvent.click(getByLabelText("Biasa"), {
target: { value: "false" },
});
});
await act(async () => {
await fireEvent.submit(getByTestId("submit-produk"));
});
......
......@@ -76,10 +76,11 @@ const TableComponent = ({
}
const [filterTab, setFilterTab] = useState(false);
if (sort !== "" && sort !== null){
sortResults(sort);
}
return (
<div
css={css`
......
......@@ -8,6 +8,7 @@ import { stringToCurrency }from "../../component/TableUtils";
const ListBatch = () =>{
let totalCost = "Loading..."
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.length){
......@@ -16,8 +17,6 @@ const ListBatch = () =>{
}else{
totalCost = stringToCurrency("0");
}
}
const data = {
url: `${process.env.REACT_APP_BASE_URL}/batch/`,
......
......@@ -6,6 +6,8 @@ import {
} from "../../component/html/html";
import { css } from "@emotion/core";
import Button from "@material-ui/core/Button";
import SystemUpdateAltIcon from '@material-ui/icons/SystemUpdateAlt';
const FormDonasi = ({ idDonasi, defaultStatus }) => {
const url = `${process.env.REACT_APP_BASE_URL}/program-donations/${idDonasi}/`;
......@@ -41,8 +43,10 @@ const FormDonasi = ({ idDonasi, defaultStatus }) => {
type="submit"
variant="contained"
color="primary"
endIcon={<SystemUpdateAltIcon />}
>
Donasi Diterima
</Button>
</form>
</div>
......
......@@ -50,9 +50,9 @@ const FormDonasi = ({ idDonasi, defaultStatus }) => {
ref={register({ required: true })}
name="donation_status"
>
<option value="001">Waiting for admin confirmation</option>
<option value="002">Completed</option>
<option value="003">Canceled</option>
<option value="001">Menunggu Konfirmasi Admin</option>
<option value="002">Selesai</option>
<option value="003">Dibatalkam</option>
<option value="004">Meminta unggah ulang bukti</option>
</InputSelectForm>
</RowInput>
......
......@@ -31,6 +31,16 @@ const ListKategori = () => {
>
KELOLA KATEGORI
</div>
<div
css={css`
width: 100%;
justify-content: space-between;
display: flex;
flex-direction: row;
margin-bottom: 1.8rem;
margin-top: 1rem;
`}
>
<div
css={css`
width: 35%;
......@@ -43,6 +53,15 @@ const ListKategori = () => {
<LinkYellow to="/kategori/tambah">TAMBAH</LinkYellow>
<LinkYellow to="/kategori">LIHAT</LinkYellow>
</div>
<div
css={css`
display: flex;
width: 20%;
`}
>
<LinkYellow to="/produk">PRODUK</LinkYellow>
</div>
</div>
<TableComponent {...data} />
</div>
);
......
......@@ -6,6 +6,7 @@ import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogTitle from "@material-ui/core/DialogTitle";
import Button from "@material-ui/core/Button";
import SortIcon from '@material-ui/icons/Sort';
import {
RowInput,
InputSubmitForm,
......@@ -81,6 +82,7 @@ const ListPengguna = () => {
color: #3c8dbc;
height: 2.3rem;
`}
startIcon={<SortIcon />}
>
Urutkan
</Button>
......
......@@ -15,6 +15,7 @@ const EditProduk = ({ productId }) => {
const onSubmit = (data) => {
send(data);
};
console.log(initialData);
if (errorState || Object.keys(initialData).length === 0)
return (
<div
......
......@@ -21,10 +21,9 @@ const FormProduk = ({ onSubmit, initialData = null }) => {
category: initialData["category"],
subcategory: initialData["subcategory"],
description: initialData["description"],
price: initialData["price"],
price: initialData["price"].split(".")[0],
stock: initialData["stock"],
pre_order: initialData["pre_order"].toString(),
modal: initialData["modal"],
modal: initialData["modal"].split(".")[0],
}
: {},
});
......@@ -38,7 +37,6 @@ const FormProduk = ({ onSubmit, initialData = null }) => {
null,
]);
const watchCategory = watch("category", "");
const watchPreorder = watch("pre_order");
const [resultsSubcategory, errorStateSubcategory, , , , , ,] = useFetchList([
urlSubcategory,
null,
......@@ -49,17 +47,11 @@ const FormProduk = ({ onSubmit, initialData = null }) => {
]);
const filterSubmit = (data) => {
const formData = new FormData();
if (watchPreorder === "false") {
data.pre_order = false;
formData.append("stock", data["stock"]);
} else {
data.pre_order = true;
}
formData.append("stock", data["stock"]);
formData.append("name", data["name"]);
formData.append("subcategory", data["subcategory"]);
formData.append("description", data["description"]);
formData.append("price", data["price"]);
formData.append("pre_order", data["pre_order"]);
formData.append("modal", data["modal"]);
if (data["image"].length !== 0) formData.append("image", data["image"][0]);
onSubmit(formData);
......@@ -140,48 +132,6 @@ const FormProduk = ({ onSubmit, initialData = null }) => {
<ErrorDiv>Deskripsi Produk tidak boleh kosong</ErrorDiv>
)}
</RowInput>
<RowInput>
<LabelInput htmlFor="is-preorder">Tipe Barang</LabelInput>
<div
css={css`
display: flex;
flex-grow: 4;
align-items: baseline;
align-content: flex-start;
`}
>
<input
data-testid="is-preorder-produk-input"
type="radio"
name="pre_order"
value="false"
id="no-preorder"
ref={register({ required: true })}
/>
<label htmlFor="no-preorder">Biasa</label>
</div>
<div
css={css`
display: flex;
flex-grow: 4;
align-items: baseline;
align-content: flex-start;
`}
>
<input
data-testid="is-preorder-produk-input-2"
type="radio"
name="pre_order"
value="true"
id="preorder"
ref={register({ required: true })}
/>
<label htmlFor="preorder">Preorder</label>
</div>
{errors.pre_order && (
<ErrorDiv>Tipe Produk tidak boleh kosong</ErrorDiv>
)}
</RowInput>
<RowInput>
<LabelInput htmlFor="modal">Modal/kuantitas </LabelInput>
<InputForm
......@@ -208,8 +158,6 @@ const FormProduk = ({ onSubmit, initialData = null }) => {
data-testid="stock-produk-input"
type="number"
name="stock"
disabled={watchPreorder === "true"}
ref={register({ required: watchPreorder === "false" })}
/>
{errors.stock && <ErrorDiv>Stok Produk tidak boleh kosong</ErrorDiv>}
</RowInput>
......
......@@ -31,6 +31,16 @@ const ListSubkategori = () => {
>
KELOLA SUBKATEGORI
</div>
<div
css={css`
width: 100%;
justify-content: space-between;
display: flex;
flex-direction: row;
margin-bottom: 1.8rem;
margin-top: 1rem;
`}
>
<div
css={css`
width: 35%;
......@@ -43,6 +53,15 @@ const ListSubkategori = () => {
<LinkYellow to="tambah">TAMBAH</LinkYellow>
<LinkYellow to="/subkategori">LIHAT</LinkYellow>
</div>
<div
css={css`
display: flex;
width: 20%;
`}
>
<LinkYellow to="/produk">PRODUK</LinkYellow>
</div>
</div>
<TableComponent {...data} />
</div>
);
......
......@@ -51,13 +51,13 @@ const FormStatus = ({ idTransaksi, defaultStatus, paymentMethod }) => {
name="transaction_status"
>
{paymentMethod === "TRF" && (
<option value="001">Waiting for proof of payment</option>
<option value="001">Menunggu bukti pembayaran</option>
)}
<option value="002">Waiting for seller confirmation</option>
<option value="003">In process</option>
<option value="004">Being shipped</option>
<option value="005">Completed</option>
<option value="006">Canceled</option>
<option value="002">Menunggu konfirmasi penjual</option>
<option value="003">Dalam proses</option>
<option value="004">Sedang dikirim</option>
<option value="005">Selesai</option>
<option value="006">Dibatalkan</option>
</InputSelectForm>
</RowInput>
<Button
......
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