mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Merge pull request #16 from Re-Ignited-Development/feat/sellout-app
Feat/sellout app
This commit is contained in:
22 files changed
+271
-109
No files matched your search
+14
-14
@@ -37,26 +37,26 @@ setTimeout(() => {
|
|||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
data: {
|
data: {
|
||||||
app: "BANK",
|
app: "CONTACTS",
|
||||||
method: "setContacts",
|
method: "setContacts",
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
number: "345-4366",
|
number: "345-4366",
|
||||||
display: "Gjelten",
|
display: "chip",
|
||||||
avatar: "https://i.imgur.com/Qpw6j8D.png",
|
avatar: 'https://i.imgur.com/Qpw6j8D.png'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
number: "456-4366",
|
number: "456-4366",
|
||||||
display: "Loyd",
|
display: "shit",
|
||||||
avatar: "",
|
avatar: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
number: "123-4366",
|
number: "123-4366",
|
||||||
display: "Fabian",
|
display: "rocky",
|
||||||
avatar: "https://i.imgur.com/B8ta5Aa.jpeg",
|
avatar: 'https://i.imgur.com/B8ta5Aa.jpeg'
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -85,24 +85,24 @@ setTimeout(() => {
|
|||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Donald Trump",
|
name: "Some guy",
|
||||||
number: "123-4567",
|
number: "123-4567",
|
||||||
description:
|
description:
|
||||||
"This is me just selling the whole country, because like why not dude",
|
"Selling this cool car",
|
||||||
img: "some shady link?",
|
url: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
name: "Joe Biden",
|
name: "Some other dude",
|
||||||
number: "666-6666",
|
number: "666-6666",
|
||||||
description: "I think I might buy it Trump!",
|
description: "Selling my wife",
|
||||||
img: "even shadier link?",
|
url: "",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
useNuiService();
|
useNuiService();
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#contact-app .Mui-focused::after {
|
||||||
|
border-bottom: #2196f3 solid 4px;
|
||||||
|
}
|
||||||
@@ -8,9 +8,9 @@ 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';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
@@ -36,6 +36,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 openModal = () => {
|
const openModal = () => {
|
||||||
setShowModal(true);
|
setShowModal(true);
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import ListItemText from "@material-ui/core/ListItemText";
|
import ListItemText from "@material-ui/core/ListItemText";
|
||||||
import { Button, ListItemAvatar, Avatar as MuiAvatar } from "@material-ui/core";
|
import {
|
||||||
|
Button,
|
||||||
|
ListItemAvatar,
|
||||||
|
Avatar as MuiAvatar,
|
||||||
|
List,
|
||||||
|
ListItem,
|
||||||
|
TextField,
|
||||||
|
Collapse,
|
||||||
|
makeStyles
|
||||||
|
} 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";
|
||||||
@@ -9,17 +18,39 @@ 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 { List } from "../../../../ui/components/List";
|
|
||||||
import { ListItem } from "../../../../ui/components/ListItem";
|
|
||||||
import { useContacts } from "../../hooks/useContacts";
|
import { useContacts } from "../../hooks/useContacts";
|
||||||
|
import { useContactModal } from '../../hooks/useContactModal';
|
||||||
|
|
||||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||||
|
|
||||||
|
import "../Contact.css"
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
updateButton: {
|
||||||
|
margin: 'auto',
|
||||||
|
fontSize: 14,
|
||||||
|
width: 150,
|
||||||
|
background: "#2196f3",
|
||||||
|
marginBottom: 10,
|
||||||
|
padding: 8
|
||||||
|
},
|
||||||
|
collapseItem: {
|
||||||
|
margin: 'auto',
|
||||||
|
width: '50%'
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
export const ContactList = () => {
|
export const ContactList = () => {
|
||||||
|
const classes = useStyles()
|
||||||
const { filteredContacts } = useFilteredContacts();
|
const { filteredContacts } = useFilteredContacts();
|
||||||
|
const { showContactModal, setShowContactModal } = useContactModal();
|
||||||
|
|
||||||
const contacts = useContacts();
|
const contacts = useContacts();
|
||||||
|
|
||||||
|
const openContactInfo = () => {
|
||||||
|
setShowContactModal(!showContactModal);
|
||||||
|
}
|
||||||
const startCall = (number) => {
|
const startCall = (number) => {
|
||||||
console.log(number);
|
console.log(number);
|
||||||
Nui.send("phone:startCall", {
|
Nui.send("phone:startCall", {
|
||||||
@@ -29,40 +60,52 @@ export const ContactList = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
{contacts.contacts
|
{contacts.contacts.filter(contact => contact.display.includes(filteredContacts) || contact.number.includes(filteredContacts)).map((contact) => (
|
||||||
.filter(
|
<>
|
||||||
(contact) =>
|
<ListItem key={contact.id} divider>
|
||||||
contact.display.includes(filteredContacts) ||
|
<ListItemAvatar>
|
||||||
contact.number.includes(filteredContacts)
|
{contact.avatar ? (
|
||||||
)
|
<MuiAvatar src={contact.avatar} />
|
||||||
.map((contact) => (
|
): (
|
||||||
<ListItem key={contact.id} divider>
|
<MuiAvatar>{contact.display.slice(0, 1).toUpperCase()}</MuiAvatar>
|
||||||
<ListItemAvatar>
|
)}
|
||||||
{contact.avatar ? (
|
</ListItemAvatar>
|
||||||
<MuiAvatar src={contact.avatar} />
|
<ListItemText primary={contact.display} secondary={contact.number} />
|
||||||
) : (
|
<Button onClick={() => startCall(contact.number)}>
|
||||||
<MuiAvatar>{contact.display.slice(0, 1)}</MuiAvatar>
|
<PhoneIcon />
|
||||||
)}
|
</Button>
|
||||||
</ListItemAvatar>
|
<Button
|
||||||
<ListItemText
|
onClick={() =>
|
||||||
primary={contact.display}
|
console.log("Message: " + contact.display, contact.number)
|
||||||
secondary={contact.number}
|
}
|
||||||
/>
|
>
|
||||||
<Button onClick={() => startCall(contact.number)}>
|
<ChatIcon />
|
||||||
<PhoneIcon />
|
</Button>
|
||||||
</Button>
|
<Button onClick={openContactInfo}>
|
||||||
<Button
|
<FontAwesomeIcon icon={faPen} size="lg"/>
|
||||||
onClick={() =>
|
</Button>
|
||||||
console.log("Message: " + contact.display, contact.number)
|
</ListItem>
|
||||||
}
|
<Collapse in={showContactModal} timeout="auto" unmountOnExit>
|
||||||
>
|
<List component="div" disablePadding>
|
||||||
<ChatIcon />
|
<ListItem className={classes.collapseItem}>
|
||||||
</Button>
|
<TextField
|
||||||
<Button>
|
value={contact.display}
|
||||||
<FontAwesomeIcon icon={faPen} size="lg" />
|
/>
|
||||||
</Button>
|
</ListItem>
|
||||||
</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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -10,7 +10,11 @@ export const contactsState = {
|
|||||||
default: false,
|
default: false,
|
||||||
}),
|
}),
|
||||||
filterContacts: atom({
|
filterContacts: atom({
|
||||||
key: "filterContacts",
|
key: 'filterContacts',
|
||||||
default: "",
|
default: ""
|
||||||
}),
|
}),
|
||||||
|
showContactsModal: atom({
|
||||||
|
key: 'showContactModal',
|
||||||
|
default: false
|
||||||
|
})
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { contactsState } from './state';
|
||||||
|
|
||||||
|
export const useContactModal = () => {
|
||||||
|
const [ showContactModal, setShowContactModal ] = useRecoilState(contactsState.showContactsModal);
|
||||||
|
return { showContactModal, setShowContactModal };
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ interface Contact {
|
|||||||
id: string;
|
id: string;
|
||||||
display: string;
|
display: string;
|
||||||
number: string;
|
number: string;
|
||||||
img?: string;
|
avatar?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IUseContacts {
|
interface IUseContacts {
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
#sellout-app .Mui-selected {
|
#sellout-app .Mui-selected {
|
||||||
color: #f44336 !important;
|
color: #f44336 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#sellout-app .Mui-focused::after {
|
||||||
|
border-bottom: #f44336 solid 3px;
|
||||||
|
}
|
||||||
@@ -51,14 +51,16 @@ export const SelloutItem = (listing) => {
|
|||||||
<Typography className={classes.headerTypo} variant="h5">
|
<Typography className={classes.headerTypo} variant="h5">
|
||||||
{listing.name}
|
{listing.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
{/*<Typography
|
||||||
className={classes.headerTypo}
|
className={classes.headerTypo}
|
||||||
style={{ borderBottom: "1px solid #f44336" }}
|
style={{ borderBottom: "1px solid #f44336" }}
|
||||||
>
|
>
|
||||||
{listing.number}
|
{listing.number}
|
||||||
</Typography>
|
</Typography>*/}
|
||||||
</div>
|
</div>
|
||||||
<ImageDisplay imgURL={listing.img} />
|
{listing.url ? (
|
||||||
|
<ImageDisplay imgURL={listing.url} />
|
||||||
|
): null }
|
||||||
<Typography variant="h6" className={classes.desc}>
|
<Typography variant="h6" className={classes.desc}>
|
||||||
{listing.description}
|
{listing.description}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { makeStyles, Button, TextField } from "@material-ui/core";
|
import { makeStyles, Button, TextField } from "@material-ui/core";
|
||||||
|
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||||
|
|
||||||
|
import "../Sellout.css"
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -27,11 +30,25 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
|
|
||||||
export const ListingForm = () => {
|
export const ListingForm = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
|
const [ title, setTitle ] = useState('');
|
||||||
|
const [ url, setUrl ] = useState('');
|
||||||
|
const [ desc, setDesc ] = useState('');
|
||||||
|
|
||||||
|
const addListing = () => {
|
||||||
|
Nui.send('phone:addListing', {
|
||||||
|
title,
|
||||||
|
url,
|
||||||
|
desc
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<h1>New Listing</h1>
|
<h1>New Listing</h1>
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
|
onChange={e => setTitle(e.target.value)}
|
||||||
placeholder="Title on listing.."
|
placeholder="Title on listing.."
|
||||||
inputProps={{ className: classes.textFieldInput }}
|
inputProps={{ className: classes.textFieldInput }}
|
||||||
style={{ width: "80%" }}
|
style={{ width: "80%" }}
|
||||||
@@ -41,6 +58,7 @@ export const ListingForm = () => {
|
|||||||
<TextField
|
<TextField
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
placeholder="Image URL"
|
placeholder="Image URL"
|
||||||
|
onChange={e => setUrl(e.target.value)}
|
||||||
inputProps={{ className: classes.textFieldInput }}
|
inputProps={{ className: classes.textFieldInput }}
|
||||||
style={{ width: "80%" }}
|
style={{ width: "80%" }}
|
||||||
size="medium"
|
size="medium"
|
||||||
@@ -49,6 +67,7 @@ export const ListingForm = () => {
|
|||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
|
onChange={e => setDesc(e.target.value)}
|
||||||
placeholder="Description"
|
placeholder="Description"
|
||||||
inputProps={{ className: classes.multilineFieldInput }}
|
inputProps={{ className: classes.multilineFieldInput }}
|
||||||
style={{ width: "80%" }}
|
style={{ width: "80%" }}
|
||||||
@@ -58,7 +77,7 @@ export const ListingForm = () => {
|
|||||||
variant="outlined"
|
variant="outlined"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button className={classes.postButton}>Post</Button>
|
<Button onClick={addListing} className={classes.postButton}>Post</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -5,7 +5,6 @@ import { BottomNavigation, BottomNavigationAction } from "@material-ui/core";
|
|||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faHome } from "@fortawesome/free-solid-svg-icons";
|
import { faHome } from "@fortawesome/free-solid-svg-icons";
|
||||||
import AddCircleIcon from "@material-ui/icons/AddCircle";
|
import AddCircleIcon from "@material-ui/icons/AddCircle";
|
||||||
import FaceIcon from "@material-ui/icons/Face";
|
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -38,11 +37,6 @@ export const NavigationBar = () => {
|
|||||||
icon={<AddCircleIcon />}
|
icon={<AddCircleIcon />}
|
||||||
to="/sellout/new"
|
to="/sellout/new"
|
||||||
/>
|
/>
|
||||||
<BottomNavigationAction
|
|
||||||
component={Link}
|
|
||||||
icon={<FaceIcon />}
|
|
||||||
to="/sellout/new"
|
|
||||||
/>
|
|
||||||
</BottomNavigation>
|
</BottomNavigation>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -3,6 +3,6 @@ import { atom } from "recoil";
|
|||||||
export const selloutState = {
|
export const selloutState = {
|
||||||
listing: atom({
|
listing: atom({
|
||||||
key: "listing",
|
key: "listing",
|
||||||
default: null,
|
default: [],
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -32,11 +32,6 @@ export const Navigation = () => {
|
|||||||
className={classes.root}
|
className={classes.root}
|
||||||
onChange={(_e, value) => value()}
|
onChange={(_e, value) => value()}
|
||||||
>
|
>
|
||||||
<BottomNavigationAction
|
|
||||||
label="Phone"
|
|
||||||
value={() => history.push("/phone")}
|
|
||||||
icon={<PhoneIcon />}
|
|
||||||
/>
|
|
||||||
<BottomNavigationAction
|
<BottomNavigationAction
|
||||||
label="Home"
|
label="Home"
|
||||||
value={() => history.push("/")}
|
value={() => history.push("/")}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ on(`__cfx_nui:${events.CONTACTS_ADD_CONTACT}`, (data: any) => {
|
|||||||
emitNet(events.CONTACTS_ADD_CONTACT, number, display, avatar);
|
emitNet(events.CONTACTS_ADD_CONTACT, number, display, avatar);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
emitNet(events.CONTACTS_GET_CONTACTS)
|
||||||
}, 1000);
|
}, 500)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -235,9 +235,10 @@ async function Phone() {
|
|||||||
isPhoneOpen = true;
|
isPhoneOpen = true;
|
||||||
await phoneOpenAnim();
|
await phoneOpenAnim();
|
||||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||||
emitNet("phone:getCredentials"); // Gets the credentials. Will eventually most likely only get the phone number and name, idk.
|
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||||
SetCursorLocation(0.936, 0.922); //Experimental
|
emitNet('phone:getCredentials') // Gets the credentials. Will eventually most likely only get the phone number and name, idk.
|
||||||
let res = GetActiveScreenResolution();
|
SetCursorLocation(0.936, 0.922) //Experimental
|
||||||
|
let res = GetActiveScreenResolution()
|
||||||
SendNuiMessage(
|
SendNuiMessage(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
app: "PHONE",
|
app: "PHONE",
|
||||||
@@ -270,9 +271,10 @@ async function Phone() {
|
|||||||
isPhoneOpen = true;
|
isPhoneOpen = true;
|
||||||
await phoneOpenAnim();
|
await phoneOpenAnim();
|
||||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||||
emitNet("phone:getCredentials");
|
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||||
SetCursorLocation(0.936, 0.922); //Experimental
|
emitNet('phone:getCredentials')
|
||||||
let res = GetActiveScreenResolution();
|
SetCursorLocation(0.936, 0.922) //Experimental
|
||||||
|
let res = GetActiveScreenResolution()
|
||||||
SendNuiMessage(
|
SendNuiMessage(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
app: "PHONE",
|
app: "PHONE",
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import events from '../utils/events';
|
||||||
|
|
||||||
|
RegisterNuiCallbackType(events.SELLOUT_ADD_LISTING);
|
||||||
|
on(`__cfx_nui:${events.SELLOUT_ADD_LISTING}`, (data: any) => {
|
||||||
|
emitNet(events.SELLOUT_ADD_LISTING, data)
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||||
|
console.log("Fetched")
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.SELLOUT_SEND_LISTING, (listing: any) => {
|
||||||
|
SendNuiMessage(
|
||||||
|
JSON.stringify({
|
||||||
|
app: "SELLOUT",
|
||||||
|
method: "setListings",
|
||||||
|
data: listing
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
import { ESXClient } from "fivem-esx-js/client/esx_client";
|
import { ESXClient } from "fivem-esx-js/client/esx_client";
|
||||||
import "./cl_main";
|
import './cl_main';
|
||||||
import "./cl_twitter";
|
import './cl_twitter';
|
||||||
import "./cl_contacts";
|
import './cl_contacts';
|
||||||
|
import './cl_sellout';
|
||||||
|
|
||||||
export let ESX: ESXClient = null;
|
export let ESX: ESXClient = null;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { pool } from './db';
|
||||||
|
import { ESX, getSource } from './server';
|
||||||
|
|
||||||
|
export const usePhoneNumber = async (identifier: string) => {
|
||||||
|
const query = "SELECT phone_number FROM users WHERE identifier = ?"
|
||||||
|
const result = await pool.query(query, [identifier]);
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
import { ESXServer } from "fivem-esx-js/server/esx_server";
|
import { ESXServer } from "fivem-esx-js/server/esx_server";
|
||||||
|
|
||||||
import "./db";
|
import './db';
|
||||||
import "./sv_twitter";
|
import './sv_twitter';
|
||||||
import "./sv_main";
|
import './sv_main';
|
||||||
import "./sv_contacts";
|
import './sv_contacts';
|
||||||
|
import './sv_sellout';
|
||||||
|
|
||||||
export let ESX: ESXServer = null;
|
export let ESX: ESXServer = null;
|
||||||
|
|
||||||
|
|||||||
@@ -37,19 +37,17 @@ onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Failed to fetch contacts: ", error);
|
console.log("Failed to fetch contacts: ", error);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.CONTACTS_ADD_CONTACT, (number: string, display: string, avatar: string) => {
|
||||||
|
try {
|
||||||
|
const _source = (global as any).source;
|
||||||
|
const xPlayer = ESX.GetPlayerFromId(_source);
|
||||||
|
const _identifier = xPlayer.getIdentifier()
|
||||||
|
addContact(_identifier, number, display, avatar);
|
||||||
|
//emit(events.CONTACTS_GET_CONTACTS);
|
||||||
|
|
||||||
|
} catch(error) {
|
||||||
|
console.log("Failed to add contact: ", error);
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(
|
|
||||||
events.CONTACTS_ADD_CONTACT,
|
|
||||||
(number: string, display: string, avatar: string) => {
|
|
||||||
try {
|
|
||||||
const _source = (global as any).source;
|
|
||||||
const xPlayer = ESX.GetPlayerFromId(_source);
|
|
||||||
const _identifier = xPlayer.getIdentifier();
|
|
||||||
addContact(_identifier, number, display, avatar);
|
|
||||||
emit(events.CONTACTS_GET_CONTACTS);
|
|
||||||
} catch (error) {
|
|
||||||
console.log("Failed to add contact: ", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import events from '../utils/events';
|
||||||
|
import { ESX, getSource } from './server';
|
||||||
|
import { pool } from './db';
|
||||||
|
|
||||||
|
|
||||||
|
interface IListing {
|
||||||
|
title: string;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function addListing(identifier: string, name: string, title: string, url: string, description: string): Promise<any> {
|
||||||
|
const query = "INSERT INTO npwd_sellout_listings (identifier, name, title, url, description) VALUES (?, ?, ?, ?, ?)"
|
||||||
|
console.log("hallllllollooooo");
|
||||||
|
await pool.query(query, [identifier, name, title, url, description])
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchAllListings(): Promise<IListing[]> {
|
||||||
|
const query = "SELECT * FROM npwd_sellout_listings ORDER BY id DESC";
|
||||||
|
|
||||||
|
const [ results ] = await pool.query(query);
|
||||||
|
const listings = <IListing[]>results;
|
||||||
|
|
||||||
|
return listings;
|
||||||
|
}
|
||||||
|
|
||||||
|
onNet(events.SELLOUT_ADD_LISTING, (data: any) => {
|
||||||
|
try {
|
||||||
|
const xPlayer = ESX.GetPlayerFromId(getSource())
|
||||||
|
const _identifier = xPlayer.getIdentifier()
|
||||||
|
const name = xPlayer.getName()
|
||||||
|
console.log("ADDED")
|
||||||
|
|
||||||
|
addListing(_identifier, name, data.title, data.url, data.desc)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
||||||
|
try {
|
||||||
|
console.log("Fetching all listings")
|
||||||
|
const listings = await fetchAllListings();
|
||||||
|
console.log("ADDED")
|
||||||
|
emitNet(events.SELLOUT_SEND_LISTING, getSource(), listings)
|
||||||
|
|
||||||
|
} catch(error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -22,9 +22,14 @@ export default {
|
|||||||
TWITTER_TOGGLE_LIKE_FAILURE: "toggleLikeFailed",
|
TWITTER_TOGGLE_LIKE_FAILURE: "toggleLikeFailed",
|
||||||
|
|
||||||
// Contacts
|
// Contacts
|
||||||
CONTACTS_SEND_CONTACTS: "phone:sendContacts",
|
CONTACTS_SEND_CONTACTS: 'phone:sendContacts',
|
||||||
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_UPDATE_CONTACTS: 'phone:updateContacts',
|
||||||
};
|
|
||||||
|
// Sellout
|
||||||
|
SELLOUT_ADD_LISTING: 'phone:addListing',
|
||||||
|
SELLOUT_FETCH_LISTING: 'phone:fetchAllListing',
|
||||||
|
SELLOUT_SEND_LISTING: 'phone:sendAllListings'
|
||||||
|
}
|
||||||
Reference in new issue
Block a user