51 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-08-29 18:45:52 +02:00
import { CheckCircle, CircleDashed, ShieldAlert } from "lucide-react";
import "./CustomStateCellRender.css";
2024-10-08 15:33:04 +02:00
import { Cell, Tooltip } from "@codex-storage/marketplace-ui-components";
2024-08-29 18:45:52 +02:00
type Props = {
state: string;
message: string | undefined;
};
export const CustomStateCellRender = ({ state, message }: Props) => {
const icons = {
pending: CircleDashed,
submitted: CircleDashed,
started: CircleDashed,
finished: CheckCircle,
cancelled: ShieldAlert,
2024-09-16 13:47:31 +02:00
errored: ShieldAlert,
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",
};
const Icon = icons[state as keyof typeof icons] || CircleDashed;
return (
2024-10-08 15:33:04 +02:00
<Cell>
<p
className={
"cell-state cell-state--custom cell-state--" +
states[state as keyof typeof states]
}>
{message ? (
<Tooltip message={message}>
<Icon size={"1rem"} className="cell-stateIcon" />
</Tooltip>
) : (
2024-08-29 18:45:52 +02:00
<Icon size={"1rem"} className="cell-stateIcon" />
2024-10-08 15:33:04 +02:00
)}
2024-08-29 18:45:52 +02:00
2024-10-08 15:33:04 +02:00
<span>{state}</span>
</p>
</Cell>
2024-08-29 18:45:52 +02:00
);
};