prettier formatting

This commit is contained in:
erik-sn committed 2020-11-21 00:37:13 -05:00
1 parent 9363032c42
commit be5c038128
19 files changed
+294 -238

No files matched your search

@@ -1,23 +1,25 @@
import React, { FormEvent, useState } from 'react'
import { useTranslation } from 'react-i18next';
import { TextField, Button } from '@material-ui/core'
import AddIcon from '@material-ui/icons/Add';
import React, { FormEvent, useState } from "react";
import { useTranslation } from "react-i18next";
import { TextField, Button } from "@material-ui/core";
import AddIcon from "@material-ui/icons/Add";
import useStyles from './form.styles';
import useModals from '../../hooks/useModals';
import Nui from '../../../../os/nui-events/utils/Nui';
import useStyles from "./form.styles";
import useModals from "../../hooks/useModals";
import Nui from "../../../../os/nui-events/utils/Nui";
const NewMessageGroupForm = () => {
const classes = useStyles();
const { t } = useTranslation();
const { setShowNewMessageGroup } = useModals();
const [ participants, setParticipants ] = useState('');
const [ label, setLabel ] = useState('');
const [participants, setParticipants] = useState("");
const [label, setLabel] = useState("");
// handles phone numbers in a csv format and strips all spaces and
// external characters out of them:
// 123-4567, 987-6543, 333-4444
const parts = participants.split(',').map(part => part.replace(/[^0-9]/g, ''));
const parts = participants
.split(",")
.map((part) => part.replace(/[^0-9]/g, ""));
const isGroupChat = parts.length > 1;
const handleSubmit = (event: FormEvent) => {
@@ -25,44 +27,49 @@ const NewMessageGroupForm = () => {
if (parts.length > 0) {
const labelValue = label.trim();
Nui.send('phone:createMessageGroup', {
Nui.send("phone:createMessageGroup", {
phoneNumbers: parts,
label: isGroupChat && labelValue ? labelValue : null,
});
setParticipants('');
setParticipants("");
setShowNewMessageGroup(false); // close modal after submission
}
}
};
return (
<form className={classes.newGroupForm} onSubmit={handleSubmit}>
<TextField
<TextField
value={participants}
onChange={e => setParticipants(e.target.value)}
onChange={(e) => setParticipants(e.target.value)}
placeholder={t("APPS_MESSAGES_NEW_MESSAGE_GROUP")}
className={classes.newGroupinput}
autoFocus
inputProps={{
className: classes.messagesInput
className: classes.messagesInput,
}}
multiline
/>
{isGroupChat && (
<TextField
<TextField
value={label}
onChange={e => setLabel(e.target.value)}
onChange={(e) => setLabel(e.target.value)}
placeholder={t("APPS_MESSAGES_GROUP_CHAT_LABEL")}
className={classes.newGroupinput}
inputProps={{
className: classes.messagesInput
className: classes.messagesInput,
}}
/>
)}
<Button variant="contained" className={classes.newGroupSubmitButton} color="primary" type="submit" >
<Button
variant="contained"
className={classes.newGroupSubmitButton}
color="primary"
type="submit"
>
{t("APPS_MESSAGES_NEW_MESSAGE_GROUP_SUBMIT")}
</Button>
</form>
)
}
);
};
export default NewMessageGroupForm;