Created
March 29, 2024 09:57
-
-
Save Bogdan808/0299e2ae12cbf031b2ffcf5f74735f92 to your computer and use it in GitHub Desktop.
This file contains 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"; | |
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<PurchaseOrdersApi.IStatus, StatusChipsType> = { | |
EDITING: "paused", | |
RECEIVED: "success", | |
SHIPMENT_ERROR: "error", | |
CONFIRMED: "disabled", | |
IN_TRANSIT: "disabled", | |
RECEIVING: "disabled", | |
SHIPMENT_CREATED: "disabled", | |
CLOSED: "disabled", | |
CANCELLED: "disabled", | |
}; | |
export const PurchaseOrdersStatusCell = ({ value }: { value: PurchaseOrdersApi.IStatus }) => { | |
const { t } = useTranslation(); | |
return ( | |
<StatusChip type={typeByStatus[value]}> | |
{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