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 }) => (