feat: optimize style of SMS notifications module.

This commit is contained in:
a.bouhuolia
2021-11-09 12:34:55 +02:00
parent 4b5e06f50c
commit 7371557482
14 changed files with 96 additions and 45 deletions

View File

@@ -1,25 +1,53 @@
import React from 'react';
import styled from 'styled-components';
import { Intent } from '@blueprintjs/core';
import { DataTable } from 'components';
import { DataTable, AppToaster } from 'components';
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
import { useSMSIntegrationTableColumns, ActionsMenu } from './components';
import { useSMSIntegrationContext } from './SMSIntegrationProvider';
import { useSettingEditSMSNotification } from 'hooks/query';
import withDialogActions from 'containers/Dialog/withDialogActions';
import { compose } from 'utils';
/**
* SMS Message data table.
*/
function SMSMessagesDataTable({
// #withDialogAction
openDialog,
}) {
// Edit SMS message notification mutations.
const { mutateAsync: editSMSNotificationMutate } =
useSettingEditSMSNotification();
// Handle notification switch change.
const handleNotificationSwitchChange = React.useCallback(
(event, value, notification) => {
editSMSNotificationMutate({
notification_key: notification.key,
is_notification_enabled: value,
}).then(() => {
AppToaster.show({
message: 'SMS notification hs been enabled successfully.',
intent: Intent.SUCCESS,
});
});
},
[editSMSNotificationMutate],
);
// Table columns.
const columns = useSMSIntegrationTableColumns();
const columns = useSMSIntegrationTableColumns({
onSwitchChange: handleNotificationSwitchChange,
});
const { notifications, isSMSNotificationsLoading } =
useSMSIntegrationContext();
// handle edit message link click
const handleEditMessageText = ({ key }) => {
openDialog('sms-message-form', { notificationkey: key });
};

View File

@@ -5,6 +5,7 @@ import { Menu, MenuItem } from '@blueprintjs/core';
import { ButtonLink } from 'components';
import { SwitchFieldCell } from 'components/DataTableCells';
import { safeInvoke } from 'utils';
/**
@@ -63,7 +64,7 @@ export function ActionsMenu({
* Retrieve SMS notifications messages table columns
* @returns
*/
export function useSMSIntegrationTableColumns() {
export function useSMSIntegrationTableColumns({ onSwitchChange }) {
return React.useMemo(
() => [
{
@@ -98,9 +99,10 @@ export function useSMSIntegrationTableColumns() {
disableResizing: true,
disableSortBy: true,
width: '80',
onSwitchChange,
},
],
[],
[onSwitchChange],
);
}