mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-23 08:10:32 +00:00
feat: SMS message preview with variables.
This commit is contained in:
@@ -4,6 +4,9 @@ import '../../../style/pages/SMSMessage/SMSMessage.scss';
|
|||||||
import { SMSMessageDialogProvider } from './SMSMessageDialogProvider';
|
import { SMSMessageDialogProvider } from './SMSMessageDialogProvider';
|
||||||
import SMSMessageForm from './SMSMessageForm';
|
import SMSMessageForm from './SMSMessageForm';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SMS message dialog content.
|
||||||
|
*/
|
||||||
export default function SMSMessageDialogContent({
|
export default function SMSMessageDialogContent({
|
||||||
// #ownProps
|
// #ownProps
|
||||||
dialogName,
|
dialogName,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ function SMSMessageDialogProvider({ notificationkey, dialogName, ...props }) {
|
|||||||
const { mutateAsync: editSMSNotificationMutate } =
|
const { mutateAsync: editSMSNotificationMutate } =
|
||||||
useSettingEditSMSNotification();
|
useSettingEditSMSNotification();
|
||||||
|
|
||||||
|
// SMS notificiation details
|
||||||
const { data: smsNotification, isLoading: isSMSNotificationLoading } =
|
const { data: smsNotification, isLoading: isSMSNotificationLoading } =
|
||||||
useSettingSMSNotification(notificationkey);
|
useSettingSMSNotification(notificationkey);
|
||||||
|
|
||||||
|
|||||||
@@ -2,24 +2,28 @@ import React from 'react';
|
|||||||
import { Form, useFormikContext } from 'formik';
|
import { Form, useFormikContext } from 'formik';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Classes } from '@blueprintjs/core';
|
import { Classes } from '@blueprintjs/core';
|
||||||
|
import { castArray } from 'lodash';
|
||||||
|
|
||||||
import SMSMessageFormFields from './SMSMessageFormFields';
|
import SMSMessageFormFields from './SMSMessageFormFields';
|
||||||
import SMSMessageFormFloatingActions from './SMSMessageFormFloatingActions';
|
import SMSMessageFormFloatingActions from './SMSMessageFormFloatingActions';
|
||||||
|
|
||||||
|
import { useSMSMessageDialogContext } from './SMSMessageDialogProvider';
|
||||||
import { SMSMessagePreview } from 'components';
|
import { SMSMessagePreview } from 'components';
|
||||||
import { getSMSUnits } from '../../NotifyViaSMS/utils';
|
import { getSMSUnits } from '../../NotifyViaSMS/utils';
|
||||||
|
|
||||||
const messageVariables = [
|
|
||||||
{
|
|
||||||
variable: '{CompanyName}',
|
|
||||||
description: 'References to the current company name.',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMS message form content.
|
* SMS message form content.
|
||||||
*/
|
*/
|
||||||
export default function SMSMessageFormContent() {
|
export default function SMSMessageFormContent() {
|
||||||
|
// SMS message dialog context.
|
||||||
|
const { smsNotification } = useSMSMessageDialogContext();
|
||||||
|
|
||||||
|
// Ensure always returns array.
|
||||||
|
const messageVariables = React.useMemo(
|
||||||
|
() => castArray(smsNotification.allowed_variables),
|
||||||
|
[smsNotification.allowed_variables],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form>
|
<Form>
|
||||||
<div className={Classes.DIALOG_BODY}>
|
<div className={Classes.DIALOG_BODY}>
|
||||||
@@ -30,7 +34,7 @@ export default function SMSMessageFormContent() {
|
|||||||
<SMSMessageVariables>
|
<SMSMessageVariables>
|
||||||
{messageVariables.map(({ variable, description }) => (
|
{messageVariables.map(({ variable, description }) => (
|
||||||
<MessageVariable>
|
<MessageVariable>
|
||||||
<strong>{variable}</strong> {description}
|
<strong>{`{${variable}}`}</strong> {description}
|
||||||
</MessageVariable>
|
</MessageVariable>
|
||||||
))}
|
))}
|
||||||
</SMSMessageVariables>
|
</SMSMessageVariables>
|
||||||
|
|||||||
@@ -30,9 +30,6 @@ function SMSMessageFormFloatingActions({
|
|||||||
return (
|
return (
|
||||||
<div className={Classes.DIALOG_FOOTER}>
|
<div className={Classes.DIALOG_FOOTER}>
|
||||||
<DialogFooterActions alignment={'left'}>
|
<DialogFooterActions alignment={'left'}>
|
||||||
<Button onClick={handleCancelBtnClick} style={{ minWidth: '75px' }}>
|
|
||||||
<T id={'cancel'} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
loading={isSubmitting}
|
loading={isSubmitting}
|
||||||
@@ -41,6 +38,9 @@ function SMSMessageFormFloatingActions({
|
|||||||
>
|
>
|
||||||
Save SMS Message
|
Save SMS Message
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button onClick={handleCancelBtnClick} style={{ minWidth: '75px' }}>
|
||||||
|
<T id={'cancel'} />
|
||||||
|
</Button>
|
||||||
</DialogFooterActions>
|
</DialogFooterActions>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user