mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
feats(contacts/nui): cleanup | esx.js | translation for contacts
This commit is contained in:
1 parent
4d6bc53eea
commit
74f43efddb
12 files changed
+265
-196
No files matched your search
@@ -1,71 +1,30 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from 'react';
|
||||||
import { makeStyles, Theme } from "@material-ui/core/styles";
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
import { Button, TextField } from "@material-ui/core";
|
import { Button, TextField } from '@material-ui/core';
|
||||||
import Nui from "../../../os/nui-events/utils/Nui";
|
import Nui from '../../../os/nui-events/utils/Nui';
|
||||||
import List from "@material-ui/core/List";
|
import List from '@material-ui/core/List';
|
||||||
import ListItem from "@material-ui/core/ListItem";
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import Modal from "../../../ui/components/Modal";
|
import Modal from '../../../ui/components/Modal';
|
||||||
import { useModal } from "../hooks/useModal";
|
import { useModal } from '../hooks/useModal';
|
||||||
import ClearIcon from "@material-ui/icons/Clear";
|
import ClearIcon from '@material-ui/icons/Clear';
|
||||||
import PersonIcon from "@material-ui/icons/Person";
|
import PersonIcon from '@material-ui/icons/Person';
|
||||||
import PhoneIcon from "@material-ui/icons/Phone";
|
import PhoneIcon from '@material-ui/icons/Phone';
|
||||||
import AccountCircleIcon from "@material-ui/icons/AccountCircle";
|
import AccountCircleIcon from '@material-ui/icons/AccountCircle';
|
||||||
|
import useStyles from './styles.contactmodal';
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
|
||||||
button: {
|
|
||||||
margin: 5,
|
|
||||||
marginTop: 20,
|
|
||||||
},
|
|
||||||
root: {
|
|
||||||
position: "fixed",
|
|
||||||
bottom: 380,
|
|
||||||
zIndex: 2,
|
|
||||||
background: "#232323",
|
|
||||||
marginLeft: "-4em",
|
|
||||||
height: "20%",
|
|
||||||
},
|
|
||||||
clearButton: {
|
|
||||||
width: "10%",
|
|
||||||
position: "absolute",
|
|
||||||
right: 0,
|
|
||||||
},
|
|
||||||
textInputField: {
|
|
||||||
fontSize: 20,
|
|
||||||
borderBottomColor: "red",
|
|
||||||
},
|
|
||||||
addBtn: {
|
|
||||||
margin: "auto",
|
|
||||||
fontSize: 16,
|
|
||||||
width: 150,
|
|
||||||
background: "#2196f3",
|
|
||||||
marginBottom: 10,
|
|
||||||
padding: 8,
|
|
||||||
},
|
|
||||||
cancelBtn: {
|
|
||||||
margin: "auto",
|
|
||||||
width: 150,
|
|
||||||
background: "#232323",
|
|
||||||
marginBottom: 20,
|
|
||||||
padding: 8,
|
|
||||||
},
|
|
||||||
icons: {
|
|
||||||
marginRight: 5,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const AddContactModal = () => {
|
export const AddContactModal = () => {
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState('');
|
||||||
const [number, setNumber] = useState("");
|
const [number, setNumber] = useState('');
|
||||||
const [avatar, setAvatar] = useState("");
|
const [avatar, setAvatar] = useState('');
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
const { showModal, setShowModal } = useModal();
|
const { showModal, setShowModal } = useModal();
|
||||||
|
|
||||||
const addContact = () => {
|
const addContact = () => {
|
||||||
if (name === "" || number === "") {
|
if (name === '' || number === '') {
|
||||||
console.log("You need to pass in values");
|
console.log('You need to pass in values');
|
||||||
} else {
|
} else {
|
||||||
Nui.send("contacts:add", {
|
Nui.send('contacts:add', {
|
||||||
name,
|
name,
|
||||||
number,
|
number,
|
||||||
avatar,
|
avatar,
|
||||||
@@ -91,8 +50,8 @@ export const AddContactModal = () => {
|
|||||||
inputProps={{ className: classes.textInputField }}
|
inputProps={{ className: classes.textInputField }}
|
||||||
onChange={(e) => setName(e.target.value)}
|
onChange={(e) => setName(e.target.value)}
|
||||||
fullWidth
|
fullWidth
|
||||||
variant="standard"
|
variant='standard'
|
||||||
placeholder="Name"
|
placeholder='Name'
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
@@ -102,9 +61,9 @@ export const AddContactModal = () => {
|
|||||||
inputProps={{ className: classes.textInputField }}
|
inputProps={{ className: classes.textInputField }}
|
||||||
onChange={(e) => setNumber(e.target.value)}
|
onChange={(e) => setNumber(e.target.value)}
|
||||||
fullWidth
|
fullWidth
|
||||||
placeholder="Number"
|
placeholder='Number'
|
||||||
variant="standard"
|
variant='standard'
|
||||||
type="text"
|
type='text'
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
@@ -114,9 +73,9 @@ export const AddContactModal = () => {
|
|||||||
inputProps={{ className: classes.textInputField }}
|
inputProps={{ className: classes.textInputField }}
|
||||||
onChange={(e) => setAvatar(e.target.value)}
|
onChange={(e) => setAvatar(e.target.value)}
|
||||||
fullWidth
|
fullWidth
|
||||||
placeholder="Avatar URL"
|
placeholder='Avatar URL'
|
||||||
variant="standard"
|
variant='standard'
|
||||||
type="text"
|
type='text'
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
|
|||||||
@@ -1,30 +1,12 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { makeStyles, createStyles, Theme } from "@material-ui/core/styles";
|
import Paper from '@material-ui/core/Paper';
|
||||||
import Paper from "@material-ui/core/Paper";
|
import ContactsIcon from '@material-ui/icons/Contacts';
|
||||||
import ContactsIcon from "@material-ui/icons/Contacts";
|
import useStyles from './styles.contacts';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
|
||||||
createStyles({
|
|
||||||
root: {
|
|
||||||
height: "60px",
|
|
||||||
width: "100%",
|
|
||||||
display: "flex",
|
|
||||||
flexFlow: "row nowrap",
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
background: "#424242",
|
|
||||||
},
|
|
||||||
icon: {
|
|
||||||
color: "#fff",
|
|
||||||
fontSize: 30,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
export const ContactTitle = () => {
|
export const ContactTitle = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
return (
|
return (
|
||||||
<Paper className={classes.root} square variant="outlined" elevation={24}>
|
<Paper className={classes.root} square variant='outlined' elevation={24}>
|
||||||
<ContactsIcon className={classes.icon} />
|
<ContactsIcon className={classes.icon} />
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { AppWrapper } from '../../../ui/components';
|
import { AppWrapper } from '../../../ui/components';
|
||||||
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
|
|
||||||
import { AppTitle } from '../../../ui/components/AppTitle';
|
import { AppTitle } from '../../../ui/components/AppTitle';
|
||||||
import { AppContent } from '../../../ui/components/AppContent';
|
import { AppContent } from '../../../ui/components/AppContent';
|
||||||
import { ContactList } from './List/ContactList';
|
import { ContactList } from './List/ContactList';
|
||||||
@@ -10,30 +9,11 @@ import { useModal } from '../hooks/useModal';
|
|||||||
import { SearchContacts } from './List/SearchContacts';
|
import { SearchContacts } from './List/SearchContacts';
|
||||||
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||||
import Fab from '@material-ui/core/Fab';
|
import Fab from '@material-ui/core/Fab';
|
||||||
import { useContactModal } from '../hooks/useContactModal';
|
|
||||||
import { InfoModal } from './modal/InfoModal';
|
import { InfoModal } from './modal/InfoModal';
|
||||||
import { useContactDetail } from '../hooks/useContactDetail';
|
import { useContactDetail } from '../hooks/useContactDetail';
|
||||||
import { ContactAlert } from './alert/ContactAlert';
|
import { ContactAlert } from './alert/ContactAlert';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
import useStyles from './styles.contacts';
|
||||||
createStyles({
|
|
||||||
backgroundModal: {
|
|
||||||
background: 'black',
|
|
||||||
opacity: '0.6',
|
|
||||||
position: 'absolute',
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
zIndex: 5,
|
|
||||||
},
|
|
||||||
absolute: {
|
|
||||||
position: 'sticky',
|
|
||||||
bottom: theme.spacing(2),
|
|
||||||
left: theme.spacing(3),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
export const ContactsApp = () => {
|
export const ContactsApp = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import ListItemText from "@material-ui/core/ListItemText";
|
import ListItemText from '@material-ui/core/ListItemText';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
ListItemAvatar,
|
ListItemAvatar,
|
||||||
@@ -9,41 +9,41 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
Collapse,
|
Collapse,
|
||||||
makeStyles,
|
makeStyles,
|
||||||
} from "@material-ui/core";
|
} from '@material-ui/core';
|
||||||
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { faPen } from "@fortawesome/free-solid-svg-icons";
|
import { faPen } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
import { useFilteredContacts } from "../../hooks/useFilteredContacts";
|
import { useFilteredContacts } from '../../hooks/useFilteredContacts';
|
||||||
|
|
||||||
import PhoneIcon from "@material-ui/icons/Phone";
|
import PhoneIcon from '@material-ui/icons/Phone';
|
||||||
import ChatIcon from "@material-ui/icons/Chat";
|
import ChatIcon from '@material-ui/icons/Chat';
|
||||||
import MoreVertIcon from "@material-ui/icons/MoreVert";
|
import MoreVertIcon from '@material-ui/icons/MoreVert';
|
||||||
import { useContacts } from "../../hooks/useContacts";
|
import { useContacts } from '../../hooks/useContacts';
|
||||||
import { useContactModal } from "../../hooks/useContactModal";
|
import { useContactModal } from '../../hooks/useContactModal';
|
||||||
import { useContactDetail } from "../../hooks/useContactDetail";
|
import { useContactDetail } from '../../hooks/useContactDetail';
|
||||||
|
|
||||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
|
|
||||||
import "../Contact.css";
|
import '../Contact.css';
|
||||||
|
import { ContactAlert } from '../alert/ContactAlert';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
updateButton: {
|
updateButton: {
|
||||||
margin: "auto",
|
margin: 'auto',
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
width: 150,
|
width: 150,
|
||||||
background: "#2196f3",
|
background: '#2196f3',
|
||||||
marginBottom: 10,
|
marginBottom: 10,
|
||||||
padding: 8,
|
padding: 8,
|
||||||
},
|
},
|
||||||
collapseItem: {
|
collapseItem: {
|
||||||
margin: "auto",
|
margin: 'auto',
|
||||||
width: "50%",
|
width: '50%',
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const ContactList = () => {
|
export const ContactList = () => {
|
||||||
const classes = useStyles();
|
|
||||||
const { filteredContacts } = useFilteredContacts();
|
const { filteredContacts } = useFilteredContacts();
|
||||||
const { setShowContactModal } = useContactModal();
|
const { setShowContactModal } = useContactModal();
|
||||||
const { contactDetail, setContactDetail } = useContactDetail();
|
const { contactDetail, setContactDetail } = useContactDetail();
|
||||||
@@ -53,11 +53,11 @@ export const ContactList = () => {
|
|||||||
const openContactInfo = (contact) => {
|
const openContactInfo = (contact) => {
|
||||||
setShowContactModal(true);
|
setShowContactModal(true);
|
||||||
setContactDetail(contact);
|
setContactDetail(contact);
|
||||||
console.log("CONTACT", contactDetail);
|
console.log('CONTACT', contactDetail);
|
||||||
};
|
};
|
||||||
const startCall = (number) => {
|
const startCall = (number) => {
|
||||||
console.log(number);
|
console.log(number);
|
||||||
Nui.send("phone:startCall", {
|
Nui.send('phone:startCall', {
|
||||||
number,
|
number,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -67,8 +67,8 @@ export const ContactList = () => {
|
|||||||
{contacts.contacts
|
{contacts.contacts
|
||||||
.filter(
|
.filter(
|
||||||
(contact) =>
|
(contact) =>
|
||||||
contact.display.includes(filteredContacts) ||
|
contact.display.includes(filteredContacts.toLowerCase()) ||
|
||||||
contact.number.includes(filteredContacts)
|
contact.number.includes(filteredContacts.toLowerCase())
|
||||||
)
|
)
|
||||||
.map((contact) => (
|
.map((contact) => (
|
||||||
<>
|
<>
|
||||||
@@ -91,7 +91,7 @@ export const ContactList = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
console.log("Message: " + contact.display, contact.number)
|
console.log('Message: ' + contact.display, contact.number)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ChatIcon />
|
<ChatIcon />
|
||||||
|
|||||||
@@ -1,66 +1,65 @@
|
|||||||
import React, { useState } from "react";
|
import React from 'react';
|
||||||
import { InputBase } from "@material-ui/core";
|
import { InputBase } from '@material-ui/core';
|
||||||
import SearchIcon from "@material-ui/icons/Search";
|
import SearchIcon from '@material-ui/icons/Search';
|
||||||
import {
|
import {
|
||||||
createStyles,
|
createStyles,
|
||||||
fade,
|
fade,
|
||||||
Theme,
|
Theme,
|
||||||
makeStyles,
|
makeStyles,
|
||||||
} from "@material-ui/core/styles";
|
} from '@material-ui/core/styles';
|
||||||
|
|
||||||
import { useFilteredContacts } from "../../hooks/useFilteredContacts";
|
import { useFilteredContacts } from '../../hooks/useFilteredContacts';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
bg: {
|
bg: {
|
||||||
backgroundColor: "#232323",
|
backgroundColor: '#232323',
|
||||||
display: "flex",
|
display: 'flex',
|
||||||
height: 60,
|
height: 60,
|
||||||
justifyContent: "center",
|
justifyContent: 'center',
|
||||||
alignItems: "center",
|
alignItems: 'center',
|
||||||
},
|
},
|
||||||
textFieldInput: {
|
textFieldInput: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
},
|
},
|
||||||
inputRoot: {
|
inputRoot: {
|
||||||
color: "#fff",
|
color: '#fff',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
},
|
},
|
||||||
inputInput: {
|
inputInput: {
|
||||||
padding: theme.spacing(1, 4, 1, 4),
|
padding: theme.spacing(1, 4, 1, 4),
|
||||||
// vertical padding + font size from searchIcon
|
transition: theme.transitions.create('width'),
|
||||||
transition: theme.transitions.create("width"),
|
width: '100%',
|
||||||
width: "100%",
|
|
||||||
|
|
||||||
[theme.breakpoints.up("sm")]: {
|
[theme.breakpoints.up('sm')]: {
|
||||||
width: "13ch",
|
width: '13ch',
|
||||||
"&:focus": {
|
'&:focus': {
|
||||||
width: "20ch",
|
width: '20ch',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
search: {
|
search: {
|
||||||
position: "relative",
|
position: 'relative',
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderRadius: theme.shape.borderRadius,
|
||||||
backgroundColor: fade(theme.palette.common.white, 0.15),
|
backgroundColor: fade(theme.palette.common.white, 0.15),
|
||||||
"&:hover": {
|
'&:hover': {
|
||||||
backgroundColor: fade(theme.palette.common.white, 0.25),
|
backgroundColor: fade(theme.palette.common.white, 0.25),
|
||||||
},
|
},
|
||||||
marginLeft: 0,
|
marginLeft: 0,
|
||||||
width: "100%",
|
width: '100%',
|
||||||
[theme.breakpoints.up("sm")]: {
|
[theme.breakpoints.up('sm')]: {
|
||||||
marginLeft: theme.spacing(1),
|
marginLeft: theme.spacing(1),
|
||||||
width: "auto",
|
width: 'auto',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
searchIcon: {
|
searchIcon: {
|
||||||
padding: theme.spacing(0, 0.5),
|
padding: theme.spacing(0, 0.5),
|
||||||
height: "100%",
|
height: '100%',
|
||||||
position: "absolute",
|
position: 'absolute',
|
||||||
pointerEvents: "none",
|
pointerEvents: 'none',
|
||||||
display: "flex",
|
display: 'flex',
|
||||||
alignItems: "center",
|
alignItems: 'center',
|
||||||
justifyContent: "center",
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -69,10 +68,8 @@ export const SearchContacts = () => {
|
|||||||
const { setFilteredContacts } = useFilteredContacts();
|
const { setFilteredContacts } = useFilteredContacts();
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const [searchValue, setSearchValue] = useState("");
|
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
setSearchValue(e.target.value);
|
|
||||||
setFilteredContacts(e.target.value);
|
setFilteredContacts(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -80,16 +77,16 @@ export const SearchContacts = () => {
|
|||||||
<div className={classes.bg}>
|
<div className={classes.bg}>
|
||||||
<div className={classes.search}>
|
<div className={classes.search}>
|
||||||
<div className={classes.searchIcon}>
|
<div className={classes.searchIcon}>
|
||||||
<SearchIcon style={{ color: "#fff" }} />
|
<SearchIcon style={{ color: '#fff' }} />
|
||||||
</div>
|
</div>
|
||||||
<InputBase
|
<InputBase
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
placeholder="Search contacts..."
|
placeholder='Search contacts...'
|
||||||
classes={{
|
classes={{
|
||||||
root: classes.inputRoot,
|
root: classes.inputRoot,
|
||||||
input: classes.inputInput,
|
input: classes.inputInput,
|
||||||
}}
|
}}
|
||||||
inputProps={{ "aria-label": "search" }}
|
inputProps={{ 'aria-label': 'search' }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { Snackbar } from '@material-ui/core';
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Alert } from '../../../../ui/components/Alert';
|
||||||
|
import { useContactAlert } from '../../hooks/useAlert';
|
||||||
|
|
||||||
|
export const ContactAlert = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { alert, setAlert } = useContactAlert();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [message, setMessage] = useState(null);
|
||||||
|
const [severity, setSeverity] = useState('');
|
||||||
|
|
||||||
|
const _handleClose = () => {
|
||||||
|
setOpen(false);
|
||||||
|
setAlert(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (alert === 'CONTACT_ADD_SUCCESS') {
|
||||||
|
setMessage(t('APPS_CONTACTS_ADD_SUCCESS'));
|
||||||
|
setSeverity('success');
|
||||||
|
setOpen(true);
|
||||||
|
} else if (alert === 'CONTACT_ADD_FAILED') {
|
||||||
|
setMessage(t('APPS_CONTACTS_ADD_FAILED'));
|
||||||
|
setSeverity('error');
|
||||||
|
setOpen(true);
|
||||||
|
} else if (alert === 'CONTACT_UPDATE_SUCCESS') {
|
||||||
|
setMessage(t('APPS_CONTACTS_UPDATE_SUCCESS'));
|
||||||
|
setSeverity('success');
|
||||||
|
setOpen(true);
|
||||||
|
} else if (alert === 'CONTACT_UPDATE_FAILED') {
|
||||||
|
setMessage(t('APPS_CONTACTS_UPDATE_FAILED'));
|
||||||
|
setSeverity('error');
|
||||||
|
setOpen(true);
|
||||||
|
} else if (alert === 'CONTACT_DELETE_SUCCESS') {
|
||||||
|
setMessage(t('APPS_CONTACTS_DELETE_SUCCESS'));
|
||||||
|
setSeverity('success');
|
||||||
|
setOpen(true);
|
||||||
|
} else if (alert === 'CONTACT_DELETE_FAILED') {
|
||||||
|
setMessage(t('APPS_CONTACTS_DELETE_FAILED'));
|
||||||
|
setSeverity('error');
|
||||||
|
setOpen(true);
|
||||||
|
}
|
||||||
|
}, [alert]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Snackbar
|
||||||
|
style={{ width: '80%', position: 'absolute', bottom: '10%' }}
|
||||||
|
autoHideDuration={6000}
|
||||||
|
open={open}
|
||||||
|
onClose={_handleClose}
|
||||||
|
>
|
||||||
|
<Alert severity={severity} variant='filled'>
|
||||||
|
{message}
|
||||||
|
</Alert>
|
||||||
|
</Snackbar>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Paper,
|
Paper,
|
||||||
Slide,
|
Slide,
|
||||||
Button,
|
Button,
|
||||||
TextField,
|
TextField,
|
||||||
Avatar as MuiAvatar,
|
Avatar as MuiAvatar,
|
||||||
} from "@material-ui/core";
|
} from '@material-ui/core';
|
||||||
import useStyles from "./modal.styles";
|
import useStyles from './modal.styles';
|
||||||
import { useContactModal } from "../../hooks/useContactModal";
|
import { useContactModal } from '../../hooks/useContactModal';
|
||||||
import ArrowBackIcon from "@material-ui/icons/ArrowBack";
|
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||||
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useContactDetail } from "../../hooks/useContactDetail";
|
import { useContactDetail } from '../../hooks/useContactDetail';
|
||||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
|
|
||||||
export const InfoModal = () => {
|
export const InfoModal = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
@@ -21,14 +21,14 @@ export const InfoModal = () => {
|
|||||||
const { contactDetail, setContactDetail } = useContactDetail();
|
const { contactDetail, setContactDetail } = useContactDetail();
|
||||||
|
|
||||||
const [display, setDisplay] = useState(
|
const [display, setDisplay] = useState(
|
||||||
contactDetail ? contactDetail.display : ""
|
contactDetail ? contactDetail.display : ''
|
||||||
);
|
);
|
||||||
console.log(contactDetail);
|
console.log(contactDetail);
|
||||||
const [number, setNumber] = useState(
|
const [number, setNumber] = useState(
|
||||||
contactDetail ? contactDetail.number : ""
|
contactDetail ? contactDetail.number : ''
|
||||||
);
|
);
|
||||||
const [avatar, setAvatar] = useState(
|
const [avatar, setAvatar] = useState(
|
||||||
contactDetail ? contactDetail.avatar : ""
|
contactDetail ? contactDetail.avatar : ''
|
||||||
);
|
);
|
||||||
|
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
@@ -37,7 +37,7 @@ export const InfoModal = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateContact = () => {
|
const updateContact = () => {
|
||||||
Nui.send("phone:updateContact", {
|
Nui.send('phone:updateContact', {
|
||||||
id: contactDetail.id,
|
id: contactDetail.id,
|
||||||
display,
|
display,
|
||||||
number,
|
number,
|
||||||
@@ -48,7 +48,7 @@ export const InfoModal = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteContact = () => {
|
const deleteContact = () => {
|
||||||
Nui.send("phone:deleteContact", {
|
Nui.send('phone:deleteContact', {
|
||||||
id: contactDetail.id,
|
id: contactDetail.id,
|
||||||
});
|
});
|
||||||
setContactDetail(null);
|
setContactDetail(null);
|
||||||
@@ -56,12 +56,12 @@ export const InfoModal = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Slide direction="up" in={showContactModal}>
|
<Slide direction='up' in={showContactModal}>
|
||||||
<Paper
|
<Paper
|
||||||
className={showContactModal ? classes.modalRoot : classes.modalHide}
|
className={showContactModal ? classes.modalRoot : classes.modalHide}
|
||||||
>
|
>
|
||||||
<Button style={{ margin: 10 }} onClick={closeModal}>
|
<Button style={{ margin: 10 }} onClick={closeModal}>
|
||||||
<ArrowBackIcon fontSize="large" />
|
<ArrowBackIcon fontSize='large' />
|
||||||
</Button>
|
</Button>
|
||||||
<div className={classes.listContainer}>
|
<div className={classes.listContainer}>
|
||||||
<MuiAvatar className={classes.avatar} src={avatar} />
|
<MuiAvatar className={classes.avatar} src={avatar} />
|
||||||
@@ -69,7 +69,7 @@ export const InfoModal = () => {
|
|||||||
className={classes.input}
|
className={classes.input}
|
||||||
value={display}
|
value={display}
|
||||||
onChange={(e) => setDisplay(e.target.value)}
|
onChange={(e) => setDisplay(e.target.value)}
|
||||||
placeholder={t("APPS_CONTACT_FORM_NAME")}
|
placeholder={t('APPS_CONTACT_FORM_NAME')}
|
||||||
fullWidth
|
fullWidth
|
||||||
inputProps={{
|
inputProps={{
|
||||||
className: classes.inputProps,
|
className: classes.inputProps,
|
||||||
@@ -79,7 +79,7 @@ export const InfoModal = () => {
|
|||||||
className={classes.input}
|
className={classes.input}
|
||||||
value={number}
|
value={number}
|
||||||
onChange={(e) => setNumber(e.target.value)}
|
onChange={(e) => setNumber(e.target.value)}
|
||||||
placeholder={t("APPS_CONTACT_FORM_NUMBER")}
|
placeholder={t('APPS_CONTACT_FORM_NUMBER')}
|
||||||
fullWidth
|
fullWidth
|
||||||
inputProps={{
|
inputProps={{
|
||||||
className: classes.inputProps,
|
className: classes.inputProps,
|
||||||
@@ -87,7 +87,7 @@ export const InfoModal = () => {
|
|||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
placeholder={t("APPS_CONTACT_FORM_AVATAR")}
|
placeholder={t('APPS_CONTACT_FORM_AVATAR')}
|
||||||
fullWidth
|
fullWidth
|
||||||
value={avatar}
|
value={avatar}
|
||||||
onChange={(e) => setAvatar(e.target.value)}
|
onChange={(e) => setAvatar(e.target.value)}
|
||||||
@@ -96,7 +96,7 @@ export const InfoModal = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div style={{ display: "block" }}>
|
<div style={{ display: 'block' }}>
|
||||||
<Button onClick={updateContact} className={classes.updateButton}>
|
<Button onClick={updateContact} className={classes.updateButton}>
|
||||||
Update
|
Update
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
|
button: {
|
||||||
|
margin: 5,
|
||||||
|
marginTop: 20,
|
||||||
|
},
|
||||||
|
root: {
|
||||||
|
position: 'fixed',
|
||||||
|
bottom: 380,
|
||||||
|
zIndex: 2,
|
||||||
|
background: '#232323',
|
||||||
|
marginLeft: '-4em',
|
||||||
|
height: '20%',
|
||||||
|
},
|
||||||
|
clearButton: {
|
||||||
|
width: '10%',
|
||||||
|
position: 'absolute',
|
||||||
|
right: 0,
|
||||||
|
},
|
||||||
|
textInputField: {
|
||||||
|
fontSize: 20,
|
||||||
|
borderBottomColor: 'red',
|
||||||
|
},
|
||||||
|
addBtn: {
|
||||||
|
margin: 'auto',
|
||||||
|
fontSize: 16,
|
||||||
|
width: 150,
|
||||||
|
background: '#2196f3',
|
||||||
|
marginBottom: 10,
|
||||||
|
padding: 8,
|
||||||
|
},
|
||||||
|
cancelBtn: {
|
||||||
|
margin: 'auto',
|
||||||
|
width: 150,
|
||||||
|
background: '#232323',
|
||||||
|
marginBottom: 20,
|
||||||
|
padding: 8,
|
||||||
|
},
|
||||||
|
icons: {
|
||||||
|
marginRight: 5,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export default useStyles;
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
|
backgroundModal: {
|
||||||
|
background: 'black',
|
||||||
|
opacity: '0.6',
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
zIndex: 5,
|
||||||
|
},
|
||||||
|
absolute: {
|
||||||
|
position: 'sticky',
|
||||||
|
bottom: theme.spacing(2),
|
||||||
|
left: theme.spacing(3),
|
||||||
|
},
|
||||||
|
// title
|
||||||
|
root: {
|
||||||
|
height: '60px',
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexFlow: 'row nowrap',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
background: '#424242',
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
color: '#fff',
|
||||||
|
fontSize: 30,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export default useStyles;
|
||||||
@@ -1,24 +1,28 @@
|
|||||||
import { atom } from "recoil";
|
import { atom } from 'recoil';
|
||||||
|
|
||||||
export const contactsState = {
|
export const contactsState = {
|
||||||
contacts: atom({
|
contacts: atom({
|
||||||
key: "contactsList",
|
key: 'contactsList',
|
||||||
default: [],
|
default: [],
|
||||||
}),
|
}),
|
||||||
showModal: atom({
|
showModal: atom({
|
||||||
key: "showModal",
|
key: 'showModal',
|
||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
filterContacts: atom({
|
filterContacts: atom({
|
||||||
key: 'filterContacts',
|
key: 'filterContacts',
|
||||||
default: ""
|
default: '',
|
||||||
}),
|
}),
|
||||||
showContactsModal: atom({
|
showContactsModal: atom({
|
||||||
key: 'showContactModal',
|
key: 'showContactModal',
|
||||||
default: false
|
default: false,
|
||||||
}),
|
}),
|
||||||
contactDetail: atom({
|
contactDetail: atom({
|
||||||
key: 'contactDetail',
|
key: 'contactDetail',
|
||||||
default: null
|
default: null,
|
||||||
})
|
}),
|
||||||
|
contactAlert: atom({
|
||||||
|
key: 'contactAlert',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
@@ -61,6 +61,13 @@
|
|||||||
"APPS_MESSAGES_INVALID_PHONE_NUMBER": "Invalid phone number: ",
|
"APPS_MESSAGES_INVALID_PHONE_NUMBER": "Invalid phone number: ",
|
||||||
"APPS_MESSAGES_MESSAGE_GROUP_DUPLICATE": "This message group already exists",
|
"APPS_MESSAGES_MESSAGE_GROUP_DUPLICATE": "This message group already exists",
|
||||||
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED": "Failed to create message group",
|
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED": "Failed to create message group",
|
||||||
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_MINE": "You cannot add yourself!"
|
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_MINE": "You cannot add yourself!",
|
||||||
|
|
||||||
|
"APPS_CONTACTS_ADD_SUCCESS": "Successfully created contact!",
|
||||||
|
"APPS_CONTACTS_ADD_FAILED": "Failed to created contact!",
|
||||||
|
"APPS_CONTACTS_UPDATE_SUCCESS": "Successfully updated contact!",
|
||||||
|
"APPS_CONTACTS_UPDATE_FAILED": "Failed to update contact!",
|
||||||
|
"APPS_CONTACTS_DELETE_SUCCESS": "Successfully deleted contact!",
|
||||||
|
"APPS_CONTACTS_DELETE_FAILED": "Failed to delete contact!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
"@types/node": "^14.11.10",
|
"@types/node": "^14.11.10",
|
||||||
"axios": "^0.21.0",
|
"axios": "^0.21.0",
|
||||||
"connection-string-parser": "^1.0.3",
|
"connection-string-parser": "^1.0.3",
|
||||||
|
"esx.js": "^1.1.5",
|
||||||
"fivem-esx-js": "^0.1.12",
|
"fivem-esx-js": "^0.1.12",
|
||||||
"fivem-js": "^1.3.1",
|
"fivem-js": "^1.3.1",
|
||||||
"md5": "^2.3.0",
|
"md5": "^2.3.0",
|
||||||
|
|||||||
Reference in new issue
Block a user