diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx
index b2dbd8b..2aa27b1 100644
--- a/phone/src/Phone.tsx
+++ b/phone/src/Phone.tsx
@@ -37,26 +37,26 @@ setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
data: {
- app: "BANK",
+ app: "CONTACTS",
method: "setContacts",
data: [
{
id: 1,
number: "345-4366",
- display: "Gjelten",
- avatar: "https://i.imgur.com/Qpw6j8D.png",
+ display: "chip",
+ avatar: 'https://i.imgur.com/Qpw6j8D.png'
},
{
id: 2,
number: "456-4366",
- display: "Loyd",
- avatar: "",
+ display: "shit",
+ avatar: ''
},
{
id: 3,
number: "123-4366",
- display: "Fabian",
- avatar: "https://i.imgur.com/B8ta5Aa.jpeg",
+ display: "rocky",
+ avatar: 'https://i.imgur.com/B8ta5Aa.jpeg'
},
],
},
@@ -85,24 +85,24 @@ setTimeout(() => {
data: [
{
id: 1,
- name: "Donald Trump",
+ name: "Some guy",
number: "123-4567",
description:
- "This is me just selling the whole country, because like why not dude",
- img: "some shady link?",
+ "Selling this cool car",
+ url: "",
},
{
id: 2,
- name: "Joe Biden",
+ name: "Some other dude",
number: "666-6666",
- description: "I think I might buy it Trump!",
- img: "even shadier link?",
+ description: "Selling my wife",
+ url: "",
},
],
},
})
);
-});
+}, 1000);
function Phone() {
useNuiService();
diff --git a/phone/src/apps/contacts/components/Contact.css b/phone/src/apps/contacts/components/Contact.css
new file mode 100644
index 0000000..a6986f2
--- /dev/null
+++ b/phone/src/apps/contacts/components/Contact.css
@@ -0,0 +1,3 @@
+#contact-app .Mui-focused::after {
+ border-bottom: #2196f3 solid 4px;
+}
\ No newline at end of file
diff --git a/phone/src/apps/contacts/components/ContactsApp.tsx b/phone/src/apps/contacts/components/ContactsApp.tsx
index 4517555..fa47d34 100644
--- a/phone/src/apps/contacts/components/ContactsApp.tsx
+++ b/phone/src/apps/contacts/components/ContactsApp.tsx
@@ -8,9 +8,9 @@ import { useApp } from "../../../os/apps/hooks/useApps";
import { AddContactModal } from "./ContactModal";
import { useModal } from "../hooks/useModal";
import { SearchContacts } from "./List/SearchContacts";
-import PersonAddIcon from "@material-ui/icons/PersonAdd";
-
-import Fab from "@material-ui/core/Fab";
+import PersonAddIcon from '@material-ui/icons/PersonAdd'
+import Fab from '@material-ui/core/Fab';
+import { useContactModal } from '../hooks/useContactModal';
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@@ -36,6 +36,7 @@ export const ContactsApp = () => {
const classes = useStyles();
const { showModal, setShowModal } = useModal();
const contacts = useApp("CONTACTS");
+ const { showContactModal } = useContactModal();
const openModal = () => {
setShowModal(true);
diff --git a/phone/src/apps/contacts/components/List/ContactList.tsx b/phone/src/apps/contacts/components/List/ContactList.tsx
index e77698b..699111c 100644
--- a/phone/src/apps/contacts/components/List/ContactList.tsx
+++ b/phone/src/apps/contacts/components/List/ContactList.tsx
@@ -1,6 +1,15 @@
import React from "react";
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 { faPen } from "@fortawesome/free-solid-svg-icons";
@@ -9,17 +18,39 @@ import { useFilteredContacts } from "../../hooks/useFilteredContacts";
import PhoneIcon from "@material-ui/icons/Phone";
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 { useContactModal } from '../../hooks/useContactModal';
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 = () => {
+ const classes = useStyles()
const { filteredContacts } = useFilteredContacts();
+ const { showContactModal, setShowContactModal } = useContactModal();
const contacts = useContacts();
+ const openContactInfo = () => {
+ setShowContactModal(!showContactModal);
+ }
const startCall = (number) => {
console.log(number);
Nui.send("phone:startCall", {
@@ -29,40 +60,52 @@ export const ContactList = () => {
return (
- {contacts.contacts
- .filter(
- (contact) =>
- contact.display.includes(filteredContacts) ||
- contact.number.includes(filteredContacts)
- )
- .map((contact) => (
-
-
- {contact.avatar ? (
-
- ) : (
- {contact.display.slice(0, 1)}
- )}
-
-
-
-
-
-
- ))}
+ {contacts.contacts.filter(contact => contact.display.includes(filteredContacts) || contact.number.includes(filteredContacts)).map((contact) => (
+ <>
+
+
+ {contact.avatar ? (
+
+ ): (
+ {contact.display.slice(0, 1).toUpperCase()}
+ )}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ ))}
);
};
diff --git a/phone/src/apps/contacts/hooks/state.ts b/phone/src/apps/contacts/hooks/state.ts
index d0784e0..8d725c3 100644
--- a/phone/src/apps/contacts/hooks/state.ts
+++ b/phone/src/apps/contacts/hooks/state.ts
@@ -10,7 +10,11 @@ export const contactsState = {
default: false,
}),
filterContacts: atom({
- key: "filterContacts",
- default: "",
+ key: 'filterContacts',
+ default: ""
}),
+ showContactsModal: atom({
+ key: 'showContactModal',
+ default: false
+ })
};
diff --git a/phone/src/apps/contacts/hooks/useContactModal.ts b/phone/src/apps/contacts/hooks/useContactModal.ts
new file mode 100644
index 0000000..ce448bf
--- /dev/null
+++ b/phone/src/apps/contacts/hooks/useContactModal.ts
@@ -0,0 +1,7 @@
+import { useRecoilState } from 'recoil';
+import { contactsState } from './state';
+
+export const useContactModal = () => {
+ const [ showContactModal, setShowContactModal ] = useRecoilState(contactsState.showContactsModal);
+ return { showContactModal, setShowContactModal };
+}
\ No newline at end of file
diff --git a/phone/src/apps/contacts/hooks/useContacts.ts b/phone/src/apps/contacts/hooks/useContacts.ts
index e83a7a2..b52fc7e 100644
--- a/phone/src/apps/contacts/hooks/useContacts.ts
+++ b/phone/src/apps/contacts/hooks/useContacts.ts
@@ -5,7 +5,7 @@ interface Contact {
id: string;
display: string;
number: string;
- img?: string;
+ avatar?: string
}
interface IUseContacts {
diff --git a/phone/src/apps/sellout/components/Sellout.css b/phone/src/apps/sellout/components/Sellout.css
index 13183d3..8310949 100644
--- a/phone/src/apps/sellout/components/Sellout.css
+++ b/phone/src/apps/sellout/components/Sellout.css
@@ -1,3 +1,8 @@
#sellout-app .Mui-selected {
color: #f44336 !important;
}
+
+
+#sellout-app .Mui-focused::after {
+ border-bottom: #f44336 solid 3px;
+}
\ No newline at end of file
diff --git a/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx b/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx
index 3e93cba..4b24873 100644
--- a/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx
+++ b/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx
@@ -51,14 +51,16 @@ export const SelloutItem = (listing) => {
{listing.name}
-
{listing.number}
-
+ */}
-
+ {listing.url ? (
+
+ ): null }
{listing.description}
diff --git a/phone/src/apps/sellout/components/form/ListingForm.tsx b/phone/src/apps/sellout/components/form/ListingForm.tsx
index 669a91f..198a2ce 100644
--- a/phone/src/apps/sellout/components/form/ListingForm.tsx
+++ b/phone/src/apps/sellout/components/form/ListingForm.tsx
@@ -1,5 +1,8 @@
-import React from "react";
+import React, { useState } from "react";
import { makeStyles, Button, TextField } from "@material-ui/core";
+import Nui from "../../../../os/nui-events/utils/Nui";
+
+import "../Sellout.css"
const useStyles = makeStyles((theme) => ({
root: {
@@ -27,11 +30,25 @@ const useStyles = makeStyles((theme) => ({
export const ListingForm = () => {
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 (
New Listing
setTitle(e.target.value)}
placeholder="Title on listing.."
inputProps={{ className: classes.textFieldInput }}
style={{ width: "80%" }}
@@ -41,6 +58,7 @@ export const ListingForm = () => {
setUrl(e.target.value)}
inputProps={{ className: classes.textFieldInput }}
style={{ width: "80%" }}
size="medium"
@@ -49,6 +67,7 @@ export const ListingForm = () => {
setDesc(e.target.value)}
placeholder="Description"
inputProps={{ className: classes.multilineFieldInput }}
style={{ width: "80%" }}
@@ -58,7 +77,7 @@ export const ListingForm = () => {
variant="outlined"
/>
-
+
);
};
diff --git a/phone/src/apps/sellout/components/navigation/NavigationBar.tsx b/phone/src/apps/sellout/components/navigation/NavigationBar.tsx
index c6a25ab..85d38da 100644
--- a/phone/src/apps/sellout/components/navigation/NavigationBar.tsx
+++ b/phone/src/apps/sellout/components/navigation/NavigationBar.tsx
@@ -5,7 +5,6 @@ import { BottomNavigation, BottomNavigationAction } from "@material-ui/core";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faHome } from "@fortawesome/free-solid-svg-icons";
import AddCircleIcon from "@material-ui/icons/AddCircle";
-import FaceIcon from "@material-ui/icons/Face";
const useStyles = makeStyles((theme) => ({
root: {
@@ -38,11 +37,6 @@ export const NavigationBar = () => {
icon={}
to="/sellout/new"
/>
- }
- to="/sellout/new"
- />
);
};
diff --git a/phone/src/apps/sellout/hooks/state.ts b/phone/src/apps/sellout/hooks/state.ts
index 94a8407..46d6a3e 100644
--- a/phone/src/apps/sellout/hooks/state.ts
+++ b/phone/src/apps/sellout/hooks/state.ts
@@ -3,6 +3,6 @@ import { atom } from "recoil";
export const selloutState = {
listing: atom({
key: "listing",
- default: null,
+ default: [],
}),
};
diff --git a/phone/src/os/navigation-bar/components/Navigation.tsx b/phone/src/os/navigation-bar/components/Navigation.tsx
index 8000d74..a15019a 100644
--- a/phone/src/os/navigation-bar/components/Navigation.tsx
+++ b/phone/src/os/navigation-bar/components/Navigation.tsx
@@ -32,11 +32,6 @@ export const Navigation = () => {
className={classes.root}
onChange={(_e, value) => value()}
>
- history.push("/phone")}
- icon={}
- />
history.push("/")}
diff --git a/resources/client/cl_contacts.ts b/resources/client/cl_contacts.ts
index a0db548..df91fde 100644
--- a/resources/client/cl_contacts.ts
+++ b/resources/client/cl_contacts.ts
@@ -19,6 +19,7 @@ on(`__cfx_nui:${events.CONTACTS_ADD_CONTACT}`, (data: any) => {
emitNet(events.CONTACTS_ADD_CONTACT, number, display, avatar);
setTimeout(() => {
- emitNet(events.CONTACTS_GET_CONTACTS);
- }, 1000);
+ emitNet(events.CONTACTS_GET_CONTACTS)
+ }, 500)
});
+
diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts
index 0a78454..17e8df2 100644
--- a/resources/client/cl_main.ts
+++ b/resources/client/cl_main.ts
@@ -235,9 +235,10 @@ async function Phone() {
isPhoneOpen = true;
await phoneOpenAnim();
emitNet(events.CONTACTS_GET_CONTACTS);
- emitNet("phone:getCredentials"); // Gets the credentials. Will eventually most likely only get the phone number and name, idk.
- SetCursorLocation(0.936, 0.922); //Experimental
- let res = GetActiveScreenResolution();
+ emitNet(events.SELLOUT_FETCH_LISTING);
+ emitNet('phone:getCredentials') // Gets the credentials. Will eventually most likely only get the phone number and name, idk.
+ SetCursorLocation(0.936, 0.922) //Experimental
+ let res = GetActiveScreenResolution()
SendNuiMessage(
JSON.stringify({
app: "PHONE",
@@ -270,9 +271,10 @@ async function Phone() {
isPhoneOpen = true;
await phoneOpenAnim();
emitNet(events.CONTACTS_GET_CONTACTS);
- emitNet("phone:getCredentials");
- SetCursorLocation(0.936, 0.922); //Experimental
- let res = GetActiveScreenResolution();
+ emitNet(events.SELLOUT_FETCH_LISTING);
+ emitNet('phone:getCredentials')
+ SetCursorLocation(0.936, 0.922) //Experimental
+ let res = GetActiveScreenResolution()
SendNuiMessage(
JSON.stringify({
app: "PHONE",
diff --git a/resources/client/cl_sellout.ts b/resources/client/cl_sellout.ts
new file mode 100644
index 0000000..6a46c92
--- /dev/null
+++ b/resources/client/cl_sellout.ts
@@ -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
+ })
+ )
+})
\ No newline at end of file
diff --git a/resources/client/client.ts b/resources/client/client.ts
index 7e64fba..ec8d76d 100644
--- a/resources/client/client.ts
+++ b/resources/client/client.ts
@@ -1,7 +1,8 @@
import { ESXClient } from "fivem-esx-js/client/esx_client";
-import "./cl_main";
-import "./cl_twitter";
-import "./cl_contacts";
+import './cl_main';
+import './cl_twitter';
+import './cl_contacts';
+import './cl_sellout';
export let ESX: ESXClient = null;
diff --git a/resources/server/functions.ts b/resources/server/functions.ts
new file mode 100644
index 0000000..c9f7c0a
--- /dev/null
+++ b/resources/server/functions.ts
@@ -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
+}
\ No newline at end of file
diff --git a/resources/server/server.ts b/resources/server/server.ts
index 09968a7..f2060ed 100644
--- a/resources/server/server.ts
+++ b/resources/server/server.ts
@@ -1,9 +1,10 @@
import { ESXServer } from "fivem-esx-js/server/esx_server";
-import "./db";
-import "./sv_twitter";
-import "./sv_main";
-import "./sv_contacts";
+import './db';
+import './sv_twitter';
+import './sv_main';
+import './sv_contacts';
+import './sv_sellout';
export let ESX: ESXServer = null;
diff --git a/resources/server/sv_contacts.ts b/resources/server/sv_contacts.ts
index 8002a7b..154dec7 100644
--- a/resources/server/sv_contacts.ts
+++ b/resources/server/sv_contacts.ts
@@ -37,19 +37,17 @@ onNet(events.CONTACTS_GET_CONTACTS, async () => {
} catch (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);
- }
- }
-);
diff --git a/resources/server/sv_sellout.ts b/resources/server/sv_sellout.ts
new file mode 100644
index 0000000..bbf1667
--- /dev/null
+++ b/resources/server/sv_sellout.ts
@@ -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 {
+ 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 {
+ const query = "SELECT * FROM npwd_sellout_listings ORDER BY id DESC";
+
+ const [ results ] = await pool.query(query);
+ const listings = 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)
+ }
+})
\ No newline at end of file
diff --git a/resources/utils/events.ts b/resources/utils/events.ts
index e13604c..aaef09d 100644
--- a/resources/utils/events.ts
+++ b/resources/utils/events.ts
@@ -22,9 +22,14 @@ export default {
TWITTER_TOGGLE_LIKE_FAILURE: "toggleLikeFailed",
// Contacts
- CONTACTS_SEND_CONTACTS: "phone:sendContacts",
- CONTACTS_GET_CONTACTS: "phone:getContacts",
- CONTACTS_ADD_CONTACT_NUI: "contacts:add",
- CONTACTS_ADD_CONTACT: "contacts:add",
- CONTACTS_UPDATE_CONTACTS: "phone:updateContacts",
-};
+ CONTACTS_SEND_CONTACTS: 'phone:sendContacts',
+ CONTACTS_GET_CONTACTS: 'phone:getContacts',
+ CONTACTS_ADD_CONTACT_NUI: 'contacts:add',
+ CONTACTS_ADD_CONTACT: 'contacts:add',
+ CONTACTS_UPDATE_CONTACTS: 'phone:updateContacts',
+
+ // Sellout
+ SELLOUT_ADD_LISTING: 'phone:addListing',
+ SELLOUT_FETCH_LISTING: 'phone:fetchAllListing',
+ SELLOUT_SEND_LISTING: 'phone:sendAllListings'
+}