diff --git a/src/components/RoomDirectory.js b/src/components/RoomDirectory.js index bb30e75..2b338a6 100644 --- a/src/components/RoomDirectory.js +++ b/src/components/RoomDirectory.js @@ -13,6 +13,7 @@ import { TextField, TopToolbar, useCreate, + useDataProvider, useListContext, useNotify, useTranslate, @@ -28,7 +29,7 @@ const RoomDirectoryPagination = () => ( ); -export const RoomDirectoryDeleteButton = props => { +export const RoomDirectoryUnpublishButton = props => { const translate = useTranslate(); return ( @@ -49,7 +50,7 @@ export const RoomDirectoryDeleteButton = props => { ); }; -export const RoomDirectoryBulkDeleteButton = props => ( +export const RoomDirectoryBulkUnpublishButton = props => ( ( /> ); -export const RoomDirectoryBulkSaveButton = () => { +export const RoomDirectoryBulkPublishButton = props => { const { selectedIds } = useListContext(); const notify = useNotify(); const refresh = useRefresh(); const unselectAllRooms = useUnselectAll("rooms"); - const { createMany, isloading } = useMutation(); - - const handleSend = values => { - createMany( - ["room_directory", "createMany", { ids: selectedIds, data: {} }], - { - onSuccess: data => { - notify("resources.room_directory.action.send_success"); - unselectAllRooms(); - refresh(); - }, - onError: error => - notify("resources.room_directory.action.send_failure", { - type: "error", - }), - } - ); - }; + const dataProvider = useDataProvider(); + const { mutate, isLoading } = useMutation( + () => + dataProvider.createMany("room_directory", { + ids: selectedIds, + data: {}, + }), + { + onSuccess: () => { + notify("resources.room_directory.action.send_success"); + unselectAllRooms(); + refresh(); + }, + onError: () => + notify("resources.room_directory.action.send_failure", { + type: "error", + }), + } + ); return ( ); }; -export const RoomDirectorySaveButton = () => { +export const RoomDirectoryPublishButton = props => { const record = useRecordContext(); const notify = useNotify(); const refresh = useRefresh(); - const [create, { isloading }] = useCreate(); + const [create, { isLoading }] = useCreate(); const handleSend = () => { create( "room_directory", { data: { id: record.id } }, { - onSuccess: _data => { + onSuccess: () => { notify("resources.room_directory.action.send_success"); refresh(); }, - onError: _error => + onError: () => notify("resources.room_directory.action.send_failure", { type: "error", }), @@ -121,17 +124,16 @@ export const RoomDirectorySaveButton = () => { return ( ); }; -const RoomDirectoryBulkActionButtons = () => ; - const RoomDirectoryListActions = () => ( @@ -146,8 +148,8 @@ export const RoomDirectoryList = () => ( actions={} > "/rooms/" + id + "/show"} - bulkActionButtons={} + rowClick={(id, _resource, _record) => "/rooms/" + id + "/show"} + bulkActionButtons={} omit={["room_id", "canonical_alias", "topic"]} > { return ( - {roomDirectoryStatus === false && ( - - )} - {roomDirectoryStatus === true && ( - - )} + {roomDirectoryStatus === false && } + {roomDirectoryStatus === true && } { const RoomBulkActionButtons = () => ( <> - - + +