Skip to content

Commit

Permalink
(add) reference to shipment list and improve responsive styling
Browse files Browse the repository at this point in the history
  • Loading branch information
danh91 committed Dec 16, 2023
1 parent fde45ec commit f3f48c7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
15 changes: 10 additions & 5 deletions apps/dashboard/src/modules/Shipments/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatAddressShort, formatAddressLocationShort, formatDateTime, formatRef, getURLSearchParams, isListEqual, isNone, isNoneOrEmpty } from "@karrio/lib";
import { formatAddressShort, formatAddressLocationShort, formatDateTime, formatRef, getURLSearchParams, isListEqual, isNone, isNoneOrEmpty, formatCarrierSlug } from "@karrio/lib";
import { ShipmentPreview, ShipmentPreviewContext } from "@/components/shipment-preview";
import { ShipmentsFilter } from "@karrio/ui/filters/shipments-filter";
import { ShipmentMenu } from "@karrio/ui/components/shipment-menu";
Expand All @@ -16,6 +16,7 @@ import React, { useContext, useEffect } from "react";
import { useRouter } from "next/dist/client/router";
import { AddressType } from "@karrio/types";
import Head from "next/head";
import { useAPIMetadata } from "@karrio/hooks/api-metadata";

export { getServerSideProps } from "@/context/main";

Expand All @@ -24,6 +25,7 @@ export default function ShipmentsPage(pageProps: any) {
const Component: React.FC = () => {
const router = useRouter();
const { setLoading } = useLoader();
const { metadata } = useAPIMetadata();
const [initialized, setInitialized] = React.useState(false);
const { previewShipment } = useContext(ShipmentPreviewContext);
const context = useShipments({
Expand Down Expand Up @@ -100,19 +102,19 @@ export default function ShipmentsPage(pageProps: any) {
<td className="service is-size-7">SERVICE</td>
<td className="status"></td>
<td className="recipient is-size-7">RECIPIENT</td>
<td className="reference is-size-7">REFERENCE</td>
<td className="date is-size-7">DATE</td>
<td className="action"></td>
</tr>

{(shipments?.edges || []).map(({ node: shipment }) => (
<tr key={shipment.id} className="items is-clickable">
<td className="carrier is-vcentered p-2" onClick={() => previewShipment(shipment.id)}>
{!!shipment.carrier_name && <CarrierBadge
<CarrierBadge
className="has-background-primary has-text-weight-bold has-text-white-bis"
style={{ fontSize: '0.6rem' }}
carrier_name={shipment.meta.carrier || shipment.carrier_name}
/>}
{!shipment.carrier_name && <AppBadge />}
carrier_name={shipment.meta?.carrier || shipment.carrier_name || formatCarrierSlug(metadata.APP_NAME)}
/>
</td>
<td className="service is-vcentered p-1 pl-2 is-size-7 has-text-weight-bold has-text-grey text-ellipsis"
onClick={() => previewShipment(shipment.id)}
Expand All @@ -138,6 +140,9 @@ export default function ShipmentsPage(pageProps: any) {
<br />
<span className="has-text-weight-medium">{formatAddressLocationShort(shipment.recipient as AddressType)}</span>
</td>
<td className="reference is-vcentered is-size-7 has-text-weight-bold has-text-grey text-ellipsis" onClick={() => previewShipment(shipment.id)}>
<span>{shipment.reference || ''}</span>
</td>
<td className="date is-vcentered px-1" onClick={() => previewShipment(shipment.id)}>
<p className="is-size-7 has-text-weight-semibold has-text-grey">
{formatDateTime(shipment.created_at)}
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/pages/api/images/[name].ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function ImageFallback(req: NextApiRequest, res: NextApiResponse) {
${path}
<text x="50%" y="55%" alignment-baseline="middle" text-anchor="middle" fill="#ddd" font-weight="bold" font-family="arial"
font-size="${isIcon ? '16em' : '0.9em'}" style="text-transform: uppercase; ${isIcon ? 'border-radius: 40px;' : ''}">
font-size="${isIcon ? '16em' : '.95em'}" style="text-transform: uppercase; ${isIcon ? 'border-radius: 40px;' : '4px'}">
${carrier_name}
</text>
</g>
Expand Down
10 changes: 8 additions & 2 deletions apps/dashboard/src/styles/dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Karrio custom styling
.shipments-table {
.carrier {
width: 8%;
min-width: 50px;
min-width: 90px;
}

.service {
Expand All @@ -60,9 +60,15 @@ Karrio custom styling
max-width: 200px;
}

.reference {
min-width: 10vw;
max-width: 150px;
}

.date {
width: 15%;
min-width: 120px;
max-width: 120px;
}

.action {
Expand Down Expand Up @@ -390,7 +396,7 @@ hr {
position: fixed;
top: 0;
z-index: 40;
border-top: 1px solid rgb(196, 76, 52);
border-top: 2px solid rgb(196, 76, 52);
padding: 0;
text-align: center;
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/components/carrier-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface CarrierBadgeComponent extends React.AllHTMLAttributes<HTMLDivElement>
export const CarrierBadge: React.FC<CarrierBadgeComponent> = ({ carrier_name, className, ...props }) => {
return (
<div className='mt-1'>
<Image src={p`/carriers/${carrier_name}_logo.svg`} height="20" width="80" alt="carrier logo" />
<Image src={p`/carriers/${carrier_name}_logo.svg`} height="14" width="70" alt="carrier logo" />
</div>
);
};

0 comments on commit f3f48c7

Please sign in to comment.