From 0d5f5167ef3138ef9b4b37b71e30cc75be938cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Fri, 4 Feb 2022 19:39:35 +0000 Subject: [PATCH 1/4] feat: change custom SMS instances to SMS notices and all its interfaces --- lib/constants.js | 4 +- lib/custom-sms.js | 41 ------- .../graphql/resolvers/sms.resolver.js | 10 +- lib/new-admin/graphql/types/sms.type.js | 18 +-- lib/sms-notices.js | 56 +++++++++ lib/sms.js | 2 +- ...3996603839-change-custom-sms-to-notices.js | 21 ++++ .../CustomSMSModal.js | 37 ++---- .../CustomSMS.js => SMSNotices/SMSNotices.js} | 109 ++++++++---------- .../SMSNotices.styles.js} | 0 .../src/routing/lamassu.routes.js | 2 +- new-lamassu-admin/src/routing/pazuz.routes.js | 2 +- 12 files changed, 153 insertions(+), 149 deletions(-) delete mode 100644 lib/custom-sms.js create mode 100644 lib/sms-notices.js create mode 100644 migrations/1643996603839-change-custom-sms-to-notices.js rename new-lamassu-admin/src/pages/OperatorInfo/{CustomSMS => SMSNotices}/CustomSMSModal.js (80%) rename new-lamassu-admin/src/pages/OperatorInfo/{CustomSMS/CustomSMS.js => SMSNotices/SMSNotices.js} (50%) rename new-lamassu-admin/src/pages/OperatorInfo/{CustomSMS/CustomSMS.styles.js => SMSNotices/SMSNotices.styles.js} (100%) diff --git a/lib/constants.js b/lib/constants.js index 1efcf1d7..c4bc2fbc 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -20,6 +20,7 @@ const MANUAL = 'manual' const CASH_OUT_DISPENSE_READY = 'cash_out_dispense_ready' const CONFIRMATION_CODE = 'sms_code' +const RECEIPT = 'sms_receipt' const WALLET_SCORE_THRESHOLD = 9 @@ -37,5 +38,6 @@ module.exports = { CONFIRMATION_CODE, CASH_OUT_MINIMUM_AMOUNT_OF_CASSETTES, CASH_OUT_MAXIMUM_AMOUNT_OF_CASSETTES, - WALLET_SCORE_THRESHOLD + WALLET_SCORE_THRESHOLD, + RECEIPT } diff --git a/lib/custom-sms.js b/lib/custom-sms.js deleted file mode 100644 index 8cb8546a..00000000 --- a/lib/custom-sms.js +++ /dev/null @@ -1,41 +0,0 @@ -const _ = require('lodash/fp') -const uuid = require('uuid') -const db = require('./db') - -const getCustomMessages = () => { - const sql = `SELECT * FROM custom_messages ORDER BY created` - return db.any(sql).then(res => _.map( - it => ({ - id: it.id, - event: _.camelCase(it.event), - message: it.message - }), res)) -} - -const createCustomMessage = (event, message) => { - const sql = `INSERT INTO custom_messages (id, event, message) VALUES ($1, $2, $3)` - return db.none(sql, [uuid.v4(), _.snakeCase(event), message]) -} - -const editCustomMessage = (id, event, message) => { - const sql = `UPDATE custom_messages SET event=$2, message=$3 WHERE id=$1` - return db.none(sql, [id, _.snakeCase(event), message]) -} - -const deleteCustomMessage = id => { - const sql = `DELETE FROM custom_messages WHERE id=$1` - return db.none(sql, [id]) -} - -const getCustomMessage = event => { - const sql = `SELECT * FROM custom_messages WHERE event=$1 LIMIT 1` - return db.oneOrNone(sql, [event]) -} - -module.exports = { - getCustomMessages, - createCustomMessage, - editCustomMessage, - deleteCustomMessage, - getCustomMessage -} diff --git a/lib/new-admin/graphql/resolvers/sms.resolver.js b/lib/new-admin/graphql/resolvers/sms.resolver.js index f159c8c4..3709395d 100644 --- a/lib/new-admin/graphql/resolvers/sms.resolver.js +++ b/lib/new-admin/graphql/resolvers/sms.resolver.js @@ -1,13 +1,13 @@ -const customSms = require('../../../custom-sms') +const customSms = require('../../../sms-notices') const resolvers = { Query: { - customMessages: () => customSms.getCustomMessages() + SMSNotices: () => customSms.getSMSNotices() }, Mutation: { - createCustomMessage: (...[, { event, message }]) => customSms.createCustomMessage(event, message), - editCustomMessage: (...[, { id, event, message }]) => customSms.editCustomMessage(id, event, message), - deleteCustomMessage: (...[, { id }]) => customSms.deleteCustomMessage(id) + editSMSNotice: (...[, { id, event, message }]) => customSms.editSMSNotice(id, event, message), + enableSMSNotice: (...[, { id }]) => customSms.enableSMSNotice(id), + disableSMSNotice: (...[, { id }]) => customSms.disableSMSNotice(id) } } diff --git a/lib/new-admin/graphql/types/sms.type.js b/lib/new-admin/graphql/types/sms.type.js index a86947b7..b67ec1fa 100644 --- a/lib/new-admin/graphql/types/sms.type.js +++ b/lib/new-admin/graphql/types/sms.type.js @@ -1,25 +1,29 @@ const { gql } = require('apollo-server-express') const typeDef = gql` - type CustomMessage { + type SMSNotice { id: ID! - event: CustomMessageEvent! + event: SMSNoticeEvent! message: String! + messageName: String! + enabled: Boolean! + allowToggle: Boolean! } - enum CustomMessageEvent { + enum SMSNoticeEvent { smsCode cashOutDispenseReady + smsReceipt } type Query { - customMessages: [CustomMessage] @auth + SMSNotices: [SMSNotice] @auth } type Mutation { - createCustomMessage(event: CustomMessageEvent!, message: String!): CustomMessage @auth - editCustomMessage(id: ID!, event: CustomMessageEvent!, message: String!): CustomMessage @auth - deleteCustomMessage(id: ID!): CustomMessage @auth + editSMSNotice(id: ID!, event: SMSNoticeEvent!, message: String!): SMSNotice @auth + enableSMSNotice(id: ID!): SMSNotice @auth + disableSMSNotice(id: ID!): SMSNotice @auth } ` diff --git a/lib/sms-notices.js b/lib/sms-notices.js new file mode 100644 index 00000000..f2235069 --- /dev/null +++ b/lib/sms-notices.js @@ -0,0 +1,56 @@ +const _ = require('lodash/fp') +const uuid = require('uuid') +const db = require('./db') + +const getSMSNotices = () => { + const sql = `SELECT * FROM sms_notices ORDER BY created` + return db.any(sql).then(res => _.map( + it => ({ + id: it.id, + event: _.camelCase(it.event), + message: it.message, + messageName: it.message_name, + enabled: it.enabled, + allowToggle: it.allow_toggle + }), res)) +} + +const createSMSNotice = (event, messageName, message, enabled, allowToggle) => { + const sql = `INSERT INTO sms_notices (id, event, message_name, message${enabled ? `, enabled`: ``}${allowToggle ? `, allowToggle`: ``}) VALUES ($1, $2, $3, $4${enabled ? `, $5`: ``}${allowToggle ? `, $6`: ``})` + return db.none(sql, [uuid.v4(), _.snakeCase(event), messageName, message, enabled, allowToggle]) +} + +const editSMSNotice = (id, event, message) => { + const sql = `UPDATE sms_notices SET event=$2, message=$3 WHERE id=$1` + return db.none(sql, [id, _.snakeCase(event), message]) +} + +const deleteSMSNotice = id => { + const sql = `DELETE FROM sms_notices WHERE id=$1` + return db.none(sql, [id]) +} + +const getSMSNotice = event => { + const sql = `SELECT * FROM sms_notices WHERE event=$1 LIMIT 1` + return db.oneOrNone(sql, [event]) +} + +const enableSMSNotice = id => { + const sql = `UPDATE sms_notices SET enabled = true WHERE id=$1 LIMIT 1` + return db.oneOrNone(sql, [id]) +} + +const disableSMSNotice = id => { + const sql = `UPDATE sms_notices SET enabled = false WHERE id=$1 LIMIT 1` + return db.oneOrNone(sql, [id]) +} + +module.exports = { + getSMSNotices, + createSMSNotice, + editSMSNotice, + deleteSMSNotice, + getSMSNotice, + enableSMSNotice, + disableSMSNotice +} diff --git a/lib/sms.js b/lib/sms.js index 71b691c2..f8d1f18d 100644 --- a/lib/sms.js +++ b/lib/sms.js @@ -3,7 +3,7 @@ const argv = require('minimist')(process.argv.slice(2)) const { utils: coinUtils } = require('lamassu-coins') const _ = require('lodash/fp') -const customSms = require('./custom-sms') +const customSms = require('./sms-notices') const getDefaultMessageContent = content => ({ smsCode: `Your cryptomat code: ${content.code}`, diff --git a/migrations/1643996603839-change-custom-sms-to-notices.js b/migrations/1643996603839-change-custom-sms-to-notices.js new file mode 100644 index 00000000..c2d9ffd3 --- /dev/null +++ b/migrations/1643996603839-change-custom-sms-to-notices.js @@ -0,0 +1,21 @@ +var db = require('./db') +var smsNotices = require('../lib/sms-notices') + +exports.up = function (next) { + var sql = [ + `ALTER TABLE custom_messages RENAME TO sms_notices`, + `ALTER TYPE custom_message_event RENAME TO sms_notice_event`, + `ALTER TYPE sms_notice_event ADD VALUE 'sms_receipt'`, + `ALTER TABLE sms_notices ADD COLUMN message_name TEXT UNIQUE NOT NULL`, + `ALTER TABLE sms_notices ADD COLUMN enabled BOOLEAN NOT NULL DEFAULT true` + `ALTER TABLE sms_notices ADD COLUMN allow_toggle BOOLEAN NOT NULL DEFAULT true` + ] + + db.multi(sql, next) + .then(() => smsNotices.createSMSNotice('sms_code', 'SMS confirmation code', 'Your cryptomat code: #code', true, false)) + .then(() => smsNotices.createSMSNotice('cash_out_dispense_ready', 'Cash is ready', 'Your cash is waiting! Go to the Cryptomat and press Redeem within 24 hours. [#timestamp]', true, false)) +} + +exports.down = function (next) { + next() +} diff --git a/new-lamassu-admin/src/pages/OperatorInfo/CustomSMS/CustomSMSModal.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/CustomSMSModal.js similarity index 80% rename from new-lamassu-admin/src/pages/OperatorInfo/CustomSMS/CustomSMSModal.js rename to new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/CustomSMSModal.js index 7b993021..cf76bb5d 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/CustomSMS/CustomSMSModal.js +++ b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/CustomSMSModal.js @@ -1,15 +1,15 @@ import { makeStyles } from '@material-ui/core' import { Form, Formik, Field } from 'formik' import * as R from 'ramda' -import React, { useState } from 'react' +import React from 'react' import * as Yup from 'yup' import ErrorMessage from 'src/components/ErrorMessage' import Modal from 'src/components/Modal' import { Button } from 'src/components/buttons' -import { Autocomplete, TextInput } from 'src/components/inputs/formik' +import { TextInput } from 'src/components/inputs/formik' -import styles from './CustomSMS.styles' +import styles from './SMSNotices.styles' const useStyles = makeStyles(styles) @@ -58,18 +58,9 @@ const prefill = { } } -const CustomSMSModal = ({ - showModal, - onClose, - sms, - eventOptions, - creationError, - submit -}) => { +const CustomSMSModal = ({ showModal, onClose, sms, creationError, submit }) => { const classes = useStyles() - const [selectedEvent, setSelectedEvent] = useState(sms?.event) - const initialValues = { event: !R.isNil(sms) ? sms.event : '', message: !R.isNil(sms) ? sms.message : '' @@ -78,7 +69,7 @@ const CustomSMSModal = ({ const validationSchema = Yup.object().shape({ event: Yup.string().required('An event is required!'), message: - prefill[selectedEvent]?.validator ?? + prefill[sms?.event]?.validator ?? Yup.string() .required('The message content is required!') .trim() @@ -106,7 +97,7 @@ const CustomSMSModal = ({ <> {showModal && ( {({ values, errors, touched }) => ( -
- + - {!R.isNil(sms) ? `Confirm` : `Create SMS`} + Confirm diff --git a/new-lamassu-admin/src/pages/OperatorInfo/CustomSMS/CustomSMS.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js similarity index 50% rename from new-lamassu-admin/src/pages/OperatorInfo/CustomSMS/CustomSMS.js rename to new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js index b1d3dac0..edbc8ec3 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/CustomSMS/CustomSMS.js +++ b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js @@ -1,65 +1,59 @@ import { useQuery, useMutation } from '@apollo/react-hooks' -import { makeStyles, Box } from '@material-ui/core' +import { makeStyles } from '@material-ui/core' import gql from 'graphql-tag' import * as R from 'ramda' import React, { useState } from 'react' import { DeleteDialog } from 'src/components/DeleteDialog' -import { Link, IconButton } from 'src/components/buttons' +import { IconButton } from 'src/components/buttons' +import { Switch } from 'src/components/inputs' import DataTable from 'src/components/tables/DataTable' import { H4 } from 'src/components/typography' -import { ReactComponent as DeleteIcon } from 'src/styling/icons/action/delete/enabled.svg' import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg' -import styles from './CustomSMS.styles' import CustomSMSModal from './CustomSMSModal' +import styles from './SMSNotices.styles' const useStyles = makeStyles(styles) -const GET_CUSTOM_MESSAGES = gql` - query customMessages { - customMessages { +const GET_SMS_NOTICES = gql` + query SMSNotices { + SMSNotices { id event message + messageName + enabled + allowToggle } } ` -const CREATE_CUSTOM_MESSAGE = gql` - mutation createCustomMessage($event: CustomMessageEvent!, $message: String!) { - createCustomMessage(event: $event, message: $message) { +const EDIT_SMS_NOTICE = gql` + mutation editSMSNotice($id: ID!, $event: SMSNoticeEvent!, $message: String!) { + editSMSNotice(id: $id, event: $event, message: $message) { id } } ` -const EDIT_CUSTOM_MESSAGE = gql` - mutation editCustomMessage( - $id: ID! - $event: CustomMessageEvent! - $message: String! - ) { - editCustomMessage(id: $id, event: $event, message: $message) { +const ENABLE_SMS_NOTICE = gql` + mutation enableSMSNotice($id: ID!) { + enableSMSNotice(id: $id) { id } } ` -const DELETE_CUSTOM_MESSAGE = gql` - mutation deleteCustomMessage($id: ID!) { - deleteCustomMessage(id: $id) { +const DISABLE_SMS_NOTICE = gql` + mutation disableSMSNotice($id: ID!) { + disableSMSNotice(id: $id) { id } } ` -const EVENT_OPTIONS = [ - { code: 'smsCode', display: 'On SMS confirmation code' }, - { code: 'cashOutDispenseReady', display: 'Cash out dispense ready' } -] - -const CustomSMS = () => { +const SMSNotices = () => { const classes = useStyles() const [deleteDialog, setDeleteDialog] = useState(false) @@ -68,22 +62,22 @@ const CustomSMS = () => { const [errorMsg, setErrorMsg] = useState('') const { data: messagesData, loading: messagesLoading } = useQuery( - GET_CUSTOM_MESSAGES + GET_SMS_NOTICES ) - const [createMessage] = useMutation(CREATE_CUSTOM_MESSAGE, { + const [editMessage] = useMutation(EDIT_SMS_NOTICE, { onError: ({ msg }) => setErrorMsg(msg), - refetchQueries: () => ['customMessages'] + refetchQueries: () => ['SMSNotices'] }) - const [editMessage] = useMutation(EDIT_CUSTOM_MESSAGE, { + const [enableMessage] = useMutation(ENABLE_SMS_NOTICE, { onError: ({ msg }) => setErrorMsg(msg), - refetchQueries: () => ['customMessages'] + refetchQueries: () => ['SMSNotices'] }) - const [deleteMessage] = useMutation(DELETE_CUSTOM_MESSAGE, { + const [disableMessage] = useMutation(DISABLE_SMS_NOTICE, { onError: ({ msg }) => setErrorMsg(msg), - refetchQueries: () => ['customMessages'] + refetchQueries: () => ['SMSNotices'] }) const loading = messagesLoading @@ -94,19 +88,15 @@ const CustomSMS = () => { setDeleteDialog(false) } - const handleOpen = () => { - setErrorMsg('') - setShowModal(true) - } + console.log(messagesData) const elements = [ { - header: 'Event', - width: 600, + header: 'Message name', + width: 500, size: 'sm', textAlign: 'left', - view: it => - R.find(ite => R.propEq('event', ite.code, it), EVENT_OPTIONS).display + view: it => R.prop('messageName', it) }, { header: 'Edit', @@ -124,18 +114,20 @@ const CustomSMS = () => { ) }, { - header: 'Delete', + header: 'Enable', width: 100, size: 'sm', textAlign: 'center', view: it => ( - { - setSelectedSMS(it) - setDeleteDialog(true) - }}> - - + it.enabled + ? disableMessage({ variables: { id: it.id } }) + : enableMessage({ variables: { id: it.id } }) + }} + checked={it.enabled} + /> ) } ] @@ -143,21 +135,15 @@ const CustomSMS = () => { return ( <>
-

Custom SMS message

- - handleOpen()}> - Add custom SMS - - +

SMS Notices

{showModal && ( )} { }} onConfirmed={() => { handleClose() - deleteMessage({ - variables: { - id: selectedSMS.id - } - }) }} errorMessage={errorMsg} /> ) } -export default CustomSMS +export default SMSNotices diff --git a/new-lamassu-admin/src/pages/OperatorInfo/CustomSMS/CustomSMS.styles.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js similarity index 100% rename from new-lamassu-admin/src/pages/OperatorInfo/CustomSMS/CustomSMS.styles.js rename to new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js diff --git a/new-lamassu-admin/src/routing/lamassu.routes.js b/new-lamassu-admin/src/routing/lamassu.routes.js index e647c65b..7573c955 100644 --- a/new-lamassu-admin/src/routing/lamassu.routes.js +++ b/new-lamassu-admin/src/routing/lamassu.routes.js @@ -16,8 +16,8 @@ import MachineStatus from 'src/pages/Maintenance/MachineStatus' import Notifications from 'src/pages/Notifications/Notifications' import CoinAtmRadar from 'src/pages/OperatorInfo/CoinATMRadar' import ContactInfo from 'src/pages/OperatorInfo/ContactInfo' -import CustomSMS from 'src/pages/OperatorInfo/CustomSMS/CustomSMS' import ReceiptPrinting from 'src/pages/OperatorInfo/ReceiptPrinting' +import CustomSMS from 'src/pages/OperatorInfo/SMSNotices/SMSNotices' import TermsConditions from 'src/pages/OperatorInfo/TermsConditions' import ServerLogs from 'src/pages/ServerLogs' import Services from 'src/pages/Services/Services' diff --git a/new-lamassu-admin/src/routing/pazuz.routes.js b/new-lamassu-admin/src/routing/pazuz.routes.js index 153d0205..301c8fa9 100644 --- a/new-lamassu-admin/src/routing/pazuz.routes.js +++ b/new-lamassu-admin/src/routing/pazuz.routes.js @@ -19,8 +19,8 @@ import MachineStatus from 'src/pages/Maintenance/MachineStatus' import Notifications from 'src/pages/Notifications/Notifications' import CoinAtmRadar from 'src/pages/OperatorInfo/CoinATMRadar' import ContactInfo from 'src/pages/OperatorInfo/ContactInfo' -import CustomSMS from 'src/pages/OperatorInfo/CustomSMS/CustomSMS' import ReceiptPrinting from 'src/pages/OperatorInfo/ReceiptPrinting' +import CustomSMS from 'src/pages/OperatorInfo/SMSNotices/SMSNotices' import TermsConditions from 'src/pages/OperatorInfo/TermsConditions' import ServerLogs from 'src/pages/ServerLogs' import Services from 'src/pages/Services/Services' From 91e209b6ab13de25a4ab29d41b38843be888c80c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Wed, 9 Feb 2022 15:09:31 +0000 Subject: [PATCH 2/4] feat: add SMS preview component --- .../OperatorInfo/SMSNotices/SMSNotices.js | 69 +++++++++++++++++-- .../SMSNotices/SMSNotices.styles.js | 29 ++++++++ .../{CustomSMSModal.js => SMSNoticesModal.js} | 67 ++++++++++++------ .../src/routing/lamassu.routes.js | 10 +-- new-lamassu-admin/src/routing/pazuz.routes.js | 10 +-- .../src/styling/icons/menu/logo-white.svg | 20 ++++++ 6 files changed, 169 insertions(+), 36 deletions(-) rename new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/{CustomSMSModal.js => SMSNoticesModal.js} (68%) create mode 100644 new-lamassu-admin/src/styling/icons/menu/logo-white.svg diff --git a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js index edbc8ec3..2692a471 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js +++ b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js @@ -1,5 +1,6 @@ import { useQuery, useMutation } from '@apollo/react-hooks' -import { makeStyles } from '@material-ui/core' +import { makeStyles, Paper } from '@material-ui/core' +import { format } from 'date-fns/fp' import gql from 'graphql-tag' import * as R from 'ramda' import React, { useState } from 'react' @@ -8,11 +9,12 @@ import { DeleteDialog } from 'src/components/DeleteDialog' import { IconButton } from 'src/components/buttons' import { Switch } from 'src/components/inputs' import DataTable from 'src/components/tables/DataTable' -import { H4 } from 'src/components/typography' +import { H4, P, Label3 } from 'src/components/typography' import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg' +import { ReactComponent as WhiteLogo } from 'src/styling/icons/menu/logo-white.svg' -import CustomSMSModal from './CustomSMSModal' import styles from './SMSNotices.styles' +import CustomSMSModal from './SMSNoticesModal' const useStyles = makeStyles(styles) @@ -53,12 +55,45 @@ const DISABLE_SMS_NOTICE = gql` } ` +const multiReplace = (str, obj) => { + var re = new RegExp(Object.keys(obj).join('|'), 'gi') + + return str.replace(re, function(matched) { + return obj[matched.toLowerCase()] + }) +} + +const SMSPreview = ({ sms, coords }) => { + const classes = useStyles(coords) + + const matches = { + '#code': 123, + '#timestamp': format('HH:mm', new Date()) + } + + return ( +
+
+
+ +
+ +

{multiReplace(sms?.message, matches)}

+
+ {format('HH:mm', new Date())} +
+
+ ) +} + const SMSNotices = () => { const classes = useStyles() const [deleteDialog, setDeleteDialog] = useState(false) const [showModal, setShowModal] = useState(false) const [selectedSMS, setSelectedSMS] = useState(null) + const [previewOpen, setPreviewOpen] = useState(false) + const [previewCoords, setPreviewCoords] = useState({ x: 0, y: 0 }) const [errorMsg, setErrorMsg] = useState('') const { data: messagesData, loading: messagesLoading } = useQuery( @@ -88,8 +123,6 @@ const SMSNotices = () => { setDeleteDialog(false) } - console.log(messagesData) - const elements = [ { header: 'Message name', @@ -106,6 +139,7 @@ const SMSNotices = () => { view: it => ( { + setPreviewOpen(false) setSelectedSMS(it) setShowModal(true) }}> @@ -129,13 +163,35 @@ const SMSNotices = () => { checked={it.enabled} /> ) + }, + { + header: '', + width: 100, + size: 'sm', + textAlign: 'center', + view: it => ( + { + setSelectedSMS(it) + setPreviewCoords({ + x: e.currentTarget.getBoundingClientRect().right + 50, + y: + window.innerHeight - + 5 - + e.currentTarget.getBoundingClientRect().bottom + }) + setPreviewOpen(true) + }}> + + + ) } ] return ( <>
-

SMS Notices

+

SMS notices

{showModal && ( { }} errorMessage={errorMsg} /> + {previewOpen && } x, + bottom: ({ y }) => y, + width: 350, + overflow: 'visible' + }, + smsPreviewContainer: { + display: 'flex', + flexDirection: 'row', + alignItems: 'flex-end', + '& > *': { + marginRight: 10 + } + }, + smsPreviewIcon: { + display: 'flex', + width: 36, + height: 36, + borderRadius: 18, + backgroundColor: '#16D6D3', + alignItems: 'center', + justifyContent: 'center' + }, + smsPreviewContent: { + width: 225, + padding: 15, + borderRadius: '15px 15px 15px 0px' } } diff --git a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/CustomSMSModal.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.js similarity index 68% rename from new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/CustomSMSModal.js rename to new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.js index cf76bb5d..a5f17d9c 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/CustomSMSModal.js +++ b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.js @@ -1,4 +1,4 @@ -import { makeStyles } from '@material-ui/core' +import { makeStyles, Chip } from '@material-ui/core' import { Form, Formik, Field } from 'formik' import * as R from 'ramda' import React from 'react' @@ -27,14 +27,14 @@ const prefill = { .required('The message content is required!') .trim() .test({ - name: 'has-code-tag', - message: 'A #code tag is missing from the message!', + name: 'has-code', + message: 'The confirmation code is missing from the message!', exclusive: false, test: value => value?.match(/#code/g || [])?.length > 0 }) .test({ - name: 'has-single-code-tag', - message: 'There should be a single #code tag!', + name: 'has-single-code', + message: 'There should be a single confirmation code!', exclusive: false, test: value => value?.match(/#code/g || [])?.length === 1 }) @@ -43,22 +43,33 @@ const prefill = { validator: Yup.string() .required('The message content is required!') .trim() - .test({ - name: 'has-timestamp-tag', - message: 'A #timestamp tag is missing from the message!', - exclusive: false, - test: value => value?.match(/#timestamp/g || [])?.length > 0 - }) - .test({ - name: 'has-single-timestamp-tag', - message: 'There should be a single #timestamp tag!', - exclusive: false, - test: value => value?.match(/#timestamp/g || [])?.length === 1 - }) + // .test({ + // name: 'has-timestamp-tag', + // message: 'A #timestamp tag is missing from the message!', + // exclusive: false, + // test: value => value?.match(/#timestamp/g || [])?.length > 0 + // }) + // .test({ + // name: 'has-single-timestamp-tag', + // message: 'There should be a single #timestamp tag!', + // exclusive: false, + // test: value => value?.match(/#timestamp/g || [])?.length === 1 + // }) } } -const CustomSMSModal = ({ showModal, onClose, sms, creationError, submit }) => { +const chips = { + smsCode: [{ code: '#code', display: 'Confirmation code', removable: false }], + cashOutDispenseReady: [] +} + +const SMSNoticesModal = ({ + showModal, + onClose, + sms, + creationError, + submit +}) => { const classes = useStyles() const initialValues = { @@ -111,7 +122,7 @@ const CustomSMSModal = ({ showModal, onClose, sms, creationError, submit }) => { onSubmit={(values, errors, touched) => handleSubmit(values, errors, touched) }> - {({ values, errors, touched }) => ( + {({ values, errors, touched, setFieldValue }) => (
{ rows={6} component={TextInput} /> + {R.map( + it => ( + { + R.includes(it.code, values.message) + ? setFieldValue('message', values.message) + : setFieldValue( + 'message', + values.message.concat(' ', it.code, ' ') + ) + }} + /> + ), + chips[sms?.event] + )}
{getErrorMsg(errors, touched, creationError) && ( @@ -143,4 +170,4 @@ const CustomSMSModal = ({ showModal, onClose, sms, creationError, submit }) => { ) } -export default CustomSMSModal +export default SMSNoticesModal diff --git a/new-lamassu-admin/src/routing/lamassu.routes.js b/new-lamassu-admin/src/routing/lamassu.routes.js index 7573c955..e33d690c 100644 --- a/new-lamassu-admin/src/routing/lamassu.routes.js +++ b/new-lamassu-admin/src/routing/lamassu.routes.js @@ -17,7 +17,7 @@ import Notifications from 'src/pages/Notifications/Notifications' import CoinAtmRadar from 'src/pages/OperatorInfo/CoinATMRadar' import ContactInfo from 'src/pages/OperatorInfo/ContactInfo' import ReceiptPrinting from 'src/pages/OperatorInfo/ReceiptPrinting' -import CustomSMS from 'src/pages/OperatorInfo/SMSNotices/SMSNotices' +import SMSNotices from 'src/pages/OperatorInfo/SMSNotices/SMSNotices' import TermsConditions from 'src/pages/OperatorInfo/TermsConditions' import ServerLogs from 'src/pages/ServerLogs' import Services from 'src/pages/Services/Services' @@ -174,11 +174,11 @@ const getLamassuRoutes = () => [ component: ReceiptPrinting }, { - key: 'custom-sms', - label: 'Custom SMS', - route: '/settings/operator-info/custom-sms', + key: 'sms-notices', + label: 'SMS notices', + route: '/settings/operator-info/sms-notices', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], - component: CustomSMS + component: SMSNotices }, { key: 'coin-atm-radar', diff --git a/new-lamassu-admin/src/routing/pazuz.routes.js b/new-lamassu-admin/src/routing/pazuz.routes.js index 301c8fa9..8789a1d1 100644 --- a/new-lamassu-admin/src/routing/pazuz.routes.js +++ b/new-lamassu-admin/src/routing/pazuz.routes.js @@ -20,7 +20,7 @@ import Notifications from 'src/pages/Notifications/Notifications' import CoinAtmRadar from 'src/pages/OperatorInfo/CoinATMRadar' import ContactInfo from 'src/pages/OperatorInfo/ContactInfo' import ReceiptPrinting from 'src/pages/OperatorInfo/ReceiptPrinting' -import CustomSMS from 'src/pages/OperatorInfo/SMSNotices/SMSNotices' +import SMSNotices from 'src/pages/OperatorInfo/SMSNotices/SMSNotices' import TermsConditions from 'src/pages/OperatorInfo/TermsConditions' import ServerLogs from 'src/pages/ServerLogs' import Services from 'src/pages/Services/Services' @@ -169,11 +169,11 @@ const getPazuzRoutes = () => [ component: ReceiptPrinting }, { - key: 'custom-sms', - label: 'Custom SMS', - route: '/settings/operator-info/custom-sms', + key: 'sms-notices', + label: 'SMS notices', + route: '/settings/operator-info/sms-notices', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], - component: CustomSMS + component: SMSNotices }, { key: 'coin-atm-radar', diff --git a/new-lamassu-admin/src/styling/icons/menu/logo-white.svg b/new-lamassu-admin/src/styling/icons/menu/logo-white.svg new file mode 100644 index 00000000..7de68c79 --- /dev/null +++ b/new-lamassu-admin/src/styling/icons/menu/logo-white.svg @@ -0,0 +1,20 @@ + + + + Created with Sketch. + + + + + + + + + \ No newline at end of file From cd01d894a3ac35a06c20594cfb8296561ca5360c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Thu, 10 Feb 2022 00:36:32 +0000 Subject: [PATCH 3/4] feat: add sms preview feat: add reset to default button feat: add attachable values feat: connect the sms receipt notice to the sms receipt request --- .../graphql/resolvers/sms.resolver.js | 10 +- lib/plugins.js | 3 +- lib/plugins/wallet/mock-wallet/mock-wallet.js | 2 +- lib/routes/customerRoutes.js | 2 +- lib/sms-notices.js | 4 +- lib/sms.js | 35 +++--- ...3996603839-change-custom-sms-to-notices.js | 1 + .../OperatorInfo/SMSNotices/SMSNotices.js | 55 ++++++++- .../SMSNotices/SMSNotices.styles.js | 39 ++++++- .../SMSNotices/SMSNoticesModal.js | 104 ++++++++++++------ 10 files changed, 186 insertions(+), 69 deletions(-) diff --git a/lib/new-admin/graphql/resolvers/sms.resolver.js b/lib/new-admin/graphql/resolvers/sms.resolver.js index 3709395d..8098837b 100644 --- a/lib/new-admin/graphql/resolvers/sms.resolver.js +++ b/lib/new-admin/graphql/resolvers/sms.resolver.js @@ -1,13 +1,13 @@ -const customSms = require('../../../sms-notices') +const smsNotices = require('../../../sms-notices') const resolvers = { Query: { - SMSNotices: () => customSms.getSMSNotices() + SMSNotices: () => smsNotices.getSMSNotices() }, Mutation: { - editSMSNotice: (...[, { id, event, message }]) => customSms.editSMSNotice(id, event, message), - enableSMSNotice: (...[, { id }]) => customSms.enableSMSNotice(id), - disableSMSNotice: (...[, { id }]) => customSms.disableSMSNotice(id) + editSMSNotice: (...[, { id, event, message }]) => smsNotices.editSMSNotice(id, event, message), + enableSMSNotice: (...[, { id }]) => smsNotices.enableSMSNotice(id), + disableSMSNotice: (...[, { id }]) => smsNotices.disableSMSNotice(id) } } diff --git a/lib/plugins.js b/lib/plugins.js index 9e367387..7603bbb4 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -772,7 +772,8 @@ function plugins (settings, deviceId) { ? '123' : randomCode() - return sms.getSms(CONFIRMATION_CODE, phone, { code }) + const timestamp = dateFormat(new Date(), 'UTC:HH:MM Z') + return sms.getSms(CONFIRMATION_CODE, phone, { code, timestamp }) .then(smsObj => { const rec = { sms: smsObj diff --git a/lib/plugins/wallet/mock-wallet/mock-wallet.js b/lib/plugins/wallet/mock-wallet/mock-wallet.js index 5ffc88e1..5f566446 100644 --- a/lib/plugins/wallet/mock-wallet/mock-wallet.js +++ b/lib/plugins/wallet/mock-wallet/mock-wallet.js @@ -9,7 +9,7 @@ const NAME = 'FakeWallet' const SECONDS = 1000 const PUBLISH_TIME = 3 * SECONDS const AUTHORIZE_TIME = PUBLISH_TIME + 5 * SECONDS -const CONFIRM_TIME = AUTHORIZE_TIME + 120 * SECONDS +const CONFIRM_TIME = AUTHORIZE_TIME + 10 * SECONDS let t0 diff --git a/lib/routes/customerRoutes.js b/lib/routes/customerRoutes.js index 8b0e51d6..72d64a9a 100644 --- a/lib/routes/customerRoutes.js +++ b/lib/routes/customerRoutes.js @@ -190,6 +190,6 @@ router.patch('/:id/block', triggerBlock) router.patch('/:id/suspend', triggerSuspend) router.patch('/:id/photos/idcarddata', updateIdCardData) router.patch('/:id/:txId/photos/customerphoto', updateTxCustomerPhoto) -router.patch('/:id/smsreceipt', sendSmsReceipt) +router.post('/:id/smsreceipt', sendSmsReceipt) module.exports = router diff --git a/lib/sms-notices.js b/lib/sms-notices.js index f2235069..ac2b86fd 100644 --- a/lib/sms-notices.js +++ b/lib/sms-notices.js @@ -36,12 +36,12 @@ const getSMSNotice = event => { } const enableSMSNotice = id => { - const sql = `UPDATE sms_notices SET enabled = true WHERE id=$1 LIMIT 1` + const sql = `UPDATE sms_notices SET enabled = true WHERE id=$1` return db.oneOrNone(sql, [id]) } const disableSMSNotice = id => { - const sql = `UPDATE sms_notices SET enabled = false WHERE id=$1 LIMIT 1` + const sql = `UPDATE sms_notices SET enabled = false WHERE id=$1` return db.oneOrNone(sql, [id]) } diff --git a/lib/sms.js b/lib/sms.js index f8d1f18d..424df961 100644 --- a/lib/sms.js +++ b/lib/sms.js @@ -1,17 +1,16 @@ + +const dateFormat = require('dateformat') + const ph = require('./plugin-helper') const argv = require('minimist')(process.argv.slice(2)) const { utils: coinUtils } = require('lamassu-coins') const _ = require('lodash/fp') -const customSms = require('./sms-notices') - -const getDefaultMessageContent = content => ({ - smsCode: `Your cryptomat code: ${content.code}`, - cashOutDispenseReady: `Your cash is waiting! Go to the Cryptomat and press Redeem within 24 hours. [${content.timestamp}]` -}) +const smsNotices = require('./sms-notices') +const { RECEIPT } = require('./constants') function getSms (event, phone, content) { - return customSms.getCustomMessage(event) + return smsNotices.getSMSNotice(event) .then(msg => { if (!_.isNil(msg)) { var accMsg = msg.message @@ -22,11 +21,6 @@ function getSms (event, phone, content) { body: messageContent } } - - return { - toNumber: phone, - body: getDefaultMessageContent(content)[_.camelCase(event)] - } }) } @@ -110,13 +104,16 @@ function formatSmsReceipt (data, options) { message = message.concat(`Address: ${data.address}\n`) } - const request = { - sms: { - toNumber: data.customerPhone, - body: message - } - } - return request + const timestamp = dateFormat(new Date(), 'UTC:HH:MM Z') + const postReceiptSmsPromise = getSms(RECEIPT, data.customerPhone, { timestamp }) + + return Promise.all([smsNotices.getSMSNotice(RECEIPT), postReceiptSmsPromise]) + .then(([res, postReceiptSms]) => ({ + sms: { + toNumber: data.customerPhone, + body: res.enabled ? message.concat('\n\n', postReceiptSms.body) : message + } + })) } module.exports = { diff --git a/migrations/1643996603839-change-custom-sms-to-notices.js b/migrations/1643996603839-change-custom-sms-to-notices.js index c2d9ffd3..9d1313d9 100644 --- a/migrations/1643996603839-change-custom-sms-to-notices.js +++ b/migrations/1643996603839-change-custom-sms-to-notices.js @@ -14,6 +14,7 @@ exports.up = function (next) { db.multi(sql, next) .then(() => smsNotices.createSMSNotice('sms_code', 'SMS confirmation code', 'Your cryptomat code: #code', true, false)) .then(() => smsNotices.createSMSNotice('cash_out_dispense_ready', 'Cash is ready', 'Your cash is waiting! Go to the Cryptomat and press Redeem within 24 hours. [#timestamp]', true, false)) + .then(() => smsNotices.createSMSNotice('sms_receipt', 'SMS receipt', '', true, true)) } exports.down = function (next) { diff --git a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js index 2692a471..3e56aae1 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js +++ b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js @@ -6,11 +6,14 @@ import * as R from 'ramda' import React, { useState } from 'react' import { DeleteDialog } from 'src/components/DeleteDialog' +import { HoverableTooltip } from 'src/components/Tooltip' import { IconButton } from 'src/components/buttons' import { Switch } from 'src/components/inputs' import DataTable from 'src/components/tables/DataTable' import { H4, P, Label3 } from 'src/components/typography' import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg' +import { ReactComponent as ExpandIconClosed } from 'src/styling/icons/action/expand/closed.svg' +import { ReactComponent as ExpandIconOpen } from 'src/styling/icons/action/expand/open.svg' import { ReactComponent as WhiteLogo } from 'src/styling/icons/menu/logo-white.svg' import styles from './SMSNotices.styles' @@ -63,6 +66,26 @@ const multiReplace = (str, obj) => { }) } +const formatContent = content => { + const fragments = R.split(/\n/)(content) + return R.map((it, idx) => { + if (idx === fragments.length) return <>{it} + return ( + <> + {it} +
+ + ) + }, fragments) +} + +const TOOLTIPS = { + smsCode: ``, + cashOutDispenseReady: ``, + smsReceipt: formatContent(`The contents of this notice will be appended to the end of the SMS receipt sent, and not replace it.\n + To edit the contents of the SMS receipt, please go to the 'Receipt' tab`) +} + const SMSPreview = ({ sms, coords }) => { const classes = useStyles(coords) @@ -78,7 +101,13 @@ const SMSPreview = ({ sms, coords }) => {
-

{multiReplace(sms?.message, matches)}

+

+ {R.isEmpty(sms?.message) ? ( + No content available + ) : ( + formatContent(multiReplace(sms?.message, matches)) + )} +

{format('HH:mm', new Date())} @@ -118,8 +147,8 @@ const SMSNotices = () => { const loading = messagesLoading const handleClose = () => { - setSelectedSMS(null) setShowModal(false) + setSelectedSMS(null) setDeleteDialog(false) } @@ -129,7 +158,17 @@ const SMSNotices = () => { width: 500, size: 'sm', textAlign: 'left', - view: it => R.prop('messageName', it) + view: it => + !R.isEmpty(TOOLTIPS[it.event]) ? ( +
+ {R.prop('messageName', it)} + +

{TOOLTIPS[it.event]}

+
+
+ ) : ( + R.prop('messageName', it) + ) }, { header: 'Edit', @@ -180,9 +219,15 @@ const SMSNotices = () => { 5 - e.currentTarget.getBoundingClientRect().bottom }) - setPreviewOpen(true) + R.equals(selectedSMS, it) + ? setPreviewOpen(!previewOpen) + : setPreviewOpen(true) }}> - + {R.equals(selectedSMS, it) && previewOpen ? ( + + ) : ( + + )} ) } diff --git a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js index 39d192b9..65e39737 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js +++ b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js @@ -1,4 +1,9 @@ -import { spacer } from 'src/styling/variables' +import { + spacer, + fontMonospaced, + fontSize5, + fontColor +} from 'src/styling/variables' const styles = { header: { @@ -52,6 +57,38 @@ const styles = { width: 225, padding: 15, borderRadius: '15px 15px 15px 0px' + }, + chipButtons: { + width: 480, + display: 'flex', + flexDirection: 'column', + alignItems: 'space-between', + '& > div': { + marginTop: 15 + }, + '& > div:first-child': { + marginTop: 0 + }, + '& > div > div': { + margin: [[0, 5, 0, 5]] + }, + '& > div > div > span': { + lineHeight: '120%', + color: fontColor, + fontSize: fontSize5, + fontFamily: fontMonospaced, + fontWeight: 500 + }, + marginLeft: 'auto', + marginRight: 'auto' + }, + resetToDefault: { + width: 145 + }, + messageWithTooltip: { + display: 'flex', + flexDirection: 'row', + alignItems: 'center' } } diff --git a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.js index a5f17d9c..f6885bf2 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.js +++ b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.js @@ -6,8 +6,12 @@ import * as Yup from 'yup' import ErrorMessage from 'src/components/ErrorMessage' import Modal from 'src/components/Modal' -import { Button } from 'src/components/buttons' +import { ActionButton, Button } from 'src/components/buttons' import { TextInput } from 'src/components/inputs/formik' +import { Info2 } from 'src/components/typography' +import { ReactComponent as DefaultIconReverse } from 'src/styling/icons/button/retry/white.svg' +import { ReactComponent as DefaultIcon } from 'src/styling/icons/button/retry/zodiac.svg' +import { zircon } from 'src/styling/variables' import styles from './SMSNotices.styles' @@ -21,7 +25,7 @@ const getErrorMsg = (formikErrors, formikTouched, mutationError) => { return null } -const prefill = { +const PREFILL = { smsCode: { validator: Yup.string() .required('The message content is required!') @@ -43,24 +47,28 @@ const prefill = { validator: Yup.string() .required('The message content is required!') .trim() - // .test({ - // name: 'has-timestamp-tag', - // message: 'A #timestamp tag is missing from the message!', - // exclusive: false, - // test: value => value?.match(/#timestamp/g || [])?.length > 0 - // }) - // .test({ - // name: 'has-single-timestamp-tag', - // message: 'There should be a single #timestamp tag!', - // exclusive: false, - // test: value => value?.match(/#timestamp/g || [])?.length === 1 - // }) + }, + smsReceipt: { + validator: Yup.string().trim() } } -const chips = { - smsCode: [{ code: '#code', display: 'Confirmation code', removable: false }], - cashOutDispenseReady: [] +const CHIPS = { + smsCode: [ + { code: '#code', display: 'Confirmation code', obligatory: true }, + { code: '#timestamp', display: 'Timestamp', obligatory: false } + ], + cashOutDispenseReady: [ + { code: '#timestamp', display: 'Timestamp', obligatory: false } + ], + smsReceipt: [{ code: '#timestamp', display: 'Timestamp', obligatory: false }] +} + +const DEFAULT_MESSAGES = { + smsCode: 'Your cryptomat code: #code', + cashOutDispenseReady: + 'Your cash is waiting! Go to the Cryptomat and press Redeem within 24 hours. [#timestamp]', + smsReceipt: '' } const SMSNoticesModal = ({ @@ -80,7 +88,7 @@ const SMSNoticesModal = ({ const validationSchema = Yup.object().shape({ event: Yup.string().required('An event is required!'), message: - prefill[sms?.event]?.validator ?? + PREFILL[sms?.event]?.validator ?? Yup.string() .required('The message content is required!') .trim() @@ -108,7 +116,7 @@ const SMSNoticesModal = ({ <> {showModal && ( {({ values, errors, touched, setFieldValue }) => ( + + setFieldValue('message', DEFAULT_MESSAGES[sms?.event]) + }> + Reset to default + - {R.map( - it => ( - { - R.includes(it.code, values.message) - ? setFieldValue('message', values.message) - : setFieldValue( - 'message', - values.message.concat(' ', it.code, ' ') - ) - }} - /> - ), - chips[sms?.event] + {R.length(CHIPS[sms?.event]) > 0 && ( + Values to attach )} +
+ {R.map( + it => ( +
+ {R.map( + ite => ( + { + setFieldValue( + 'message', + values.message.concat( + R.last(values.message) === ' ' ? '' : ' ', + ite.code + ) + ) + }} + /> + ), + it + )} +
+ ), + R.splitEvery(3, CHIPS[sms?.event]) + )} +
{getErrorMsg(errors, touched, creationError) && ( From ec377cd0b9b36c2851ae3a044743fed55ec9b165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Tue, 15 Feb 2022 15:42:18 +0000 Subject: [PATCH 4/4] fix: remove SMS deletion modal --- .../src/pages/OperatorInfo/SMSNotices/SMSNotices.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js index 3e56aae1..4a1bb469 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js +++ b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.js @@ -5,7 +5,6 @@ import gql from 'graphql-tag' import * as R from 'ramda' import React, { useState } from 'react' -import { DeleteDialog } from 'src/components/DeleteDialog' import { HoverableTooltip } from 'src/components/Tooltip' import { IconButton } from 'src/components/buttons' import { Switch } from 'src/components/inputs' @@ -118,7 +117,6 @@ const SMSPreview = ({ sms, coords }) => { const SMSNotices = () => { const classes = useStyles() - const [deleteDialog, setDeleteDialog] = useState(false) const [showModal, setShowModal] = useState(false) const [selectedSMS, setSelectedSMS] = useState(null) const [previewOpen, setPreviewOpen] = useState(false) @@ -149,7 +147,6 @@ const SMSNotices = () => { const handleClose = () => { setShowModal(false) setSelectedSMS(null) - setDeleteDialog(false) } const elements = [ @@ -247,16 +244,6 @@ const SMSNotices = () => { submit={editMessage} /> )} - { - handleClose() - }} - onConfirmed={() => { - handleClose() - }} - errorMessage={errorMsg} - /> {previewOpen && }