import React from "react"; import { Product } from "@/_models/Product"; import Image from "next/image"; import { ModelStatus, ModelStatusComponent } from "../ModelStatusComponent"; import ModelActionMenu from "../ModelActionMenu"; import { useAtomValue } from "jotai"; import { currentProductAtom } from "@/_helpers/JotaiWrapper"; import ModelActionButton, { ModelActionType } from "../ModelActionButton"; import useStartStopModel from "@/_hooks/useStartStopModel"; import useDeleteModel from "@/_hooks/useDeleteModel"; type Props = { model: Product; }; const ModelRow: React.FC = ({ model }) => { const { startModel } = useStartStopModel(); const activeModel = useAtomValue(currentProductAtom); const { deleteModel } = useDeleteModel(); let status = ModelStatus.Installed; if (activeModel && activeModel.id === model.id) { status = ModelStatus.Active; } let actionButtonType = ModelActionType.Start; if (activeModel && activeModel.id === model.id) { actionButtonType = ModelActionType.Stop; } const onModelActionClick = (action: ModelActionType) => { if (action === ModelActionType.Start) { startModel(model.id); } }; const onDeleteClick = () => { deleteModel(model); }; return ( {model.name} {model.version}
{model.format} {model.accelerated && ( GPU Accelerated )}
{model.totalSize} ); }; export default ModelRow;