46 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Cell, Tooltip } from "@codex-storage/marketplace-ui-components";
2024-11-07 14:49:24 +01:00
import PurchaseStateIcon from "../../assets/icons/purchases-state-pending.svg?react";
import SuccessCircleIcon from "../../assets/icons/success-circle.svg?react";
import ErrorCircleIcon from "../../assets/icons/error-circle.svg?react";
2024-08-29 18:45:52 +02:00
type Props = {
state: string;
message: string | undefined;
};
export const CustomStateCellRender = ({ state, message }: Props) => {
2024-08-29 18:45:52 +02:00
const icons = {
2024-11-07 14:49:24 +01:00
pending: PurchaseStateIcon,
submitted: PurchaseStateIcon,
started: PurchaseStateIcon,
finished: SuccessCircleIcon,
cancelled: ErrorCircleIcon,
errored: ErrorCircleIcon,
2024-08-29 18:45:52 +02:00
};
const states = {
cancelled: "error",
2024-09-16 13:47:31 +02:00
errored: "error",
2024-08-29 18:45:52 +02:00
pending: "warning",
started: "loading",
submitted: "loading",
finished: "success",
};
2024-11-07 14:49:24 +01:00
const Icon = icons[state as keyof typeof icons] || PurchaseStateIcon;
2024-08-29 18:45:52 +02:00
return (
2024-10-08 15:33:04 +02:00
<Cell>
2024-11-07 14:58:56 +01:00
<p className={"cell-state" + states[state as keyof typeof states]}>
{message ? (
2024-10-08 15:33:04 +02:00
<Tooltip message={message}>
<Icon width={20} className="cell-stateIcon" />
2024-10-08 15:33:04 +02:00
</Tooltip>
) : (
<Icon width={20} className="cell-stateIcon" />
)}
2024-10-08 15:33:04 +02:00
</p>
</Cell>
2024-08-29 18:45:52 +02:00
);
};