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