50 lines
1.1 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-08-30 17:26:27 +02:00
import { StateCell, Tooltip } from "@codex-storage/marketplace-ui-components";
2024-08-29 18:45:52 +02:00
// Import css
StateCell;
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,
};
const states = {
cancelled: "error",
pending: "warning",
started: "loading",
submitted: "loading",
finished: "success",
};
const Icon = icons[state as keyof typeof icons] || CircleDashed;
return (
<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>
) : (
<Icon size={"1rem"} className="cell-stateIcon" />
)}
<span>{state}</span>
</p>
);
};