mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
prettier formatting
This commit is contained in:
1 parent
9363032c42
commit
be5c038128
19 files changed
+294
-238
No files matched your search
@@ -1,9 +1,9 @@
|
||||
import React, { FormEvent, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Paper, TextField, Button } from '@material-ui/core'
|
||||
import useStyles from './form.styles';
|
||||
import SendIcon from '@material-ui/icons/Send';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import React, { FormEvent, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Paper, TextField, Button } from "@material-ui/core";
|
||||
import useStyles from "./form.styles";
|
||||
import SendIcon from "@material-ui/icons/Send";
|
||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||
|
||||
interface IProps {
|
||||
messageGroupId: string | undefined;
|
||||
@@ -12,40 +12,41 @@ interface IProps {
|
||||
const MessageInput = ({ messageGroupId }: IProps) => {
|
||||
const classes = useStyles();
|
||||
const { t } = useTranslation();
|
||||
const [ message, setMessage ] = useState('')
|
||||
const [message, setMessage] = useState("");
|
||||
|
||||
const handleSubmit = (event: FormEvent) => {
|
||||
event.preventDefault();
|
||||
if (message.trim()) { // don't allow the user to submit white space
|
||||
Nui.send('phone:sendMessage', {
|
||||
groupId: messageGroupId,
|
||||
message
|
||||
if (message.trim()) {
|
||||
// don't allow the user to submit white space
|
||||
Nui.send("phone:sendMessage", {
|
||||
groupId: messageGroupId,
|
||||
message,
|
||||
});
|
||||
setMessage('');
|
||||
setMessage("");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (!messageGroupId) return null;
|
||||
|
||||
return (
|
||||
<Paper className={classes.paper} variant="outlined" >
|
||||
<Paper className={classes.paper} variant="outlined">
|
||||
<form className={classes.form} onSubmit={handleSubmit}>
|
||||
<TextField
|
||||
value={message}
|
||||
onChange={e => setMessage(e.target.value)}
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
placeholder={t("APPS_MESSAGES_NEW_MESSAGE")}
|
||||
className={classes.input}
|
||||
inputRef={(input) => input && input.focus()}
|
||||
inputProps={{
|
||||
className: classes.messagesInput
|
||||
className: classes.messagesInput,
|
||||
}}
|
||||
/>
|
||||
<Button className={classes.sendButton} type="submit" >
|
||||
<Button className={classes.sendButton} type="submit">
|
||||
<SendIcon />
|
||||
</Button>
|
||||
</form>
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default MessageInput;
|
||||
export default MessageInput;
|
||||
@@ -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;
|
||||
@@ -1,38 +1,38 @@
|
||||
import { makeStyles } from '@material-ui/core';
|
||||
import { makeStyles } from "@material-ui/core";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
sendButton: {
|
||||
float: 'right'
|
||||
float: "right",
|
||||
},
|
||||
paper: {
|
||||
position: 'absolute',
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
width: '100%',
|
||||
width: "100%",
|
||||
},
|
||||
form: {
|
||||
display: 'flex',
|
||||
display: "flex",
|
||||
},
|
||||
input: {
|
||||
width: '100%',
|
||||
margin: 10
|
||||
width: "100%",
|
||||
margin: 10,
|
||||
},
|
||||
newGroupForm: {
|
||||
position: 'absolute',
|
||||
position: "absolute",
|
||||
top: 65,
|
||||
display: 'flex',
|
||||
flexFlow: 'column nowrap',
|
||||
justifyContent: 'flex-start',
|
||||
width: '100%',
|
||||
display: "flex",
|
||||
flexFlow: "column nowrap",
|
||||
justifyContent: "flex-start",
|
||||
width: "100%",
|
||||
},
|
||||
newGroupSubmitButton: {
|
||||
margin: '15px 8px 0px 8px',
|
||||
margin: "15px 8px 0px 8px",
|
||||
},
|
||||
newGroupinput: {
|
||||
margin: '0px 8px 15px 8px',
|
||||
margin: "0px 8px 15px 8px",
|
||||
},
|
||||
messagesInput: {
|
||||
fontSize: 20
|
||||
}
|
||||
}))
|
||||
fontSize: 20,
|
||||
},
|
||||
}));
|
||||
|
||||
export default useStyles;
|
||||
export default useStyles;
|
||||
Reference in new issue
Block a user