Created
March 29, 2024 10:06
-
-
Save Bogdan808/f78f54e43e0f516de070367081dce4d6 to your computer and use it in GitHub Desktop.
Extracted
Extracted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StatusChip } from "@helium10/re-ui-components"; | |
import type { StatusChipsType } from "@helium10/re-ui-components/src/components/chip/config"; | |
import { useTranslation } from "@/i18n/useTranslation"; | |
import type { PurchaseOrdersApi } from "@/requests/purchaseOrder/purchaseOrders"; | |
type ExtractedStatuses = Extract< | |
PurchaseOrdersApi.IStatus, | |
"EDITING" | "RECEIVED" | "SHIPMENT_ERROR" | |
>; | |
const purchaseOrdersStatuses: Record<PurchaseOrdersApi.IStatus, string> = { | |
EDITING: "editing", | |
CONFIRMED: "confirmed", | |
IN_TRANSIT: "inTransit", | |
RECEIVING: "receiving", | |
RECEIVED: "received", | |
SHIPMENT_CREATED: "shipmentCreated", | |
CLOSED: "closed", | |
CANCELLED: "cancelled", | |
SHIPMENT_ERROR: "shipmentError", | |
}; | |
const typeByStatus: Record<ExtractedStatuses, StatusChipsType> = { | |
EDITING: "paused", | |
RECEIVED: "success", | |
SHIPMENT_ERROR: "error", | |
}; | |
export const PurchaseOrdersStatusCell = ({ value }: { value: PurchaseOrdersApi.IStatus }) => { | |
const { t } = useTranslation(); | |
return ( | |
<StatusChip type={typeByStatus[value as ExtractedStatuses] || "disabled"}> | |
{t(`purchaseOrders.columns.status.content.${purchaseOrdersStatuses[value]}`)} | |
</StatusChip> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment