mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Merge branch 'master' into feat/snackbar-provider
This commit is contained in:
39 files changed
+926
-904
No files matched your search
+9
-46
@@ -1,7 +1,7 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import './Phone.css';
|
||||
import './i18n';
|
||||
import { Route, useHistory } from 'react-router-dom';
|
||||
import { Route } from 'react-router-dom';
|
||||
import { CallModal } from './modal/components/CallModal';
|
||||
import { Alert } from './ui/components/Alert';
|
||||
import { HomeApp } from './apps/home/components/Home';
|
||||
@@ -36,51 +36,6 @@ import { useQuickAccess } from './os/notifications/hooks/useQuickAccess';
|
||||
import { useSnackbar } from './ui/hooks/useSnackbar';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
app: 'PHONE',
|
||||
method: 'phoneConfig',
|
||||
data: {
|
||||
Locale: 'en',
|
||||
KeyTogglePhone: 288,
|
||||
KeyTakeCall: 38,
|
||||
PhoneAsItem: false,
|
||||
SwimDestroy: false,
|
||||
RunRate: 10,
|
||||
DestoryChance: 100,
|
||||
DestroyPhoneReCheck: 3,
|
||||
notificationPosition: {
|
||||
horizontal: 'right',
|
||||
vertical: 'top',
|
||||
},
|
||||
general: {
|
||||
useDashNumber: true,
|
||||
},
|
||||
twitter: {
|
||||
showNotifications: true,
|
||||
generateProfileNameFromUsers: true,
|
||||
allowEdtiableProfileName: true,
|
||||
allowDeleteTweets: true,
|
||||
allowReportTweets: true,
|
||||
characterLimit: 160,
|
||||
newLineLimit: 10,
|
||||
enableAvatars: true,
|
||||
enableEmojis: true,
|
||||
enableImages: true,
|
||||
maxImages: 3,
|
||||
},
|
||||
bank: {
|
||||
showNotifications: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
app: 'PHONE',
|
||||
method: 'setVisibility',
|
||||
data: true,
|
||||
},
|
||||
]);
|
||||
|
||||
function Phone() {
|
||||
const quickAccess = useQuickAccess();
|
||||
useNuiService();
|
||||
@@ -191,3 +146,11 @@ function Phone() {
|
||||
}
|
||||
|
||||
export default Phone;
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
app: 'PHONE',
|
||||
method: 'setVisibility',
|
||||
data: true,
|
||||
},
|
||||
]);
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, {useEffect} from 'react';
|
||||
import React from 'react';
|
||||
import { Box, Button } from '@material-ui/core';
|
||||
import useStyles from './grid.styles';
|
||||
import { usePhotos } from '../../hooks/usePhotos';
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Button, TextField } from '@material-ui/core';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import List from '@material-ui/core/List';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import Modal from '../../../ui/components/Modal';
|
||||
import { useModal } from '../hooks/useModal';
|
||||
import PersonIcon from '@material-ui/icons/Person';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import AccountCircleIcon from '@material-ui/icons/AccountCircle';
|
||||
import useStyles from './styles.contactmodal';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const AddContactModal = () => {
|
||||
const [name, setName] = useState('');
|
||||
const [number, setNumber] = useState('');
|
||||
const [avatar, setAvatar] = useState('');
|
||||
const classes = useStyles();
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { showModal, setShowModal } = useModal();
|
||||
|
||||
const addContact = () => {
|
||||
if (name === '' || number === '') {
|
||||
console.log('You need to pass in values');
|
||||
} else {
|
||||
Nui.send('contacts:add', {
|
||||
name,
|
||||
number,
|
||||
avatar,
|
||||
});
|
||||
setShowModal(false)
|
||||
}
|
||||
};
|
||||
|
||||
const _handleClose = () => {
|
||||
setShowModal(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal visible={showModal} handleClose={_handleClose}>
|
||||
<List style={{ marginTop: 30 }}>
|
||||
<ListItem>
|
||||
<PersonIcon className={classes.icons} />
|
||||
<TextField
|
||||
value={name}
|
||||
inputProps={{ className: classes.textInputField }}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
fullWidth
|
||||
variant='standard'
|
||||
placeholder={t('APPS_CONTACT_MODAL_PLACEHOLDER_NAME')}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<PhoneIcon className={classes.icons} />
|
||||
<TextField
|
||||
value={number}
|
||||
inputProps={{ className: classes.textInputField }}
|
||||
onChange={(e) => setNumber(e.target.value)}
|
||||
fullWidth
|
||||
placeholder={t('APPS_CONTACT_MODAL_PLACEHOLDER_NUMBER')}
|
||||
variant='standard'
|
||||
type='text'
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<AccountCircleIcon className={classes.icons} />
|
||||
<TextField
|
||||
value={avatar}
|
||||
inputProps={{ className: classes.textInputField }}
|
||||
onChange={(e) => setAvatar(e.target.value)}
|
||||
fullWidth
|
||||
placeholder={t('APPS_CONTACT_MODAL_PLACEHOLDER_AVATAR')}
|
||||
variant='standard'
|
||||
type='text'
|
||||
/>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Button className={classes.addBtn} onClick={addContact}>
|
||||
{t('APPS_CONTACT_MODAL_BUTTON_ADD')}
|
||||
</Button>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
import React from 'react';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
import ContactsIcon from '@material-ui/icons/Contacts';
|
||||
import useStyles from './styles.contacts';
|
||||
|
||||
export const ContactTitle = () => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper className={classes.root} square variant='outlined' elevation={24}>
|
||||
<ContactsIcon className={classes.icon} />
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
@@ -2,17 +2,12 @@ import React from 'react';
|
||||
import { AppWrapper } from '../../../ui/components';
|
||||
import { AppTitle } from '../../../ui/components/AppTitle';
|
||||
import { AppContent } from '../../../ui/components/AppContent';
|
||||
import { ContactList } from './List/ContactList';
|
||||
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||
import { AddContactModal } from './ContactModal';
|
||||
import { useModal } from '../hooks/useModal';
|
||||
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||
import Fab from '@material-ui/core/Fab';
|
||||
import { InfoModal } from './modal/InfoModal';
|
||||
import { useContactDetail } from '../hooks/useContactDetail';
|
||||
|
||||
import useStyles from './styles.contacts';
|
||||
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||
import { Route } from 'react-router-dom';
|
||||
|
||||
import ContactsInfoPage from './views/ContactInfo';
|
||||
import { ContactPage } from './views/ContactsPage';
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
@@ -22,42 +17,32 @@ InjectDebugData([
|
||||
{
|
||||
id: 1,
|
||||
display: 'Ruqen',
|
||||
number: '43534444',
|
||||
number: '555-15196',
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 2,
|
||||
display: 'Taso',
|
||||
number: '456466',
|
||||
number: '215-8139',
|
||||
avatar: 'http://i.tasoagc.dev/i9Ig',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
display: 'Chip',
|
||||
number: '417-8792',
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
export const ContactsApp = () => {
|
||||
const classes = useStyles();
|
||||
const { showModal, setShowModal } = useModal();
|
||||
const contacts = useApp('CONTACTS');
|
||||
const { contactDetail } = useContactDetail();
|
||||
|
||||
const openModal = () => {
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<AppWrapper id='contact-app'>
|
||||
<AppTitle app={contacts} />
|
||||
<AddContactModal />
|
||||
<InfoModal key={contactDetail?.id} />
|
||||
<div className={showModal ? classes.backgroundModal : undefined} />
|
||||
<AppContent>
|
||||
<ContactList />
|
||||
<Fab
|
||||
onClick={openModal}
|
||||
style={{ backgroundColor: '#2196f3', color: '#fff' }}
|
||||
className={classes.absolute}
|
||||
>
|
||||
<PersonAddIcon />
|
||||
</Fab>
|
||||
<Route path='/contacts/' exact component={ContactPage} />
|
||||
<Route path='/contacts/:id' exact component={ContactsInfoPage} />
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
);
|
||||
|
||||
@@ -14,78 +14,84 @@ import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import ChatIcon from '@material-ui/icons/Chat';
|
||||
import MoreVertIcon from '@material-ui/icons/MoreVert';
|
||||
import { useContacts } from '../../hooks/useContacts';
|
||||
import { useContactModal } from '../../hooks/useContactModal';
|
||||
import { useContactDetail } from '../../hooks/useContactDetail';
|
||||
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
|
||||
import '../Contact.css';
|
||||
import { SearchContacts } from './SearchContacts';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||
|
||||
export const ContactList = () => {
|
||||
const { filteredContacts } = useFilteredContacts();
|
||||
const { setShowContactModal } = useContactModal();
|
||||
const { setContactDetail } = useContactDetail();
|
||||
const history = useHistory();
|
||||
|
||||
const contacts = useContacts();
|
||||
const { contacts } = useContacts();
|
||||
|
||||
const openContactInfo = (contact) => {
|
||||
setShowContactModal(true);
|
||||
setContactDetail(contact);
|
||||
const openContactInfo = (contactId: number) => {
|
||||
history.push(`/contacts/${contactId}`);
|
||||
};
|
||||
const startCall = (number) => {
|
||||
console.log(number);
|
||||
|
||||
const startCall = (number: string) => {
|
||||
LogDebugEvent({
|
||||
action: 'Emitting `Start Call` to Scripts',
|
||||
level: 2,
|
||||
data: true,
|
||||
});
|
||||
Nui.send('phone:beginCall', {
|
||||
number,
|
||||
});
|
||||
};
|
||||
|
||||
const handleMessage = () => {
|
||||
LogDebugEvent({
|
||||
action: 'Routing to Message',
|
||||
level: 1,
|
||||
data: true,
|
||||
});
|
||||
// TODO: Integrate to send to message event when route becomes available
|
||||
};
|
||||
|
||||
const filteredRegEx = new RegExp(filteredContacts, 'gi');
|
||||
|
||||
return (
|
||||
<>
|
||||
<SearchContacts />
|
||||
<List>
|
||||
{contacts.contacts
|
||||
{contacts
|
||||
.filter(
|
||||
(contact) =>
|
||||
contact.display.match(filteredRegEx) ||
|
||||
contact.number.match(filteredRegEx)
|
||||
)
|
||||
.map((contact) => (
|
||||
<>
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemAvatar>
|
||||
{contact.avatar ? (
|
||||
<MuiAvatar src={contact.avatar} />
|
||||
) : (
|
||||
<MuiAvatar>
|
||||
{contact.display.slice(0, 1).toUpperCase()}
|
||||
</MuiAvatar>
|
||||
)}
|
||||
</ListItemAvatar>
|
||||
<ListItemText
|
||||
primary={contact.display}
|
||||
secondary={contact.number}
|
||||
/>
|
||||
<Button onClick={() => startCall(contact.number)}>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log('Message: ' + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
<Button
|
||||
style={{ margin: -15 }}
|
||||
onClick={() => openContactInfo(contact)}
|
||||
>
|
||||
<MoreVertIcon />
|
||||
</Button>
|
||||
</ListItem>
|
||||
</>
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemAvatar>
|
||||
{contact.avatar ? (
|
||||
<MuiAvatar src={contact.avatar} />
|
||||
) : (
|
||||
<MuiAvatar>
|
||||
{contact.display.slice(0, 1).toUpperCase()}
|
||||
</MuiAvatar>
|
||||
)}
|
||||
</ListItemAvatar>
|
||||
<ListItemText
|
||||
primary={contact.display}
|
||||
secondary={contact.number}
|
||||
/>
|
||||
<Button onClick={() => startCall(contact.number)}>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button onClick={() => handleMessage()}>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
<Button
|
||||
style={{ margin: -15 }}
|
||||
onClick={() => openContactInfo(contact.id)}
|
||||
>
|
||||
<MoreVertIcon />
|
||||
</Button>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
</>
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Paper,
|
||||
Slide,
|
||||
Button,
|
||||
TextField,
|
||||
Avatar as MuiAvatar,
|
||||
} from '@material-ui/core';
|
||||
import useStyles from './modal.styles';
|
||||
import { useContactModal } from '../../hooks/useContactModal';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useContactDetail } from '../../hooks/useContactDetail';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
|
||||
export const InfoModal = () => {
|
||||
const classes = useStyles();
|
||||
const { showContactModal, setShowContactModal } = useContactModal();
|
||||
const { t } = useTranslation();
|
||||
const { contactDetail, setContactDetail } = useContactDetail();
|
||||
|
||||
const [display, setDisplay] = useState(
|
||||
contactDetail ? contactDetail.display : ''
|
||||
);
|
||||
console.log(contactDetail);
|
||||
const [number, setNumber] = useState(
|
||||
contactDetail ? contactDetail.number : ''
|
||||
);
|
||||
const [avatar, setAvatar] = useState(
|
||||
contactDetail ? contactDetail.avatar : ''
|
||||
);
|
||||
|
||||
const closeModal = () => {
|
||||
setShowContactModal(false);
|
||||
setContactDetail(null);
|
||||
};
|
||||
|
||||
const updateContact = () => {
|
||||
Nui.send('phone:updateContact', {
|
||||
id: contactDetail.id,
|
||||
display,
|
||||
number,
|
||||
avatar,
|
||||
});
|
||||
setContactDetail(null);
|
||||
setShowContactModal(false);
|
||||
};
|
||||
|
||||
const deleteContact = () => {
|
||||
Nui.send('phone:deleteContact', {
|
||||
id: contactDetail.id,
|
||||
});
|
||||
setContactDetail(null);
|
||||
setShowContactModal(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Slide direction='up' in={showContactModal}>
|
||||
<Paper
|
||||
className={showContactModal ? classes.modalRoot : classes.modalHide}
|
||||
square
|
||||
>
|
||||
<Button style={{ margin: 10 }} onClick={closeModal}>
|
||||
<ArrowBackIcon fontSize='large' />
|
||||
</Button>
|
||||
<div className={classes.listContainer}>
|
||||
<MuiAvatar className={classes.avatar} src={avatar} />
|
||||
<TextField
|
||||
className={classes.input}
|
||||
value={display}
|
||||
onChange={(e) => setDisplay(e.target.value)}
|
||||
placeholder={t('APPS_CONTACT_FORM_NAME')}
|
||||
fullWidth
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
value={number}
|
||||
onChange={(e) => setNumber(e.target.value)}
|
||||
placeholder={t('APPS_CONTACT_FORM_NUMBER')}
|
||||
fullWidth
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
placeholder={t('APPS_CONTACT_FORM_AVATAR')}
|
||||
fullWidth
|
||||
value={avatar}
|
||||
onChange={(e) => setAvatar(e.target.value)}
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
/>
|
||||
|
||||
<div style={{ display: 'block' }}>
|
||||
<Button onClick={updateContact} className={classes.updateButton}>
|
||||
{t('GENERIC_UPDATE')}
|
||||
</Button>
|
||||
<Button onClick={deleteContact} className={classes.deleteButton}>
|
||||
{t('GENERIC_DELETE')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Paper>
|
||||
</Slide>
|
||||
);
|
||||
};
|
||||
@@ -1,49 +0,0 @@
|
||||
import { makeStyles } from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
modalRoot: {
|
||||
zIndex: 10,
|
||||
position: 'absolute',
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
},
|
||||
modalHide: {
|
||||
display: 'none',
|
||||
},
|
||||
listContainer: {
|
||||
marginTop: 30,
|
||||
width: '75%',
|
||||
margin: '0 auto',
|
||||
textAlign: 'center',
|
||||
},
|
||||
avatar: {
|
||||
margin: 'auto',
|
||||
height: '125px',
|
||||
width: '124px',
|
||||
marginBottom: 29,
|
||||
},
|
||||
input: {
|
||||
marginBottom: 20,
|
||||
margin: 'auto',
|
||||
textAlign: 'center',
|
||||
},
|
||||
inputProps: {
|
||||
fontSize: 22,
|
||||
},
|
||||
updateButton: {
|
||||
background: '#2196f3',
|
||||
width: 150,
|
||||
height: 45,
|
||||
fontSize: 16,
|
||||
marginTop: 29,
|
||||
marginBottom: 29,
|
||||
},
|
||||
deleteButton: {
|
||||
background: '#d32f2f',
|
||||
width: 150,
|
||||
height: 40,
|
||||
fontSize: 16,
|
||||
},
|
||||
}));
|
||||
|
||||
export default useStyles;
|
||||
@@ -1,45 +0,0 @@
|
||||
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;
|
||||
@@ -1,35 +0,0 @@
|
||||
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: 'absolute',
|
||||
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;
|
||||
@@ -0,0 +1,197 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Avatar as MuiAvatar,
|
||||
Button,
|
||||
Paper,
|
||||
TextField,
|
||||
} from '@material-ui/core';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory, useParams } from 'react-router-dom';
|
||||
import { useContacts } from '../../hooks/useContacts';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||
|
||||
interface ContactInfoRouteParams {
|
||||
mode: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
root: {
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
},
|
||||
listContainer: {
|
||||
marginTop: 30,
|
||||
width: '75%',
|
||||
margin: '0 auto',
|
||||
textAlign: 'center',
|
||||
},
|
||||
avatar: {
|
||||
margin: 'auto',
|
||||
height: '125px',
|
||||
width: '124px',
|
||||
marginBottom: 29,
|
||||
},
|
||||
input: {
|
||||
marginBottom: 20,
|
||||
margin: 'auto',
|
||||
textAlign: 'center',
|
||||
},
|
||||
inputProps: {
|
||||
fontSize: 22,
|
||||
},
|
||||
updateButton: {
|
||||
background: '#2196f3',
|
||||
width: 150,
|
||||
height: 45,
|
||||
fontSize: 16,
|
||||
marginTop: 29,
|
||||
marginBottom: 29,
|
||||
},
|
||||
deleteButton: {
|
||||
background: '#d32f2f',
|
||||
width: 150,
|
||||
height: 40,
|
||||
fontSize: 16,
|
||||
},
|
||||
saveButton: {
|
||||
background: theme.palette.success.dark,
|
||||
color: '#fff',
|
||||
width: 150,
|
||||
height: 45,
|
||||
fontsize: 22,
|
||||
marginTop: theme.spacing(2),
|
||||
},
|
||||
}));
|
||||
|
||||
const ContactsInfoPage = () => {
|
||||
const classes = useStyles();
|
||||
|
||||
const history = useHistory();
|
||||
|
||||
const { getContact } = useContacts();
|
||||
|
||||
const { id } = useParams<ContactInfoRouteParams>();
|
||||
|
||||
const contact = getContact(parseInt(id));
|
||||
|
||||
// Set state after checking if null
|
||||
const [name, setName] = useState(contact ? contact.display : contact);
|
||||
const [number, setNumber] = useState(contact ? contact.number : contact);
|
||||
const [avatar, setAvatar] = useState(contact ? contact.avatar : contact);
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleContactAdd = () => {
|
||||
LogDebugEvent({
|
||||
action: 'Handling Contact Add',
|
||||
data: contact,
|
||||
level: 2,
|
||||
});
|
||||
Nui.send('phone:addContact', {
|
||||
name,
|
||||
number,
|
||||
avatar,
|
||||
});
|
||||
};
|
||||
|
||||
const handleContactSave = () => {
|
||||
LogDebugEvent({
|
||||
action: 'Handling Contact Update',
|
||||
data: contact,
|
||||
level: 2,
|
||||
});
|
||||
Nui.send('phone:updateContact', {
|
||||
id: contact.id,
|
||||
display: name,
|
||||
number,
|
||||
avatar,
|
||||
});
|
||||
};
|
||||
|
||||
const handleContactDelete = () => {
|
||||
LogDebugEvent({
|
||||
action: 'Handling Contact Delete',
|
||||
data: contact,
|
||||
level: 2,
|
||||
});
|
||||
Nui.send('phone:deleteContact', {
|
||||
id: contact.id,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Paper className={classes.root} square>
|
||||
<Button style={{ margin: 10 }} onClick={() => history.goBack()}>
|
||||
<ArrowBackIcon fontSize='large' />
|
||||
</Button>
|
||||
<div className={classes.listContainer}>
|
||||
{avatar ? (
|
||||
<MuiAvatar className={classes.avatar} src={contact.avatar} />
|
||||
) : (
|
||||
<MuiAvatar className={classes.avatar} />
|
||||
)}
|
||||
<TextField
|
||||
className={classes.input}
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
placeholder={t('APPS_CONTACT_FORM_NAME')}
|
||||
fullWidth
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
value={number}
|
||||
onChange={(e) => setNumber(e.target.value)}
|
||||
placeholder={t('APPS_CONTACT_FORM_NUMBER')}
|
||||
fullWidth
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
placeholder={t('APPS_CONTACT_FORM_AVATAR')}
|
||||
fullWidth
|
||||
value={avatar}
|
||||
onChange={(e) => setAvatar(e.target.value)}
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
/>
|
||||
{/* Display if fetched contact */}
|
||||
{contact && (
|
||||
<div style={{ display: 'block' }}>
|
||||
<Button
|
||||
onClick={handleContactSave}
|
||||
className={classes.updateButton}
|
||||
>
|
||||
{t('GENERIC_UPDATE')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleContactDelete}
|
||||
className={classes.deleteButton}
|
||||
>
|
||||
{t('GENERIC_DELETE')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{/* Display if no fetched contact */}
|
||||
{!contact && (
|
||||
<div style={{ display: 'block' }}>
|
||||
<Button onClick={handleContactAdd} className={classes.saveButton}>
|
||||
{t('APPS_CONTACT_MODAL_BUTTON_ADD')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
|
||||
export default ContactsInfoPage;
|
||||
@@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
import { ContactList } from '../List/ContactList';
|
||||
import Fab from '@material-ui/core/Fab';
|
||||
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||
import { ContactAlert } from '../alert/ContactAlert';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
absolute: {
|
||||
position: 'absolute',
|
||||
bottom: theme.spacing(2),
|
||||
right: theme.spacing(2),
|
||||
},
|
||||
icon: {
|
||||
color: '#fff',
|
||||
fontSize: 30,
|
||||
},
|
||||
}));
|
||||
|
||||
export const ContactPage = () => {
|
||||
const history = useHistory();
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContactList />
|
||||
<Fab
|
||||
onClick={() => history.push('/contacts/add')}
|
||||
style={{ backgroundColor: '#2196f3', color: '#fff' }}
|
||||
className={classes.absolute}
|
||||
>
|
||||
<PersonAddIcon />
|
||||
</Fab>
|
||||
<ContactAlert />
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { ContactProps } from '../../../common/typings/contact';
|
||||
import { contactsState } from './state';
|
||||
|
||||
interface ContactDetailProps {
|
||||
contactDetail: ContactProps;
|
||||
setContactDetail: (contact: object) => void;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const useContactDetail = (): ContactDetailProps => {
|
||||
const [ contactDetail, setContactDetail ] = useRecoilState(contactsState.contactDetail);
|
||||
return { contactDetail, setContactDetail };
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { contactsState } from './state';
|
||||
|
||||
interface ModalProps {
|
||||
showContactModal: boolean;
|
||||
setShowContactModal: (show: boolean) => void;
|
||||
}
|
||||
|
||||
export const useContactModal = (): ModalProps => {
|
||||
const [ showContactModal, setShowContactModal ] = useRecoilState(contactsState.showContactsModal);
|
||||
return { showContactModal, setShowContactModal };
|
||||
};
|
||||
@@ -1,19 +1,31 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { contactsState } from './state';
|
||||
|
||||
import { ContactProps } from '../../../common/typings/contact';
|
||||
import { Contact } from '../../../common/typings/contact';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
interface IUseContacts {
|
||||
contacts: ContactProps[]
|
||||
contacts: Contact[];
|
||||
getDisplayByNumber: (number: string) => string;
|
||||
getContact: (id: number) => Contact;
|
||||
}
|
||||
|
||||
export const useContacts = (): IUseContacts => {
|
||||
const contacts = useRecoilValue(contactsState.contacts);
|
||||
const getDisplayByNumber = useCallback((number: string) => {
|
||||
const found = contacts.find((contact) => contact.number === number)
|
||||
return found ? found.display : number
|
||||
}, [contacts])
|
||||
return { contacts, getDisplayByNumber };
|
||||
const getDisplayByNumber = useCallback(
|
||||
(number: string) => {
|
||||
const found = contacts.find((contact) => contact.number === number);
|
||||
return found ? found.display : number;
|
||||
},
|
||||
[contacts]
|
||||
);
|
||||
const getContact = useCallback(
|
||||
(id: number): Contact | null => {
|
||||
for (const contact of contacts) {
|
||||
if (contact.id === id) return contact;
|
||||
}
|
||||
},
|
||||
[contacts]
|
||||
);
|
||||
return { contacts, getDisplayByNumber, getContact };
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Button, TextField, Slide } from '@material-ui/core';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
|
||||
import { useNoteModal } from '../hooks/useNoteModal';
|
||||
|
||||
@@ -37,6 +37,18 @@ InjectDebugData([
|
||||
app: 'TWITTER',
|
||||
method: 'fetchTweets',
|
||||
data: [
|
||||
{
|
||||
id: 59,
|
||||
message: 'XSS\n<script src="test.js">Test</script>\nBro',
|
||||
avatar_url: 'http://i.tasoagc.dev/jtKL',
|
||||
seconds_since_tweet: 500,
|
||||
isMine: false,
|
||||
updateAt: '2021-02-08 14:37:46',
|
||||
visible: 1,
|
||||
likes: 50000,
|
||||
profile_name: 'jQuery Main',
|
||||
images: 'http://i.tasoagc.dev/0xdp',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
message: 'GCPhone will never die',
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { TextField } from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
const useStyles = makeStyles({
|
||||
textField: {
|
||||
flex: '1 1 100%',
|
||||
padding: '10px 15px',
|
||||
@@ -12,7 +12,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
textFieldInput: {
|
||||
fontSize: '22px',
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
export const ImagePrompt = ({ visible, value, handleChange }) => {
|
||||
const textFieldRef = useRef(null);
|
||||
@@ -23,7 +23,10 @@ export const ImagePrompt = ({ visible, value, handleChange }) => {
|
||||
textFieldRef.current && textFieldRef.current.focus();
|
||||
}, [visible]);
|
||||
|
||||
const handleImageChange = useCallback(e => handleChange(e.target.value), []);
|
||||
const handleImageChange = useCallback(
|
||||
(e) => handleChange(e.target.value),
|
||||
[handleChange]
|
||||
);
|
||||
|
||||
if (!visible) return null;
|
||||
return (
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
ListItem,
|
||||
Typography,
|
||||
} from '@material-ui/core';
|
||||
|
||||
import { secondsToHumanReadable } from '../../utils/time';
|
||||
import LikeButton from '../buttons/LikeButton';
|
||||
import ReplyButton from '../buttons/ReplyButton';
|
||||
@@ -16,6 +15,7 @@ import Avatar from '../Avatar';
|
||||
import ShowMore from './ShowMore';
|
||||
import { QuoteButton } from '../buttons/QuoteButton';
|
||||
import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
||||
import DOMPurify from 'dompurify';
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
root: {
|
||||
@@ -80,7 +80,16 @@ export const Tweet = (tweet) => {
|
||||
|
||||
// this is a workaround to transfer string new lines and returns that
|
||||
// are stored into the database into html for the UI to render
|
||||
|
||||
// We are replacing with <br /> to eventually render in HTML
|
||||
const formattedMessage = message.replace(/\n\r?/g, '<br />');
|
||||
|
||||
// Therefore we need to sanitize this message to protect against XSS
|
||||
const sanitizedMessage = DOMPurify.sanitize(formattedMessage, {
|
||||
// Be as strict as possible, whitelisting <br> tag
|
||||
ALLOWED_TAGS: ['br'],
|
||||
});
|
||||
|
||||
const profileName = profile_name ? `@${profile_name}` : '';
|
||||
|
||||
return (
|
||||
@@ -106,7 +115,9 @@ export const Tweet = (tweet) => {
|
||||
</div>
|
||||
<div
|
||||
className={classes.message}
|
||||
dangerouslySetInnerHTML={{ __html: formattedMessage }}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: sanitizedMessage,
|
||||
}}
|
||||
/>
|
||||
{enableImages && <ImageDisplay visible images={images} small />}
|
||||
<div className={classes.buttonContainer}>
|
||||
|
||||
@@ -43,9 +43,6 @@ export const useTwitterService = () => {
|
||||
);
|
||||
const setNotification = useSetRecoilState(twitterState.notification);
|
||||
|
||||
const _setProfile = (profile) => {
|
||||
setProfile(profile);
|
||||
};
|
||||
const _setUpdateProfileSuccess = (isSuccessful) => {
|
||||
setUpdateProfileSuccess(isSuccessful);
|
||||
setUpdateProfileLoading(false); // on any result we should set loading to false
|
||||
@@ -56,10 +53,6 @@ export const useTwitterService = () => {
|
||||
setCreateLoading(false);
|
||||
};
|
||||
|
||||
const _setNotification = (tweet) => {
|
||||
setNotification(tweet);
|
||||
};
|
||||
|
||||
const _setTweets = (tweets) => {
|
||||
setTweets(tweets.map(processTweet));
|
||||
};
|
||||
@@ -67,12 +60,12 @@ export const useTwitterService = () => {
|
||||
setFilteredTweets(tweets.map(processTweet));
|
||||
};
|
||||
|
||||
useNuiEvent(APP_TWITTER, 'getOrCreateTwitterProfile', _setProfile);
|
||||
useNuiEvent(APP_TWITTER, 'getOrCreateTwitterProfile', setProfile);
|
||||
useNuiEvent(APP_TWITTER, 'updateProfileLoading', setUpdateProfileLoading);
|
||||
useNuiEvent(APP_TWITTER, 'updateProfileResult', _setUpdateProfileSuccess);
|
||||
useNuiEvent(APP_TWITTER, 'fetchTweets', _setTweets);
|
||||
useNuiEvent(APP_TWITTER, 'fetchTweetsFiltered', _setFilteredTweets);
|
||||
useNuiEvent(APP_TWITTER, 'createTweetLoading', setCreateLoading);
|
||||
useNuiEvent(APP_TWITTER, 'createTweetResult', _setCreateSuccess);
|
||||
useNuiEvent(APP_TWITTER, 'createTweetBroadcast', _setNotification);
|
||||
useNuiEvent(APP_TWITTER, 'createTweetBroadcast', setNotification);
|
||||
};
|
||||
@@ -25,7 +25,7 @@ interface BankConfig {
|
||||
showNotifications: boolean;
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
export interface IServerConfig {
|
||||
Locale: string;
|
||||
KeyTogglePhone: number;
|
||||
KeyTakeCall: number;
|
||||
|
||||
@@ -11,9 +11,9 @@ export interface IContactAlert {
|
||||
setAlert: (type: string) => void;
|
||||
}
|
||||
|
||||
export interface ContactProps {
|
||||
id: string;
|
||||
export interface Contact {
|
||||
id: number;
|
||||
display: string;
|
||||
number: string;
|
||||
avatar?: string
|
||||
}
|
||||
avatar?: string;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"Locale": "en",
|
||||
"KeyTogglePhone": 288,
|
||||
"KeyTakeCall": 38,
|
||||
"PhoneAsItem": false,
|
||||
"SwimDestroy": false,
|
||||
"RunRate": 10,
|
||||
"DestoryChance": 100,
|
||||
"DestroyPhoneReCheck": 3,
|
||||
"notificationPosition": {
|
||||
"horizontal": "right",
|
||||
"vertical": "top"
|
||||
},
|
||||
"general": {
|
||||
"useDashNumber": true
|
||||
},
|
||||
"twitter": {
|
||||
"showNotifications": true,
|
||||
"generateProfileNameFromUsers": true,
|
||||
"allowEdtiableProfileName": true,
|
||||
"allowDeleteTweets": true,
|
||||
"allowReportTweets": true,
|
||||
"characterLimit": 160,
|
||||
"newLineLimit": 10,
|
||||
"enableAvatars": true,
|
||||
"enableEmojis": true,
|
||||
"enableImages": true,
|
||||
"maxImages": 3
|
||||
},
|
||||
"bank": {
|
||||
"showNotifications": true
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
{
|
||||
"translation": {
|
||||
"DATE_FORMAT": "DD/MM/AAAA",
|
||||
"DATE_TIME_FORMAT": "DD/MM/AAAA hh:mm A",
|
||||
|
||||
"COMING_SOON": "En cours...",
|
||||
|
||||
"APPS_DIALER": "Téléphone",
|
||||
"APPS_CONTACTS": "Contacts",
|
||||
"APPS_MESSAGES": "Messages",
|
||||
@@ -9,6 +13,10 @@
|
||||
"APPS_BANK": "WhoDis Banque",
|
||||
"APPS_NOTES": "Notes",
|
||||
"APPS_EXAMPLE": "App test",
|
||||
"APPS_TWITTER": "Twitter",
|
||||
"APPS_SELLOUT": "Marché",
|
||||
"APPS_CAMERA": "Caméra",
|
||||
|
||||
"APPS_BANK_TRANSFER": "Transfert",
|
||||
"APPS_SETTINGS_OPTIONS_WALLPAPER": "Fond d'écran",
|
||||
"APPS_SETTINGS_OPTIONS_FRAME": "Cadre/Coque",
|
||||
@@ -75,6 +83,13 @@
|
||||
"APPS_CONTACT_MODAL_PLACEHOLDER_NUMBER": "Numéro",
|
||||
"APPS_CONTACT_MODAL_PLACEHOLDER_AVATAR": "Photo",
|
||||
"APPS_CONTACT_MODAL_BUTTON_ADD": "Ajouter un contact",
|
||||
|
||||
"APPS_NOTES_ADD_SUCCESS": "Note sauvegardée avec succès.",
|
||||
"APPS_NOTES_ADD_FAILED": "Erreur lors de la suppression d'une note.",
|
||||
"APPS_NOTES_UPDATE_SUCCESS": "Mise à jour d'une note réalisée avec succès.",
|
||||
"APPS_NOTES_UPDATE_FAILED": "Erreur lors de la mise à jour d'une note.",
|
||||
"APPS_NOTES_DELETE_SUCCESS": "Note supprimée avec succès.",
|
||||
"APPS_NOTES_DELETE_FAILED": "Erreur lors de la suppression d'une note.",
|
||||
|
||||
"APPS_SETTINGS_PHONE_NUMBER": "Numéro de téléphone",
|
||||
"APPS_SETTINGS_OPTION_WALLPAPER": "Fond d'écran",
|
||||
@@ -84,6 +99,7 @@
|
||||
"APPS_SETTINGS_OPTION_RINGTONE": "Sonnerie",
|
||||
"APPS_SETTINGS_OPTION_RINGTONEVOL": "Volume de la sonnerie",
|
||||
|
||||
"GENERIC_SAVE": "Sauvegarder",
|
||||
"GENERIC_UPDATE": "Mettre à jour",
|
||||
"GENERIC_DELETE": "Supprimer"
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ type AppsRepository = { preinstalled: IAppConfig[] };
|
||||
const AppWithStartup = ({ children, id }) => {
|
||||
useEffect(() => {
|
||||
Nui.send(`phone:app:${id}`);
|
||||
}, []);
|
||||
}, [id]);
|
||||
return children;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
export default {
|
||||
async send(event: any, data = {}) {
|
||||
/* eslint-disable no-unreachable */
|
||||
return fetch(`http://new-phone-who-dis/${event}`, {
|
||||
return fetch(`https://new-phone-who-dis/${event}`, {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { phoneState } from './state';
|
||||
import { ServerConfig } from '../../../common/typings/config';
|
||||
import { IServerConfig } from '../../../common/typings/config';
|
||||
import ServerConfig from '../../../config.autogen.json';
|
||||
|
||||
interface IUsePhone {
|
||||
visibility: boolean;
|
||||
config?: ServerConfig;
|
||||
config?: IServerConfig;
|
||||
}
|
||||
|
||||
export const usePhone = (): IUsePhone => {
|
||||
const visibility = useRecoilValue(phoneState.visibility);
|
||||
const config = useRecoilValue(phoneState.phoneConfig);
|
||||
return { visibility, config };
|
||||
return { visibility, config: ServerConfig as any };
|
||||
};
|
||||
@@ -3,7 +3,6 @@ import { makeStyles } from '@material-ui/core/styles';
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import { green } from '@material-ui/core/colors';
|
||||
import { Button } from '@material-ui/core';
|
||||
import Nui from '../../os/nui-events/utils/Nui';
|
||||
|
||||
interface IStyles {
|
||||
root: any;
|
||||
|
||||
Reference in new issue
Block a user