Merge branch 'develop' of https://github.com/bigcapitalhq/client into develop

This commit is contained in:
elforjani13
2021-11-11 15:23:52 +02:00
6 changed files with 64 additions and 37 deletions

View File

@@ -27,7 +27,7 @@ export function BalanceSheetAlerts() {
<Icon icon="info-block" iconSize={12} />{' '}
<T id={'just_a_moment_we_re_calculating_your_cost_transactions'} />
<Button onClick={handleRecalcReport} minimal={true} small={true}>
<T id={'refresh'} />
<T id={'report.compute_running.refresh'} />
</Button>
</div>
</If>

View File

@@ -2,7 +2,6 @@ import React from 'react';
import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import { useSettings, useSettingSMSNotifications } from 'hooks/query';
import PreferencesPageLoader from '../PreferencesPageLoader';
const SMSIntegrationContext = React.createContext();
@@ -13,13 +12,17 @@ function SMSIntegrationProvider({ ...props }) {
//Fetches Organization Settings.
const { isLoading: isSettingsLoading } = useSettings();
const { data: notifications, isLoading: isSMSNotificationsLoading } =
useSettingSMSNotifications();
const {
data: notifications,
isLoading: isSMSNotificationsLoading,
isFetching: isSMSNotificationsFetching,
} = useSettingSMSNotifications();
// Provider state.
const provider = {
notifications,
isSMSNotificationsLoading,
isSMSNotificationsFetching,
};
return (

View File

@@ -24,20 +24,24 @@ function SMSMessagesDataTable({
const { mutateAsync: editSMSNotificationMutate } =
useSettingEditSMSNotification();
const toggleSmsNotification = (notificationKey, value) => {
editSMSNotificationMutate({
notification_key: notificationKey,
is_notification_enabled: value,
}).then(() => {
AppToaster.show({
message: intl.get(
'sms_messages.notification_switch_change_success_message',
),
intent: Intent.SUCCESS,
});
});
};
// Handle notification switch change.
const handleNotificationSwitchChange = React.useCallback(
(event, value, notification) => {
editSMSNotificationMutate({
notification_key: notification.key,
is_notification_enabled: value,
}).then(() => {
AppToaster.show({
message: intl.get(
'sms_messages.notification_switch_change_success_message',
),
intent: Intent.SUCCESS,
});
});
toggleSmsNotification(notification.key, value);
},
[editSMSNotificationMutate],
);
@@ -47,28 +51,37 @@ function SMSMessagesDataTable({
onSwitchChange: handleNotificationSwitchChange,
});
const { notifications, isSMSNotificationsLoading } =
useSMSIntegrationContext();
const {
notifications,
isSMSNotificationsLoading,
isSMSNotificationsFetching,
} = useSMSIntegrationContext();
// handle edit message link click
const handleEditMessageText = ({ key }) => {
openDialog('sms-message-form', { notificationkey: key });
};
const handleEnableNotification = () => {};
const handleEnableNotification = (notification) => {
toggleSmsNotification(notification.key, true);
};
const handleDisableNotification = (notification) => {
toggleSmsNotification(notification.key, false);
};
return (
<SMSNotificationsTable
columns={columns}
data={notifications}
loading={isSMSNotificationsLoading}
progressBarLoading={isSMSNotificationsLoading}
progressBarLoading={isSMSNotificationsFetching}
TableLoadingRenderer={TableSkeletonRows}
noInitialFetch={true}
ContextMenu={ActionsMenu}
payload={{
onEditMessageText: handleEditMessageText,
onEnableNotification: handleEnableNotification,
onDisableNotification: handleDisableNotification,
}}
/>
);

View File

@@ -1,10 +1,9 @@
import React from 'react';
import intl from 'react-intl-universal';
import styled from 'styled-components';
import { Intent, Button, Menu, MenuItem } from '@blueprintjs/core';
import { Intent, Button, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
import { SwitchFieldCell } from 'components/DataTableCells';
import { safeInvoke } from 'utils';
/**
@@ -47,19 +46,27 @@ export const SMSMessageCell = ({
* Context menu of SMS notification messages.
*/
export function ActionsMenu({
payload: { onEditMessageText, onEnableNotification },
payload: { onEditMessageText, onEnableNotification, onDisableNotification },
row: { original },
}) {
return (
<Menu>
<MenuItem
text={intl.get('edit_message_text')}
onClick={safeInvoke(onEditMessageText, original)}
/>
<MenuItem
text={intl.get('enable_notification')}
onClick={safeInvoke(onEnableNotification, original)}
text={intl.get('sms_notifications.edit_message_text')}
onClick={() => safeInvoke(onEditMessageText, original)}
/>
<MenuDivider />
{!original.is_notification_enabled ? (
<MenuItem
text={intl.get('sms_notifications.enable_notification')}
onClick={() => safeInvoke(onEnableNotification, original)}
/>
) : (
<MenuItem
text={intl.get('sms_notifications.disable_notification')}
onClick={() => safeInvoke(onDisableNotification, original)}
/>
)}
</Menu>
);
}

View File

@@ -1445,8 +1445,8 @@
"notify_via_sms.dialog.notification_type": "نوع الإشعار",
"notify_via_sms.dialog.notify_via_sms": "إشعار عبر رسائل قصيرة",
"notiify_via_sms.dialog.sms_note": "<strong>ملاحظة :</strong> يمكن أن تحتوي رسالة قصيرة الواحدة على 160 حرفًا كحد أقصى <strong>{value}</strong>. سيتم استخدام وحدات الرسائل القصيرة لإرسال هذا إشعار عبر الرسائل القصيرة. ",
"notify_Via_sms.dialog.customer_phone_number_does_not_eixst": "رقم هاتف العميل غير موجود ، يرجى إدخال رقم هاتف للعميل. ",
"notify_Via_sms.dialog.customer_phone_number_invalid": "رقم هاتف العميل غير صالح ، يرجى إدخال رقم هاتف صحيح للعميل. ",
"notify_Via_sms.dialog.customer_phone_number_does_not_eixst": "رقم هاتف الزبون غير موجود ، يرجى إدخال رقم هاتف للعميل. ",
"notify_Via_sms.dialog.customer_phone_number_invalid": "رقم هاتف الزبون غير صالح ، يرجى إدخال رقم هاتف صحيح للعميل. ",
"notify_via_sms.dialog.phone_invalid_error_message": "لا يمكن إرسال إشعار الرسائل القصيرة ، رقم الهاتف للعميل غير صالح ، يرجى إدخال رقم صالح والمحاولة مرة أخرى.",
"notify_via_sms.dialog.customer_no_phone_error_message": "الزبون ليس لديه رقم هاتف.",
"notify_invoice_via_sms.dialog.success_message": "تم إرسال إشعار فاتورة البيع عبر الرسائل القصيرة بنجاح ",
@@ -1467,9 +1467,11 @@
"sms_message.dialog.success_message": "تم تحديث إعدادات إشعار الرسائل القصيرة بنجاح. ",
"sms_message.dialog.unsupported_variables_error_message": "متغيرات غير مدعومة",
"sms_message.dialog.message_variable_description": "<strong>{value}</strong> إشارة لاسم الشركة الحالي.",
"edit_message_text": "تعديل نص رسالة",
"enable_notification": "تفعيل الإشعارات",
"sms_notifications.edit_message_text": "تعديل نص رسالة",
"sms_notifications.enable_notification": "تفعيل الإشعارات",
"sms_notifications.disable_notification": "تعطيل الإشعارات",
"send_sms": "إرسال رسالة قصيرة",
"save_sms_message": "حفظ رسالة قصيرة",
"sms_message.edit_form.reset_to_default_message": "إعادة التعيين إلى الرسالة الافتراضية."
"sms_message.edit_form.reset_to_default_message": "إعادة التعيين إلى الرسالة الافتراضية.",
"report.compute_running.refresh": "تحديث"
}

View File

@@ -1454,9 +1454,11 @@
"sms_message.dialog.success_message": "Sms notification settings has been updated successfully.",
"sms_message.dialog.unsupported_variables_error_message": "Unsupported variables",
"sms_message.dialog.message_variable_description": "<strong>{value}</strong> References to the current company name.",
"edit_message_text": "Edit message text",
"enable_notification": "Enable notification",
"sms_notifications.edit_message_text": "Edit message text",
"sms_notifications.enable_notification": "Enable notification",
"sms_notifications.disable_notification": "Disable notification",
"send_sms": "Send SMS",
"save_sms_message": "Save SMS Message",
"sms_message.edit_form.reset_to_default_message": "Reset to default message."
"sms_message.edit_form.reset_to_default_message": "Reset to default message.",
"report.compute_running.refresh": "Refresh"
}