import { useMemo } from "react"; import { useAtom } from "jotai"; import { selectAtom } from "jotai/utils"; import { find, isEqual } from "lodash-es"; import { ISideDrawerFieldProps } from "@src/components/fields/types"; import { Box, Stack, Link } from "@mui/material"; import ActionFab from "./ActionFab"; import { tableScope, tableRowsAtom } from "@src/atoms/tableScope"; import { fieldSx, getFieldId } from "@src/components/SideDrawer/utils"; import { sanitiseCallableName, isUrl } from "./utils"; import { getActionName } from "./DisplayCell"; export default function Action({ column, _rowy_ref, value, disabled, }: ISideDrawerFieldProps) { const [row] = useAtom( useMemo( () => selectAtom( tableRowsAtom, (tableRows) => find(tableRows, ["_rowy_ref.path", _rowy_ref.path]), isEqual ), [_rowy_ref.path] ), tableScope ); const hasRan = value && value.status; return ( {hasRan && isUrl(value.status) ? ( {value.status} ) : hasRan ? ( value.status ) : ( sanitiseCallableName(getActionName(column)) )} ); }