mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: optimize style of SMS notifications module.
This commit is contained in:
@@ -64,7 +64,6 @@ function SMSMessageForm({
|
||||
}
|
||||
setSubmitting(false);
|
||||
};
|
||||
debugger;
|
||||
editSMSNotificationMutate(form).then(onSuccess).catch(onError);
|
||||
};
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ function SMSMessagePreviewSection() {
|
||||
return (
|
||||
<SMSPreviewSectionRoot>
|
||||
<SMSMessagePreview message={message} />
|
||||
|
||||
<SMSPreviewSectionNote>
|
||||
<strong>Note</strong>: Note: One SMS unit can contain a maximum of 160
|
||||
characters. <strong>{messagesUnits}</strong> SMS units will be used to
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import React from 'react';
|
||||
import { Intent, Button, Classes } from '@blueprintjs/core';
|
||||
import { useFormikContext } from 'formik';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import { DialogFooterActions, FormattedMessage as T } from 'components';
|
||||
|
||||
import { useSMSMessageDialogContext } from './SMSMessageDialogProvider';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
@@ -20,6 +19,7 @@ function SMSMessageFormFloatingActions({
|
||||
// Formik context.
|
||||
const { isSubmitting } = useFormikContext();
|
||||
|
||||
// SMS Message dialog contxt.
|
||||
const { dialogName } = useSMSMessageDialogContext();
|
||||
|
||||
// Handle close button click.
|
||||
@@ -29,7 +29,7 @@ function SMSMessageFormFloatingActions({
|
||||
|
||||
return (
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<FooterActions className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<DialogFooterActions alignment={'left'}>
|
||||
<Button onClick={handleCancelBtnClick} style={{ minWidth: '75px' }}>
|
||||
<T id={'cancel'} />
|
||||
</Button>
|
||||
@@ -41,13 +41,9 @@ function SMSMessageFormFloatingActions({
|
||||
>
|
||||
Save SMS Message
|
||||
</Button>
|
||||
</FooterActions>
|
||||
</DialogFooterActions>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(SMSMessageFormFloatingActions);
|
||||
|
||||
const FooterActions = styled.div`
|
||||
justify-content: flex-start;
|
||||
`;
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { Intent, Button, Classes } from '@blueprintjs/core';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { FormattedMessage as T } from 'components';
|
||||
|
||||
import { safeCallback } from 'utils';
|
||||
import { DialogFooterActions, FormattedMessage as T } from 'components';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -21,7 +18,7 @@ export default function NotifyViaSMSFormFloatingActions({ onCancel }) {
|
||||
|
||||
return (
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<FooterActions className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<DialogFooterActions alignment={'left'}>
|
||||
<Button
|
||||
intent={Intent.PRIMARY}
|
||||
loading={isSubmitting}
|
||||
@@ -37,11 +34,7 @@ export default function NotifyViaSMSFormFloatingActions({ onCancel }) {
|
||||
>
|
||||
<T id={'cancel'} />
|
||||
</Button>
|
||||
</FooterActions>
|
||||
</DialogFooterActions>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const FooterActions = styled.div`
|
||||
justify-content: flex-start;
|
||||
`;
|
||||
}
|
||||
@@ -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 });
|
||||
};
|
||||
|
||||
@@ -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],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user