mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Merge pull request #26 from Re-Ignited-Development/wrap/contacts
Wrap up contact app
This commit is contained in:
12 files changed
+305
-61
No files matched your search
+1
-1
@@ -135,7 +135,7 @@ setTimeout(() => {
|
|||||||
id: 1,
|
id: 1,
|
||||||
number: "345-4366",
|
number: "345-4366",
|
||||||
display: "chip",
|
display: "chip",
|
||||||
avatar: 'https://i.imgur.com/Qpw6j8D.png'
|
avatar: 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/200px-Rotating_earth_%28large%29.gif'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ import { useApp } from "../../../os/apps/hooks/useApps";
|
|||||||
import { AddContactModal } from "./ContactModal";
|
import { AddContactModal } from "./ContactModal";
|
||||||
import { useModal } from "../hooks/useModal";
|
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 { useContactModal } from "../hooks/useContactModal";
|
||||||
|
import { InfoModal } from "./modal/InfoModal";
|
||||||
|
import { useContactDetail } from "../hooks/useContactDetail";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
@@ -36,7 +38,7 @@ export const ContactsApp = () => {
|
|||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const { showModal, setShowModal } = useModal();
|
const { showModal, setShowModal } = useModal();
|
||||||
const contacts = useApp("CONTACTS");
|
const contacts = useApp("CONTACTS");
|
||||||
const { showContactModal } = useContactModal();
|
const { contactDetail } = useContactDetail();
|
||||||
|
|
||||||
const openModal = () => {
|
const openModal = () => {
|
||||||
setShowModal(true);
|
setShowModal(true);
|
||||||
@@ -47,6 +49,7 @@ export const ContactsApp = () => {
|
|||||||
<AppTitle app={contacts}></AppTitle>
|
<AppTitle app={contacts}></AppTitle>
|
||||||
<SearchContacts />
|
<SearchContacts />
|
||||||
<AddContactModal />
|
<AddContactModal />
|
||||||
|
<InfoModal key={contactDetail?.id} />
|
||||||
<div className={showModal ? classes.backgroundModal : undefined} />
|
<div className={showModal ? classes.backgroundModal : undefined} />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<ContactList />
|
<ContactList />
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
ListItem,
|
ListItem,
|
||||||
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";
|
||||||
@@ -18,39 +18,43 @@ 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 { 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 Nui from "../../../../os/nui-events/utils/Nui";
|
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||||
|
|
||||||
import "../Contact.css"
|
import "../Contact.css";
|
||||||
|
|
||||||
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 classes = useStyles();
|
||||||
const { filteredContacts } = useFilteredContacts();
|
const { filteredContacts } = useFilteredContacts();
|
||||||
const { showContactModal, setShowContactModal } = useContactModal();
|
const { setShowContactModal } = useContactModal();
|
||||||
|
const { contactDetail, setContactDetail } = useContactDetail();
|
||||||
|
|
||||||
const contacts = useContacts();
|
const contacts = useContacts();
|
||||||
|
|
||||||
const openContactInfo = () => {
|
const openContactInfo = (contact) => {
|
||||||
setShowContactModal(!showContactModal);
|
setShowContactModal(true);
|
||||||
}
|
setContactDetail(contact);
|
||||||
|
console.log("CONTACT", contactDetail);
|
||||||
|
};
|
||||||
const startCall = (number) => {
|
const startCall = (number) => {
|
||||||
console.log(number);
|
console.log(number);
|
||||||
Nui.send("phone:startCall", {
|
Nui.send("phone:startCall", {
|
||||||
@@ -60,17 +64,28 @@ export const ContactList = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
{contacts.contacts.filter(contact => contact.display.includes(filteredContacts) || contact.number.includes(filteredContacts)).map((contact) => (
|
{contacts.contacts
|
||||||
|
.filter(
|
||||||
|
(contact) =>
|
||||||
|
contact.display.includes(filteredContacts) ||
|
||||||
|
contact.number.includes(filteredContacts)
|
||||||
|
)
|
||||||
|
.map((contact) => (
|
||||||
<>
|
<>
|
||||||
<ListItem key={contact.id} divider>
|
<ListItem key={contact.id} divider>
|
||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
{contact.avatar ? (
|
{contact.avatar ? (
|
||||||
<MuiAvatar src={contact.avatar} />
|
<MuiAvatar src={contact.avatar} />
|
||||||
): (
|
) : (
|
||||||
<MuiAvatar>{contact.display.slice(0, 1).toUpperCase()}</MuiAvatar>
|
<MuiAvatar>
|
||||||
|
{contact.display.slice(0, 1).toUpperCase()}
|
||||||
|
</MuiAvatar>
|
||||||
)}
|
)}
|
||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText primary={contact.display} secondary={contact.number} />
|
<ListItemText
|
||||||
|
primary={contact.display}
|
||||||
|
secondary={contact.number}
|
||||||
|
/>
|
||||||
<Button onClick={() => startCall(contact.number)}>
|
<Button onClick={() => startCall(contact.number)}>
|
||||||
<PhoneIcon />
|
<PhoneIcon />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -81,29 +96,13 @@ export const ContactList = () => {
|
|||||||
>
|
>
|
||||||
<ChatIcon />
|
<ChatIcon />
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={openContactInfo}>
|
<Button
|
||||||
<FontAwesomeIcon icon={faPen} size="lg"/>
|
style={{ margin: -15 }}
|
||||||
|
onClick={() => openContactInfo(contact)}
|
||||||
|
>
|
||||||
|
<MoreVertIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<Collapse in={showContactModal} timeout="auto" unmountOnExit>
|
|
||||||
<List component="div" disablePadding>
|
|
||||||
<ListItem className={classes.collapseItem}>
|
|
||||||
<TextField
|
|
||||||
value={contact.display}
|
|
||||||
/>
|
|
||||||
</ListItem>
|
|
||||||
<ListItem className={classes.collapseItem}>
|
|
||||||
<TextField
|
|
||||||
value={contact.number}
|
|
||||||
/>
|
|
||||||
</ListItem>
|
|
||||||
<ListItem className={classes.collapseItem}>
|
|
||||||
<Button className={classes.updateButton}>
|
|
||||||
Update contact
|
|
||||||
</Button>
|
|
||||||
</ListItem>
|
|
||||||
</List>
|
|
||||||
</Collapse>
|
|
||||||
</>
|
</>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
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}
|
||||||
|
>
|
||||||
|
<Button style={{ margin: 10 }} onClick={closeModal}>
|
||||||
|
<ArrowBackIcon />
|
||||||
|
</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}>
|
||||||
|
Update
|
||||||
|
</Button>
|
||||||
|
<Button onClick={deleteContact} className={classes.deleteButton}>
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Paper>
|
||||||
|
</Slide>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
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;
|
||||||
@@ -16,5 +16,9 @@ export const contactsState = {
|
|||||||
showContactsModal: atom({
|
showContactsModal: atom({
|
||||||
key: 'showContactModal',
|
key: 'showContactModal',
|
||||||
default: false
|
default: false
|
||||||
|
}),
|
||||||
|
contactDetail: atom({
|
||||||
|
key: 'contactDetail',
|
||||||
|
default: null
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { contactsState } from './state';
|
||||||
|
|
||||||
|
export const useContactDetail = (): any => {
|
||||||
|
const [ contactDetail, setContactDetail ] = useRecoilState(contactsState.contactDetail);
|
||||||
|
return { contactDetail, setContactDetail };
|
||||||
|
}
|
||||||
@@ -3,12 +3,6 @@ import { useRecoilState, atom } from "recoil";
|
|||||||
const dialerHistoryState = atom({
|
const dialerHistoryState = atom({
|
||||||
key: "dialerHistory",
|
key: "dialerHistory",
|
||||||
default: [
|
default: [
|
||||||
{
|
|
||||||
id: 0,
|
|
||||||
caller: "Kidz",
|
|
||||||
phoneNumber: "000-1111",
|
|
||||||
type: "incoming",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
caller: "ROCKY",
|
caller: "ROCKY",
|
||||||
|
|||||||
@@ -44,6 +44,11 @@
|
|||||||
"APPS_BANK_ACCOUNT_TITLE": "Account Summary",
|
"APPS_BANK_ACCOUNT_TITLE": "Account Summary",
|
||||||
"APPS_BANK_ACCOUNT_TRANSACTIONS": "Transactions",
|
"APPS_BANK_ACCOUNT_TRANSACTIONS": "Transactions",
|
||||||
"APPS_BANK_ACCOUNT_SEE_TRANSACTION": "See all",
|
"APPS_BANK_ACCOUNT_SEE_TRANSACTION": "See all",
|
||||||
"APPS_BANK_ACTIONS_TRANSFER": "Transfer"
|
"APPS_BANK_ACTIONS_TRANSFER": "Transfer",
|
||||||
|
|
||||||
|
"APPS_CONTACT_FORM_NAME": "Name",
|
||||||
|
"APPS_CONTACT_FORM_NUMBER": "Number",
|
||||||
|
"APPS_CONTACT_FORM_AVATAR": "Avatar URL"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,8 +17,29 @@ on(`__cfx_nui:${events.CONTACTS_ADD_CONTACT}`, (data: any) => {
|
|||||||
const avatar = data.avatar;
|
const avatar = data.avatar;
|
||||||
emitNet(events.CONTACTS_ADD_CONTACT, number, display, avatar);
|
emitNet(events.CONTACTS_ADD_CONTACT, number, display, avatar);
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
emitNet(events.CONTACTS_GET_CONTACTS)
|
|
||||||
}, 500)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onNet(events.CONTACTS_ADD_CONTACT_SUCCESS, () => {
|
||||||
|
emitNet(events.CONTACTS_GET_CONTACTS)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
RegisterNuiCallbackType(events.CONTACTS_UPDATE_CONTACT);
|
||||||
|
on(`__cfx_nui:${events.CONTACTS_UPDATE_CONTACT}`, (data: any) => {
|
||||||
|
const contact = data;
|
||||||
|
emitNet(events.CONTACTS_UPDATE_CONTACT, contact)
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, () => {
|
||||||
|
emitNet(events.CONTACTS_GET_CONTACTS)
|
||||||
|
})
|
||||||
|
|
||||||
|
RegisterNuiCallbackType(events.CONTACTS_DELETE_CONTACT);
|
||||||
|
on(`__cfx_nui:${events.CONTACTS_DELETE_CONTACT}`, (data: any) => {
|
||||||
|
const contact = data;
|
||||||
|
emitNet(events.CONTACTS_DELETE_CONTACT, contact)
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, () => {
|
||||||
|
emitNet(events.CONTACTS_GET_CONTACTS)
|
||||||
|
})
|
||||||
@@ -1,12 +1,20 @@
|
|||||||
import { ESX } from "./server";
|
import { ESX, getSource } from "./server";
|
||||||
import { pool } from "./db";
|
import { pool } from "./db";
|
||||||
import events from "../utils/events";
|
import events from "../utils/events";
|
||||||
|
import { useIdentifier } from './functions'
|
||||||
|
|
||||||
interface Contacts {
|
interface Contacts {
|
||||||
|
id?: number;
|
||||||
display: string;
|
display: string;
|
||||||
number: string;
|
number: string;
|
||||||
|
avatar: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ContactId {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async function fetchAllContacts(identifier: string): Promise<Contacts[]> {
|
async function fetchAllContacts(identifier: string): Promise<Contacts[]> {
|
||||||
const query = "SELECT * FROM npwd_phone_contacts WHERE identifier = ?";
|
const query = "SELECT * FROM npwd_phone_contacts WHERE identifier = ?";
|
||||||
const [results] = await pool.query(query, [identifier]);
|
const [results] = await pool.query(query, [identifier]);
|
||||||
@@ -26,6 +34,25 @@ async function addContact(
|
|||||||
await pool.query(query, [identifier, number, display, avatar]);
|
await pool.query(query, [identifier, number, display, avatar]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateContact(contact: Contacts, identifier: string): Promise<any> {
|
||||||
|
const query = "UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?"
|
||||||
|
await pool.query(query, [
|
||||||
|
contact.number,
|
||||||
|
contact.display,
|
||||||
|
contact.avatar,
|
||||||
|
contact.id,
|
||||||
|
identifier
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteContact(contact: ContactId, identifier: string): Promise<any> {
|
||||||
|
const query = "DELETE FROM npwd_phone_contacts WHERE id = ? AND identifier = ?"
|
||||||
|
await pool.query(query, [
|
||||||
|
contact.id,
|
||||||
|
identifier
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
||||||
try {
|
try {
|
||||||
const _source = (global as any).source;
|
const _source = (global as any).source;
|
||||||
@@ -39,16 +66,36 @@ onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onNet(events.CONTACTS_ADD_CONTACT, (number: string, display: string, avatar: string) => {
|
onNet(events.CONTACTS_ADD_CONTACT, async (number: string, display: string, avatar: string) => {
|
||||||
try {
|
try {
|
||||||
const _source = (global as any).source;
|
const _source = (global as any).source;
|
||||||
const xPlayer = ESX.GetPlayerFromId(_source);
|
const _identifier = await useIdentifier()
|
||||||
const _identifier = xPlayer.getIdentifier()
|
|
||||||
addContact(_identifier, number, display, avatar);
|
addContact(_identifier, number, display, avatar);
|
||||||
//emit(events.CONTACTS_GET_CONTACTS);
|
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source)
|
||||||
|
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
console.log("Failed to add contact: ", error);
|
console.log("Failed to add contact: ", error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
||||||
|
try {
|
||||||
|
const _source = (global as any)._source
|
||||||
|
const _identifier = await useIdentifier()
|
||||||
|
updateContact(contact, _identifier)
|
||||||
|
emitNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, _source)
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
||||||
|
try {
|
||||||
|
const _identifier = await useIdentifier()
|
||||||
|
deleteContact(contact, _identifier)
|
||||||
|
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, getSource())
|
||||||
|
} catch (error) {
|
||||||
|
console.log("DELETE CONTACT ERROR", error)
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -32,7 +32,11 @@ export default {
|
|||||||
CONTACTS_GET_CONTACTS: 'phone:getContacts',
|
CONTACTS_GET_CONTACTS: 'phone:getContacts',
|
||||||
CONTACTS_ADD_CONTACT_NUI: 'contacts:add',
|
CONTACTS_ADD_CONTACT_NUI: 'contacts:add',
|
||||||
CONTACTS_ADD_CONTACT: 'contacts:add',
|
CONTACTS_ADD_CONTACT: 'contacts:add',
|
||||||
CONTACTS_UPDATE_CONTACTS: 'phone:updateContacts',
|
CONTACTS_ADD_CONTACT_SUCCESS: 'contacts:addSuccess',
|
||||||
|
CONTACTS_UPDATE_CONTACT: 'phone:updateContact',
|
||||||
|
CONTACTS_DELETE_CONTACT: 'phone:deleteContact',
|
||||||
|
CONTACTS_DELETE_CONTACT_SUCCESS: 'contacts:deleteSuccess',
|
||||||
|
CONTACTS_UPDATE_CONTACT_SUCCESS: 'phone:updateContactSuccess',
|
||||||
|
|
||||||
// Sellout
|
// Sellout
|
||||||
SELLOUT_ADD_LISTING: 'phone:addListing',
|
SELLOUT_ADD_LISTING: 'phone:addListing',
|
||||||
|
|||||||
Reference in new issue
Block a user