Skip to main content
Frontend tutorial

5.5. Create LoadingBox

Pick one loading and think about what the person at the ramp needs to know: who it's for, when it's due, and how many pallets are ready. Everything the card needs is already on Loading:

src/components/LoadingBox.tsx
import { Card, Elevation, ProgressBar } from "@blueprintjs/core";
import { observer } from "mobx-react-lite";
import { Loading } from "../store/Loading";

export const LoadingBox = observer(({ loading }: { loading: Loading }) => {
const { customer } = loading;

return <Card className="Loading" elevation={Elevation.TWO} interactive>
<header>
<div>{loading.id}</div>
</header>
<main>
<div className="details">
{loading.start.date}
<div>
<span>{loading.start.time}</span>-{loading.end.time}
</div>
</div>
<div className="customer">
{customer && <>
<div className="name">{customer.name}</div>
<div className="city">{customer.country}, {customer.city}</div>
<div className="id">{customer.id.replace(/^0*/,"")}</div>
</>}
</div>
</main>
<footer>
<div>
<b>{loading.picked}</b> of <b>{loading.pallets}</b>
</div>
<ProgressBar animate={false} value={loading.loadedRatio}
intent={loading.isLoaded ? "success" : "primary"} />
</footer>
</Card>;
});

Customer numbers come from SAP with leading zeros, so we cut them off. loadedRatio is picked / pallets, a number from 0 to 1, which is exactly what Blueprint's ProgressBar wants: 11 of 22 pallets fills half the bar. When everything is picked, isLoaded turns the bar green.

And try to display one in RampBox:

src/components/RampBox.tsx
import { Ramp } from "../store/Ramp";
import { store } from "../store/Store";
import { LoadingBox } from "./LoadingBox";
import "./Ramp.scss";

// ...

<main>
<LoadingBox loading={store.loadings[0]}/>
</main>

Every ramp shows the same loading, 0007701. That's fine for now. We wanted to see the card first.

05 / ShippingBoard Lite

localhost:5173
Ramps A, B, C and D each show the same card: loading 0007701 for Militech, 06:00 to 09:00, 2 of 2 pallets with a full green bar.

For now every ramp shows the first loading.