import { type FC, useCallback, useState } from "react"; import { Button } from "@marzneshin/common/components"; import { SelectableEntityTable, useRowSelection } from "@marzneshin/libs/entity-table"; import { columns } from "./columns"; import { type ServiceType, useServicesUpdateMutation, fetchSelectableServiceInbounds } from "@marzneshin/modules/services"; import { useTranslation } from "react-i18next"; interface ServiceInboundsTableProps { service: ServiceType; } export const ServiceInboundsTable: FC = ({ service, }) => { const { mutate: updateService } = useServicesUpdateMutation(); const { selectedRow, setSelectedRow } = useRowSelection(Object.fromEntries(service.inbound_ids.map(entityId => [String(entityId), true]))); const [selectedInbound, setSelectedInbound] = useState(service.inbound_ids); const { t } = useTranslation(); const handleApply = useCallback(() => { updateService({ id: service.id, name: service.name, inbound_ids: selectedInbound }); }, [selectedInbound, service, updateService]); const disabled = Object.keys(selectedRow).length < 1; return (
); };