import React from "react"; import { Button, Datagrid, DateField, Filter, List, Pagination, ReferenceField, ReferenceManyField, SearchInput, Show, Tab, TabbedShowLayout, TextField, TopToolbar, useRecordContext, useDelete, useNotify, useRefresh, useTranslate, } from "react-admin"; import AutorenewIcon from "@mui/icons-material/Autorenew"; import FolderSharedIcon from "@mui/icons-material/FolderShared"; import ViewListIcon from "@mui/icons-material/ViewList"; const DestinationPagination = props => ( ); const date_format = { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", }; const destinationRowSx = (record, _index) => ({ backgroundColor: record.retry_last_ts > 0 ? "#ffcccc" : "white", }); const DestinationFilter = props => { return ( ); }; export const DestinationReconnectButton = props => { const record = useRecordContext(); const refresh = useRefresh(); const notify = useNotify(); const [handleReconnect, { isLoading }] = useDelete(); // Reconnect is not required if no error has occurred. (`failure_ts`) if (!record || !record.failure_ts) return null; const handleClick = e => { // Prevents redirection to the detail page when clicking in the list e.stopPropagation(); handleReconnect( "destinations", { id: record.id }, { onSuccess: () => { notify("ra.notification.updated", { messageArgs: { smart_count: 1 }, }); refresh(); }, onError: () => { notify("ra.message.error", { type: "error" }); }, } ); }; return ( ); }; const DestinationShowActions = props => ( ); const DestinationTitle = props => { const record = useRecordContext(); const translate = useTranslate(); return ( {translate("resources.destinations.name", 1)} {record.destination} ); }; export const DestinationList = props => { return ( } pagination={} sort={{ field: "destination", order: "ASC" }} > `${id}/show/rooms`} bulkActionButtons={false} > ); }; export const DestinationShow = props => { const translate = useTranslate(); return ( } title={} {...props} > }> } path="rooms" > } perPage={50} > `/rooms/${id}/show`} > ); };