diff --git a/config.json b/config.json
index 6b01a9c..c0c10cd 100644
--- a/config.json
+++ b/config.json
@@ -9,7 +9,7 @@
"DestroyPhoneReCheck": 3,
"notificationPosition": {
"horizontal": "right",
- "vertical": "bottom"
+ "vertical": "top"
},
"twitter": {
"showNotifications": true,
@@ -22,5 +22,8 @@
"enableEmojis": true,
"enableImages": true,
"maxImages": 3
+ },
+ "bank": {
+ "showNotifications": true
}
}
\ No newline at end of file
diff --git a/phone/src/Phone.css b/phone/src/Phone.css
index d61685c..f4daefb 100644
--- a/phone/src/Phone.css
+++ b/phone/src/Phone.css
@@ -33,6 +33,9 @@
top: 100px;
display: flex;
flex-direction: column;
+ background-position: center;
+ background-size: cover;
+ background-repeat: no-repeat;
}
.PhoneAppContainer {
diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx
index c3a0eb1..4adb30e 100644
--- a/phone/src/Phone.tsx
+++ b/phone/src/Phone.tsx
@@ -21,6 +21,7 @@ import { useTwitterService } from "./apps/twitter/hooks/useTwitterService";
import { useSelloutService } from "./apps/sellout/hooks/useSelloutService";
import { useBankService } from './apps/bank/hooks/useBankService';
import { useMessagesService } from "./apps/messages/hooks/useMessageService";
+import { useNotesService } from "./apps/notes/hooks/useNotesService";
//These events are just for testing. Comment it out before building.
setTimeout(() => {
@@ -35,25 +36,35 @@ setTimeout(() => {
);
}, 1000);
+setTimeout(() => {
+ window.dispatchEvent(
+ new MessageEvent("message", {
+ data: {
+ app: "PHONE",
+ method: "setVisibility",
+ data: true,
+ },
+ })
+ );
+}, 1000);
+
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
- data: {
- app: "MESSAGES",
- method: "setConversations",
+ data: {
+ app: 'NOTES',
+ method: 'setNotes',
data: [
{
id: 1,
- name: 'rocky'
+ title: 'First note',
+ content: 'Hello, this is my shitty note'
},
{
id: 2,
- name: 'ark'
+ title: 'Second note',
+ content: 'Hello, this is another shitty note'
},
- {
- id: 3,
- name: 'kire'
- }
]
}
})
@@ -61,39 +72,30 @@ setTimeout(() => {
}, 1000)
setTimeout(() => {
- window.dispatchEvent(
- new MessageEvent("message", {
+ new MessageEvent("messsage", {
+ data: {
+ app: "BANK",
+ method: "setNotification",
data: {
- app: "MESSAGES",
- method: "setMessages",
- data: [
- {
- id: 1,
- sender: 'chip',
- receiver: 'rocky',
- sms: 'Hello there',
- owner: 1
- },
- {
- id: 2,
- sender: 'chip',
- receiver: 'depo',
- sms: 'Hello man',
- owner: 1
- },
- {
- id: 2,
- sender: 'rocky',
- receiver: 'kire',
- sms: 'Hello dude',
- owner: 1
- }
- ]
+ id: 1,
+ message: "ahhaha"
}
- })
- );
-}, 1000);
+ }
+ })
+}, 1000)
+setTimeout(() => {
+ new MessageEvent("messsage", {
+ data: {
+ app: "TWITTER",
+ method: "setNotification",
+ data: {
+ id: 1,
+ message: "ahhaha"
+ }
+ }
+ })
+}, 1000)
setTimeout(() => {
window.dispatchEvent(
@@ -170,7 +172,7 @@ setTimeout(() => {
id: 1,
number: "345-4366",
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,
@@ -190,18 +192,6 @@ setTimeout(() => {
);
}, 1000);
-setTimeout(() => {
- window.dispatchEvent(
- new MessageEvent("message", {
- data: {
- app: "PHONE",
- method: "setVisibility",
- data: true,
- },
- })
- );
-}, 1000);
-
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
@@ -244,6 +234,7 @@ function Phone() {
useSelloutService();
useBankService();
useMessagesService()
+ useNotesService();
if (visibility === false) {
return null;
diff --git a/phone/src/apps/bank/components/BankApp.css b/phone/src/apps/bank/components/BankApp.css
index 64993ad..ad19ba4 100644
--- a/phone/src/apps/bank/components/BankApp.css
+++ b/phone/src/apps/bank/components/BankApp.css
@@ -31,6 +31,11 @@
color: #388CF8 !important;
}
+
+#bank-app .MuiSnackbar-root {
+ position: absolute;
+}
+
#bank-title {
font-family: 'Bebas Neue', cursive;
font-size: 50px;
diff --git a/phone/src/apps/bank/components/BankApp.tsx b/phone/src/apps/bank/components/BankApp.tsx
index cfc38c9..55415f5 100644
--- a/phone/src/apps/bank/components/BankApp.tsx
+++ b/phone/src/apps/bank/components/BankApp.tsx
@@ -21,6 +21,7 @@ import { NavigationBar } from "./navigation/NavigationBar";
import { BankHome } from './home/BankHome';
import { BankAccount } from './account/BankAccount';
import { TransactionList } from "./transactions/TransactionList";
+import { BankAlert } from "./alert/BankAlert";
const useStyles = makeStyles((theme) => ({
root: {
@@ -67,6 +68,7 @@ export const BankApp = () => {
+
diff --git a/phone/src/apps/bank/components/alert/Alert.tsx b/phone/src/apps/bank/components/alert/Alert.tsx
new file mode 100644
index 0000000..2ba1e67
--- /dev/null
+++ b/phone/src/apps/bank/components/alert/Alert.tsx
@@ -0,0 +1,8 @@
+import React from "react";
+import MuiAlert from "@material-ui/lab/Alert";
+
+export function Alert(props) {
+ return ;
+}
+
+export default Alert;
diff --git a/phone/src/apps/bank/components/alert/BankAlert.tsx b/phone/src/apps/bank/components/alert/BankAlert.tsx
new file mode 100644
index 0000000..cda9c51
--- /dev/null
+++ b/phone/src/apps/bank/components/alert/BankAlert.tsx
@@ -0,0 +1,43 @@
+import React, { useState, useEffect } from "react";
+import { useBankAlert } from "../../hooks/useBankAlert";
+import Snackbar from "@material-ui/core/Snackbar";
+import Alert from "./Alert";
+import { useTranslation } from "react-i18next";
+
+export const BankAlert = () => {
+ const { t } = useTranslation();
+ const [open, setOpen] = useState(false);
+ const { bankAlert, setBankAlert } = useBankAlert();
+ const [ message, setMessage ] = useState(null);
+ const [severity, setSeverity] = useState("");
+
+ const _handleClose = () => {
+ setOpen(false);
+ setBankAlert(null);
+ };
+
+ useEffect(() => {
+ if (bankAlert === true ) {
+ setOpen(true);
+ setMessage(t("APPS_BANK_ALERT_TRANSFER_SUCCESS"));
+ setSeverity("success")
+ } else if (bankAlert === false) {
+ setOpen(true);
+ setMessage(t("APPS_BANK_ALERT_TRANSFER_FAILURE"));
+ setSeverity("error")
+ }
+ }, [bankAlert])
+
+ return (
+
+
+ {message}
+
+
+ );
+};
\ No newline at end of file
diff --git a/phone/src/apps/bank/components/notification/BankNotification.tsx b/phone/src/apps/bank/components/notification/BankNotification.tsx
index 6f64552..122bff0 100644
--- a/phone/src/apps/bank/components/notification/BankNotification.tsx
+++ b/phone/src/apps/bank/components/notification/BankNotification.tsx
@@ -1,16 +1,45 @@
-import React from 'react'
-import Alert from '@material-ui/lab/Alert';
-import Notification from '../../../../ui/components/Notification';
-import { useBankAlert } from './../../hooks/useBankAlert';
+import React, { useEffect, useState } from "react";
+import Notification from "../../../../ui/components/Notification";
+import { usePhone } from "../../../../os/phone/hooks/usePhone";
+import { useTranslation } from "react-i18next";
+import useStyles from './notification.style';
+import { useBankNotification } from "../../hooks/useBankNotification";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { faWonSign } from "@fortawesome/free-solid-svg-icons";
-export const BankNotification = ({ alert }) => {
- const { setBankAlert } = useBankAlert();
+export const BankNotification = () => {
+ const { notification } = useBankNotification()
+ const classes = useStyles()
+ const { t } = useTranslation();
+ const [visible, setVisible ] = useState(false);
+ const { config } = usePhone()
- const handleClose = () => {
- setBankAlert(false)
- }
+ useEffect(() => {
+ if (notification) {
+ setVisible(true);
+ }
+ }, [notification?.id])
+
+ if (!config?.bank.showNotifications || !notification) return null;
return (
-
- )
-}
+ setVisible(false)}
+ >
+
+
+
+
+
+
+
{notification.type}
+
+
{t("APPS_BANK_TIME_JUST_NOW")}
+
+
{notification.source} sent you ${notification.transferAmount}.
{notification.message}
+
+
+ )
+}
\ No newline at end of file
diff --git a/phone/src/apps/bank/components/notification/notification.style.ts b/phone/src/apps/bank/components/notification/notification.style.ts
new file mode 100644
index 0000000..7d80b71
--- /dev/null
+++ b/phone/src/apps/bank/components/notification/notification.style.ts
@@ -0,0 +1,43 @@
+import { makeStyles, createStyles, Theme } from "@material-ui/core/styles";
+
+const useStyles = makeStyles((theme: Theme) =>
+ createStyles({
+ content: {
+ padding: theme.spacing(2),
+ overflowY: 'hidden'
+ },
+ title: {
+ display: "flex",
+ flexFlow: "row nowrap",
+ justifyContent: "space-between",
+ alignItems: "center",
+ },
+ titleLeft: {
+ display: "flex",
+ flexFlow: "row nowrap",
+ justifyContent: "flex-start",
+ alignItems: "center",
+ },
+ icon: {
+ marginTop: "3px",
+ marginRight: "5px",
+ },
+ heading: {
+ marginBottom: "3px",
+ },
+ justNow: {
+ fontSize: "18px",
+ fontStyle: "italic",
+ paddingRight: "3px",
+ },
+ message: {
+ fontSize: "16px",
+ overflow: "hidden",
+ display: "-webkit-box",
+ WebkitLineClamp: 2,
+ WebkitBoxOrient: "vertical",
+ },
+ })
+)
+
+export default useStyles;
\ No newline at end of file
diff --git a/phone/src/apps/bank/components/transfers/TransferModal.tsx b/phone/src/apps/bank/components/transfers/TransferModal.tsx
index fe4050b..6759bf0 100644
--- a/phone/src/apps/bank/components/transfers/TransferModal.tsx
+++ b/phone/src/apps/bank/components/transfers/TransferModal.tsx
@@ -6,6 +6,7 @@ import CloseIcon from '@material-ui/icons/Close';
import Nui from '../../../../os/nui-events/utils/Nui';
import { useBankModal} from '../../hooks/useBankModal';
+import { Message } from '@material-ui/icons';
const useStyles = makeStyles((theme) => ({
input: {
@@ -50,15 +51,13 @@ export const TransferModal = () => {
}
const addTransfer = () => {
+ const transferAmount = parseInt(amount);
Nui.send('phone:addTransfer', {
targetID,
- amount,
+ transferAmount,
message
})
- setTimeout(() => {
- setShowBankModal(false)
- }, 200)
-
+ setShowBankModal(false)
}
return (
diff --git a/phone/src/apps/bank/hooks/state.ts b/phone/src/apps/bank/hooks/state.ts
index 2f17396..70ad8d4 100644
--- a/phone/src/apps/bank/hooks/state.ts
+++ b/phone/src/apps/bank/hooks/state.ts
@@ -9,12 +9,16 @@ export const bankState = {
key: 'modalVisibility',
default: false,
}),
- bankAlert: atom({
+ transferSuccessful: atom({
key: 'bankAlert',
- default: false
+ default: null
}),
bankCredentials: atom({
key: 'bankCredentails',
default: null
+ }),
+ notification: atom({
+ key: 'bankNotification',
+ default: null
})
}
\ No newline at end of file
diff --git a/phone/src/apps/bank/hooks/useBankAlert.ts b/phone/src/apps/bank/hooks/useBankAlert.ts
index 2fb828a..da6deb0 100644
--- a/phone/src/apps/bank/hooks/useBankAlert.ts
+++ b/phone/src/apps/bank/hooks/useBankAlert.ts
@@ -1,7 +1,7 @@
import { useRecoilState } from 'recoil';
import { bankState } from './state';
-export const useBankAlert = () => {
- const [ bankAlert, setBankAlert ] = useRecoilState(bankState.bankAlert);
+export const useBankAlert = (): any => {
+ const [ bankAlert, setBankAlert ] = useRecoilState(bankState.transferSuccessful);
return { bankAlert, setBankAlert };
}
\ No newline at end of file
diff --git a/phone/src/apps/bank/hooks/useBankNotification.ts b/phone/src/apps/bank/hooks/useBankNotification.ts
new file mode 100644
index 0000000..e67087f
--- /dev/null
+++ b/phone/src/apps/bank/hooks/useBankNotification.ts
@@ -0,0 +1,13 @@
+import { useRecoilValue } from 'recoil';
+
+import { Transfer } from '../../../common/interfaces/bank';
+import { bankState } from './state';
+
+interface IBankNotification {
+ notification: Transfer | null;
+}
+
+export const useBankNotification = (): IBankNotification => {
+ const notification = useRecoilValue(bankState.notification);
+ return { notification }
+}
\ No newline at end of file
diff --git a/phone/src/apps/bank/hooks/useBankService.ts b/phone/src/apps/bank/hooks/useBankService.ts
index 168b3f8..f853886 100644
--- a/phone/src/apps/bank/hooks/useBankService.ts
+++ b/phone/src/apps/bank/hooks/useBankService.ts
@@ -2,12 +2,21 @@ import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { bankState } from './state';
import { useTransactions } from './useTransactions'
import { useCredentials } from './useCredentials';
+import { useBankAlert } from './useBankAlert';
import { useSetRecoilState } from 'recoil'
+import { useBankNotification } from './useBankNotification';
export const useBankService = () => {
const setTransaction = useSetRecoilState(bankState.transactions)
const setCredentials = useSetRecoilState(bankState.bankCredentials)
+ const setAlertMessage = useSetRecoilState(bankState.transferSuccessful)
+ const setNotification = useSetRecoilState(bankState.notification);
+
+ ///
+
useNuiEvent('BANK', 'setTransaction', setTransaction);
- useNuiEvent('BANK', 'setCredentials', setCredentials)
- return {useTransactions, useCredentials};
+ useNuiEvent('BANK', 'setCredentials', setCredentials);
+ useNuiEvent('BANK', 'setAlert', setAlertMessage);
+ useNuiEvent('BANK', 'setNotification', setNotification);
+ return { useTransactions, useCredentials, useBankAlert, useBankNotification };
}
\ 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 fa47d34..7ef050c 100644
--- a/phone/src/apps/contacts/components/ContactsApp.tsx
+++ b/phone/src/apps/contacts/components/ContactsApp.tsx
@@ -8,9 +8,11 @@ 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 { useContactModal } from '../hooks/useContactModal';
+import PersonAddIcon from "@material-ui/icons/PersonAdd";
+import Fab from "@material-ui/core/Fab";
+import { useContactModal } from "../hooks/useContactModal";
+import { InfoModal } from "./modal/InfoModal";
+import { useContactDetail } from "../hooks/useContactDetail";
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@@ -36,7 +38,7 @@ export const ContactsApp = () => {
const classes = useStyles();
const { showModal, setShowModal } = useModal();
const contacts = useApp("CONTACTS");
- const { showContactModal } = useContactModal();
+ const { contactDetail } = useContactDetail();
const openModal = () => {
setShowModal(true);
@@ -47,6 +49,7 @@ export const ContactsApp = () => {
+
diff --git a/phone/src/apps/contacts/components/List/ContactList.tsx b/phone/src/apps/contacts/components/List/ContactList.tsx
index 699111c..2edfdcf 100644
--- a/phone/src/apps/contacts/components/List/ContactList.tsx
+++ b/phone/src/apps/contacts/components/List/ContactList.tsx
@@ -1,14 +1,14 @@
import React from "react";
import ListItemText from "@material-ui/core/ListItemText";
-import {
- Button,
+import {
+ Button,
ListItemAvatar,
Avatar as MuiAvatar,
List,
ListItem,
TextField,
Collapse,
- makeStyles
+ makeStyles,
} from "@material-ui/core";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
@@ -18,39 +18,43 @@ import { useFilteredContacts } from "../../hooks/useFilteredContacts";
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 { useContactModal } from "../../hooks/useContactModal";
+import { useContactDetail } from "../../hooks/useContactDetail";
import Nui from "../../../../os/nui-events/utils/Nui";
-import "../Contact.css"
+import "../Contact.css";
const useStyles = makeStyles((theme) => ({
updateButton: {
- margin: 'auto',
+ margin: "auto",
fontSize: 14,
width: 150,
background: "#2196f3",
marginBottom: 10,
- padding: 8
+ padding: 8,
},
collapseItem: {
- margin: 'auto',
- width: '50%'
- }
-}))
-
+ margin: "auto",
+ width: "50%",
+ },
+}));
export const ContactList = () => {
- const classes = useStyles()
+ const classes = useStyles();
const { filteredContacts } = useFilteredContacts();
- const { showContactModal, setShowContactModal } = useContactModal();
+ const { setShowContactModal } = useContactModal();
+ const { contactDetail, setContactDetail } = useContactDetail();
const contacts = useContacts();
- const openContactInfo = () => {
- setShowContactModal(!showContactModal);
- }
+ const openContactInfo = (contact) => {
+ setShowContactModal(true);
+ setContactDetail(contact);
+ console.log("CONTACT", contactDetail);
+ };
const startCall = (number) => {
console.log(number);
Nui.send("phone:startCall", {
@@ -60,52 +64,47 @@ 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).toUpperCase()}
- )}
-
-
-
-
-
-
-
-
-
-
+ 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/components/modal/InfoModal.tsx b/phone/src/apps/contacts/components/modal/InfoModal.tsx
new file mode 100644
index 0000000..07456b3
--- /dev/null
+++ b/phone/src/apps/contacts/components/modal/InfoModal.tsx
@@ -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 (
+
+
+
+
+
+
+
+
setDisplay(e.target.value)}
+ placeholder={t("APPS_CONTACT_FORM_NAME")}
+ fullWidth
+ inputProps={{
+ className: classes.inputProps,
+ }}
+ />
+ setNumber(e.target.value)}
+ placeholder={t("APPS_CONTACT_FORM_NUMBER")}
+ fullWidth
+ inputProps={{
+ className: classes.inputProps,
+ }}
+ />
+ setAvatar(e.target.value)}
+ inputProps={{
+ className: classes.inputProps,
+ }}
+ />
+
+
+
+ Update
+
+
+ Delete
+
+
+
+
+
+ );
+};
diff --git a/phone/src/apps/contacts/components/modal/modal.styles.ts b/phone/src/apps/contacts/components/modal/modal.styles.ts
new file mode 100644
index 0000000..7f0af19
--- /dev/null
+++ b/phone/src/apps/contacts/components/modal/modal.styles.ts
@@ -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;
\ No newline at end of file
diff --git a/phone/src/apps/contacts/hooks/state.ts b/phone/src/apps/contacts/hooks/state.ts
index 8d725c3..0c5321b 100644
--- a/phone/src/apps/contacts/hooks/state.ts
+++ b/phone/src/apps/contacts/hooks/state.ts
@@ -16,5 +16,9 @@ export const contactsState = {
showContactsModal: atom({
key: 'showContactModal',
default: false
+ }),
+ contactDetail: atom({
+ key: 'contactDetail',
+ default: null
})
};
diff --git a/phone/src/apps/contacts/hooks/useContactDetail.ts b/phone/src/apps/contacts/hooks/useContactDetail.ts
new file mode 100644
index 0000000..9c064e9
--- /dev/null
+++ b/phone/src/apps/contacts/hooks/useContactDetail.ts
@@ -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 };
+}
\ No newline at end of file
diff --git a/phone/src/apps/dialer/hooks/useDialerHistory.ts b/phone/src/apps/dialer/hooks/useDialerHistory.ts
index cfc6d31..6a8e19a 100644
--- a/phone/src/apps/dialer/hooks/useDialerHistory.ts
+++ b/phone/src/apps/dialer/hooks/useDialerHistory.ts
@@ -3,12 +3,6 @@ import { useRecoilState, atom } from "recoil";
const dialerHistoryState = atom({
key: "dialerHistory",
default: [
- {
- id: 0,
- caller: "Kidz",
- phoneNumber: "000-1111",
- type: "incoming",
- },
{
id: 1,
caller: "ROCKY",
diff --git a/phone/src/apps/notes/NotesApp.css b/phone/src/apps/notes/NotesApp.css
new file mode 100644
index 0000000..ed44c69
--- /dev/null
+++ b/phone/src/apps/notes/NotesApp.css
@@ -0,0 +1,7 @@
+#notes-app .Mui-focused::after {
+ border-bottom: 3px solid #f9a825;
+}
+
+#notes-app .MuiOutlinedInput-root {
+ border: 2px soild #f9a825;
+}
\ No newline at end of file
diff --git a/phone/src/apps/notes/NotesApp.tsx b/phone/src/apps/notes/NotesApp.tsx
new file mode 100644
index 0000000..d7d51bd
--- /dev/null
+++ b/phone/src/apps/notes/NotesApp.tsx
@@ -0,0 +1,48 @@
+import React from "react";
+import { AppWrapper } from "../../ui/components/AppWrapper";
+import { AppContent } from "../../ui/components/AppContent";
+import NotesTitle from "./NotesTitle";
+import NoteList from "./list/NoteList";
+
+import { useNotes } from "./hooks/useNotes";
+import { NoteModal } from "./modal/NoteModal";
+import { Fab } from "@material-ui/core";
+import AddIcon from "@material-ui/icons/Add";
+
+import { useNoteModal } from "./hooks/useNoteModal";
+import { useNoteDetail } from "./hooks/useNoteDetail";
+
+import useStyles from "./notes.styles";
+
+export const NotesApp = () => {
+ const { setNoteModal } = useNoteModal();
+ const { detail, setDetail } = useNoteDetail();
+ const notes = useNotes();
+
+ const classes = useStyles();
+
+ const handleModal = () => {
+ setNoteModal(true);
+ setDetail(null);
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+ );
+};
diff --git a/phone/src/apps/notes/NotesTitle.tsx b/phone/src/apps/notes/NotesTitle.tsx
new file mode 100644
index 0000000..8197ac4
--- /dev/null
+++ b/phone/src/apps/notes/NotesTitle.tsx
@@ -0,0 +1,20 @@
+import React from 'react'
+
+import { yellow } from "@material-ui/core/colors";
+
+import useStyles from './notes.styles';
+
+import { Paper } from "@material-ui/core";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { faStickyNote } from "@fortawesome/free-solid-svg-icons";
+
+const NotesTitle = () => {
+ const classes = useStyles()
+ return (
+
+
+
+ )
+}
+
+export default NotesTitle;
\ No newline at end of file
diff --git a/phone/src/apps/notes/hooks/state.ts b/phone/src/apps/notes/hooks/state.ts
new file mode 100644
index 0000000..9599aa0
--- /dev/null
+++ b/phone/src/apps/notes/hooks/state.ts
@@ -0,0 +1,16 @@
+import { atom } from 'recoil';
+
+export const noteStates = {
+ noteItems: atom({
+ key: 'noteItem',
+ default: []
+ }),
+ noteModal: atom({
+ key: 'noteModal',
+ default: false
+ }),
+ noteDetail: atom({
+ key: 'noteDetail',
+ default: null
+ })
+}
\ No newline at end of file
diff --git a/phone/src/apps/notes/hooks/useNoteDetail.ts b/phone/src/apps/notes/hooks/useNoteDetail.ts
new file mode 100644
index 0000000..9faab1e
--- /dev/null
+++ b/phone/src/apps/notes/hooks/useNoteDetail.ts
@@ -0,0 +1,7 @@
+import { useRecoilState } from 'recoil';
+import { noteStates } from './state';
+
+export const useNoteDetail = (): any => {
+ const [detail, setDetail] = useRecoilState(noteStates.noteDetail);
+ return { detail, setDetail };
+}
\ No newline at end of file
diff --git a/phone/src/apps/notes/hooks/useNoteModal.ts b/phone/src/apps/notes/hooks/useNoteModal.ts
new file mode 100644
index 0000000..adbcc9a
--- /dev/null
+++ b/phone/src/apps/notes/hooks/useNoteModal.ts
@@ -0,0 +1,7 @@
+import { useRecoilState } from 'recoil';
+import { noteStates } from './state';
+
+export const useNoteModal = () => {
+ const [noteModal, setNoteModal] = useRecoilState(noteStates.noteModal);
+ return { noteModal, setNoteModal };
+}
\ No newline at end of file
diff --git a/phone/src/apps/notes/hooks/useNotes.ts b/phone/src/apps/notes/hooks/useNotes.ts
new file mode 100644
index 0000000..69ce277
--- /dev/null
+++ b/phone/src/apps/notes/hooks/useNotes.ts
@@ -0,0 +1,7 @@
+import { useRecoilValue } from 'recoil';
+import { noteStates } from './state';
+
+export const useNotes = () => {
+ const notes = useRecoilValue(noteStates.noteItems);
+ return notes;
+}
diff --git a/phone/src/apps/notes/hooks/useNotesService.ts b/phone/src/apps/notes/hooks/useNotesService.ts
new file mode 100644
index 0000000..3b7df58
--- /dev/null
+++ b/phone/src/apps/notes/hooks/useNotesService.ts
@@ -0,0 +1,10 @@
+import { useSetRecoilState } from 'recoil'
+import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
+import { useNotes } from './useNotes';
+import { noteStates } from './state';
+
+export const useNotesService = () => {
+ const setNotes = useSetRecoilState(noteStates.noteItems);
+ useNuiEvent('NOTES', 'setNotes', setNotes);
+ return useNotes();
+}
\ No newline at end of file
diff --git a/phone/src/apps/notes/list/NoteList.tsx b/phone/src/apps/notes/list/NoteList.tsx
new file mode 100644
index 0000000..113c3d7
--- /dev/null
+++ b/phone/src/apps/notes/list/NoteList.tsx
@@ -0,0 +1,28 @@
+import { List, ListItem, ListItemText } from '@material-ui/core';
+import React, { useState } from 'react'
+
+import { useNoteModal } from '../hooks/useNoteModal';
+import { useNoteDetail } from '../hooks/useNoteDetail';
+
+// add search bar later
+const NoteList = ({notes}) => {
+ const { setNoteModal } = useNoteModal();
+ const { setDetail } = useNoteDetail();
+
+ const handleNoteModal = (note) => {
+ setNoteModal(true)
+ setDetail(note)
+ }
+
+ return (
+
+ {notes.map((note) => (
+ handleNoteModal(note)}>
+ {note.title}
+
+ ))}
+
+ )
+}
+
+export default NoteList;
diff --git a/phone/src/apps/notes/modal/NoteModal.tsx b/phone/src/apps/notes/modal/NoteModal.tsx
new file mode 100644
index 0000000..141d752
--- /dev/null
+++ b/phone/src/apps/notes/modal/NoteModal.tsx
@@ -0,0 +1,116 @@
+import {
+ Button,
+ TextField,
+ Slide,
+} from "@material-ui/core";
+import React, { useState } from "react";
+import ArrowBackIcon from "@material-ui/icons/ArrowBack";
+
+import { useNoteModal } from "../hooks/useNoteModal";
+import { useNoteDetail } from "../hooks/useNoteDetail";
+
+import useStyles from "./modal.styles";
+
+import "../NotesApp.css";
+import Nui from "../../../os/nui-events/utils/Nui";
+
+export const NoteModal = () => {
+ const { noteModal, setNoteModal } = useNoteModal();
+ const { detail, setDetail } = useNoteDetail();
+ console.log(detail);
+ const [title, setTitle] = useState(detail ? detail.title : "");
+ const [content, setContent] = useState(detail ? detail.content : "");
+
+ const classes = useStyles();
+
+ const _handleClose = () => {
+ setNoteModal(false);
+ setDetail(null);
+ };
+
+ const handleNoteSave = () => {
+ setNoteModal(false);
+ setDetail(null);
+ Nui.send("phone:addNote", {
+ title,
+ content,
+ });
+ };
+
+ const handleDeleteNote = () => {
+ const id = detail.id;
+ setNoteModal(false);
+ Nui.send("phone:deleteNote", {
+ id,
+ });
+ setDetail(null);
+ };
+
+ const handleUpdateNote = () => {
+ Nui.send("phone:updateNote", {
+ id: detail.id,
+ title,
+ content,
+ });
+ setNoteModal(false);
+ setDetail(null);
+ };
+
+ return (
+
+
+
+
+
+
+
+ setTitle(e.target.value)}
+ />
+ setContent(e.target.value)}
+ />
+ {!detail && (
+
+ Save
+
+ )}
+ {detail && (
+
+ Update
+
+ )}
+ {detail && (
+
+ Delete
+
+ )}
+
+
+
+
+ );
+};
diff --git a/phone/src/apps/notes/modal/modal.styles.ts b/phone/src/apps/notes/modal/modal.styles.ts
new file mode 100644
index 0000000..079dd05
--- /dev/null
+++ b/phone/src/apps/notes/modal/modal.styles.ts
@@ -0,0 +1,49 @@
+import { makeStyles } from '@material-ui/core';
+
+const useStyles = makeStyles((theme) => ({
+ modalRoot: {
+ zIndex: 20,
+ position: "absolute",
+ height: '100%',
+ width: '100%',
+ background: '#232323',
+ },
+ modalHide: {
+ display: 'none'
+ },
+ closeButton: {
+ width: '10%',
+ position: 'absolute',
+ top: 10,
+ left: 0
+ },
+ noteContainer: {
+ width: '90%',
+ marginTop: 80,
+ margin: '0 auto',
+ },
+ input: {
+ marginBottom: 20,
+ },
+ inputPropsTitle: {
+ fontSize: 28,
+ },
+ inputPropsContent: {
+ fontSize: 20,
+ },
+ saveButton: {
+ background: '#f9a825',
+ padding: '10px 30px'
+ },
+ updateButton: {
+ background: '#f9a825',
+ padding: '10px 30px',
+ marginRight: '8px'
+ },
+ deleteButton: {
+ background: '#c62828',
+ padding: '10px 30px'
+ }
+}))
+
+export default useStyles;
\ No newline at end of file
diff --git a/phone/src/apps/notes/notes.styles.ts b/phone/src/apps/notes/notes.styles.ts
new file mode 100644
index 0000000..2623a4d
--- /dev/null
+++ b/phone/src/apps/notes/notes.styles.ts
@@ -0,0 +1,30 @@
+import { makeStyles } from '@material-ui/core';
+
+const useStyles = makeStyles((theme) => ({
+ header: {
+ width: '100%',
+ display: 'flex',
+ flexFlow: 'row nowrap',
+ justifyContent: 'center',
+ alignItems: 'center',
+ textAlign: 'center',
+ height: '60px',
+ },
+ 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),
+ right: theme.spacing(3),
+ },
+}))
+
+export default useStyles;
\ No newline at end of file
diff --git a/phone/src/common/interfaces/bank.ts b/phone/src/common/interfaces/bank.ts
new file mode 100644
index 0000000..b11a21e
--- /dev/null
+++ b/phone/src/common/interfaces/bank.ts
@@ -0,0 +1,14 @@
+export interface Credentials {
+ name: string;
+ balance: number;
+}
+
+export interface Transfer {
+ id: number;
+ targetID: number;
+ source: string;
+ type: string;
+ transferAmount: number;
+ message: string;
+}
+
diff --git a/phone/src/common/interfaces/config.ts b/phone/src/common/interfaces/config.ts
index 85715eb..c5f43bf 100644
--- a/phone/src/common/interfaces/config.ts
+++ b/phone/src/common/interfaces/config.ts
@@ -16,6 +16,10 @@ interface NotificationConfig {
vertical: "bottom" | "top";
}
+interface BankConfig {
+ showNotifications: boolean;
+}
+
export interface ServerConfig {
Locale: string;
KeyTogglePhone: number;
@@ -26,5 +30,6 @@ export interface ServerConfig {
DestoryChance: number;
DestroyPhoneReCheck: number;
twitter: TwitterConfig;
+ bank: BankConfig;
notificationPosition: NotificationConfig;
}
diff --git a/phone/src/common/interfaces/notes.ts b/phone/src/common/interfaces/notes.ts
new file mode 100644
index 0000000..8d9cb5d
--- /dev/null
+++ b/phone/src/common/interfaces/notes.ts
@@ -0,0 +1,9 @@
+export interface Note {
+ id?: number;
+ title: string;
+ content: string;
+}
+
+export interface NoteId {
+ id: number;
+}
\ No newline at end of file
diff --git a/phone/src/index.tsx b/phone/src/index.tsx
index c7fc224..eb1d652 100644
--- a/phone/src/index.tsx
+++ b/phone/src/index.tsx
@@ -8,11 +8,13 @@ import "./main.css";
import Phone from "./Phone";
import * as serviceWorker from "./serviceWorker";
import TwitterNotification from "./apps/twitter/components/notification/TwitterNotification";
+import { BankNotification } from "./apps/bank/components/notification/BankNotification";
ReactDOM.render(
+
,
diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json
index 148f759..644289d 100644
--- a/phone/src/locale/en.json
+++ b/phone/src/locale/en.json
@@ -39,9 +39,19 @@
"APPS_TWITTER_TIME_HOURS": "h",
"APPS_TWITTER_TIME_DAYS": "d",
- "APPS_BANK_HOME_TITLE": "Welcome, ",
+ "APPS_BANK_HOME_TITLE": "Welcome",
+ "APPS_BANK_ACCOUNT_LINK": "Account",
+ "APPS_BANK_TIME_JUST_NOW": "Just now",
"APPS_BANK_ACCOUNT_TITLE": "Account Summary",
"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_ALERT_TRANSFER_SUCCESS": "Transfer done successfully!",
+ "APPS_BANK_ALERT_TRANSFER_FAILURE": "Transfer failed!",
+
+ "APPS_CONTACT_FORM_NAME": "Name",
+ "APPS_CONTACT_FORM_NUMBER": "Number",
+ "APPS_CONTACT_FORM_AVATAR": "Avatar URL"
+
}
}
diff --git a/phone/src/os/apps/hooks/useApps.tsx b/phone/src/os/apps/hooks/useApps.tsx
index f744ab6..40b4d25 100644
--- a/phone/src/os/apps/hooks/useApps.tsx
+++ b/phone/src/os/apps/hooks/useApps.tsx
@@ -6,6 +6,7 @@ import {
grey,
green,
purple,
+ yellow,
red,
amber,
} from "@material-ui/core/colors";
@@ -14,7 +15,8 @@ import {
faAd,
faPlaneArrival,
faPhoneAlt,
- faWonSign
+ faWonSign,
+ faStickyNote
} from "@fortawesome/free-solid-svg-icons";
import { faTwitter } from "@fortawesome/free-brands-svg-icons";
@@ -33,6 +35,7 @@ import { MessagesApp } from "../../../apps/messages/components/MessagesApp";
import { TwitterApp } from "../../../apps/twitter/components/TwitterApp";
import { ExampleApp } from "../../../apps/example/components/ExampleApp";
import { SelloutApp } from "../../../apps/sellout/components/SelloutApp";
+import { NotesApp } from "../../../apps/notes/NotesApp";
const appsState = atom({
key: "apps",
@@ -110,6 +113,15 @@ const appsState = atom({
path: "/sellout",
Route: () => ,
},
+ {
+ id: 'NOTES',
+ name: 'APPS_NOTES',
+ icon: ,
+ backgroundColor: yellow[800],
+ color: common.white,
+ path: "/notes",
+ Route: () =>
+ },
{
id: "EXAMPLE",
nameLocale: "APPS_EXAMPLE",
diff --git a/phone/src/ui/components/AppIcon.tsx b/phone/src/ui/components/AppIcon.tsx
index 8b1e4be..2e3f20a 100644
--- a/phone/src/ui/components/AppIcon.tsx
+++ b/phone/src/ui/components/AppIcon.tsx
@@ -3,6 +3,7 @@ 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;
@@ -28,13 +29,18 @@ const useStyles = makeStyles(
})
);
-export const AppIcon = ({ name, icon, backgroundColor, color }) => {
+export const AppIcon = ({ id, name, icon, backgroundColor, color }) => {
const classes = useStyles({
backgroundColor: backgroundColor || green[50],
color: color || green[400],
});
+
+ const openAppCallback = () => {
+ Nui.send(`phone:app:${id}`)
+ }
+
return (
-
+
{icon || name[0].toUpperCase()}
diff --git a/phone/src/ui/components/Notification.tsx b/phone/src/ui/components/Notification.tsx
index 851880d..03254f1 100644
--- a/phone/src/ui/components/Notification.tsx
+++ b/phone/src/ui/components/Notification.tsx
@@ -32,7 +32,7 @@ function Notification({ children, handleClose, open }) {
null }}
+ ClickAwayListenerProps={{ onClickAway: () => setTimeout(() => { handleClose() }, 5000) }}
onClose={handleClose}
open={open}
TransitionComponent={Fade}
diff --git a/resources/client/cl_bank.ts b/resources/client/cl_bank.ts
index c5681c1..c29703c 100644
--- a/resources/client/cl_bank.ts
+++ b/resources/client/cl_bank.ts
@@ -12,7 +12,6 @@ onNet(events.BANK_SEND_TRANSFERS, (transfer: any) => {
})
onNet(events.BANK_SEND_CREDENTIALS, (credentials: any) => {
- console.log("Client:", credentials.balance, credentials.name)
SendNuiMessage(
JSON.stringify({
app: "BANK",
@@ -26,8 +25,28 @@ RegisterNuiCallbackType(events.BANK_ADD_TRANSFER);
on(`__cfx_nui:${events.BANK_ADD_TRANSFER}`, (data: any) => {
const transfer = data;
emitNet(events.BANK_ADD_TRANSFER, transfer)
+})
- setTimeout(() => {
- emitNet(events.BANK_FETCH_TRANSACTIONS);
- }, 500)
+onNet(events.BANK_ADD_TRANSFER_SUCCESS, () => {
+ emitNet(events.BANK_FETCH_TRANSACTIONS);
+})
+
+onNet(events.BANK_TRANSACTION_ALERT, (bool: boolean) => {
+ SendNuiMessage(
+ JSON.stringify({
+ app: 'BANK',
+ method: 'setAlert',
+ data: bool
+ })
+ )
+})
+
+onNet(events.BANK_TRANSACTION_NOTIFICATION, (transfer: any) => {
+ SendNuiMessage(
+ JSON.stringify({
+ app: "BANK",
+ method: 'setNotification',
+ data: transfer
+ })
+ )
})
diff --git a/resources/client/cl_contacts.ts b/resources/client/cl_contacts.ts
index a052a41..0f12dc8 100644
--- a/resources/client/cl_contacts.ts
+++ b/resources/client/cl_contacts.ts
@@ -17,8 +17,29 @@ on(`__cfx_nui:${events.CONTACTS_ADD_CONTACT}`, (data: any) => {
const avatar = data.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)
+})
\ No newline at end of file
diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts
index 2ac5c9a..dfe2942 100644
--- a/resources/client/cl_main.ts
+++ b/resources/client/cl_main.ts
@@ -235,10 +235,6 @@ async function Phone() {
isPhoneOpen = true;
await phoneOpenAnim(); // Animation starts before the phone is open
emitNet('phone:getCredentials')
- emitNet(events.CONTACTS_GET_CONTACTS);
- emitNet(events.SELLOUT_FETCH_LISTING);
- emitNet(events.BANK_FETCH_TRANSACTIONS);
- emitNet(events.BANK_GET_CREDENTIALS);
console.log("Sellout fetched from client side")// Gets the credentials. Will eventually most likely only get the phone number and name, idk.
SetCursorLocation(0.90, 0.922) //Experimental
let res = GetActiveScreenResolution()
@@ -274,10 +270,6 @@ async function Phone() {
isPhoneOpen = true;
await phoneOpenAnim(); // Animation starts before the phone is open
emitNet('phone:getCredentials')
- emitNet(events.CONTACTS_GET_CONTACTS);
- emitNet(events.SELLOUT_FETCH_LISTING);
- emitNet(events.BANK_FETCH_TRANSACTIONS);
- emitNet(events.BANK_GET_CREDENTIALS);
console.log("Sellout fetched from client side")
SetCursorLocation(0.936, 0.922) //Experimental
let res = GetActiveScreenResolution()
@@ -306,6 +298,30 @@ async function Phone() {
}
}
+// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
+
+// contacts app
+RegisterNuiCallbackType(events.OPEN_APP_CONTACTS);
+on(`__cfx_nui:${events.OPEN_APP_CONTACTS}`, () => {
+ emitNet(events.CONTACTS_GET_CONTACTS);
+})
+
+RegisterNuiCallbackType(events.OPEN_APP_LISTINGS);
+on(`__cfx_nui:${events.OPEN_APP_LISTINGS}`, () => {
+ emitNet(events.SELLOUT_FETCH_LISTING);
+})
+
+RegisterNuiCallbackType(events.OPEN_APP_NOTES);
+on(`__cfx_nui:${events.OPEN_APP_NOTES}`, () => {
+ emitNet(events.NOTE_FETCH_ALL_NOTES);
+})
+
+RegisterNuiCallbackType(events.OPEN_APP_BANK);
+on(`__cfx_nui:${events.OPEN_APP_BANK}`, () => {
+ emitNet(events.BANK_FETCH_TRANSACTIONS);
+ emitNet(events.BANK_GET_CREDENTIALS);
+})
+
RegisterCommand(
"phone",
() => {
diff --git a/resources/client/cl_notes.ts b/resources/client/cl_notes.ts
new file mode 100644
index 0000000..636362f
--- /dev/null
+++ b/resources/client/cl_notes.ts
@@ -0,0 +1,39 @@
+import events from "../utils/events";
+
+onNet(events.NOTE_SEND_NOTE, (notes: any) => {
+ SendNuiMessage(
+ JSON.stringify({
+ app: "NOTES",
+ method: "setNotes",
+ data: notes,
+ })
+ );
+});
+
+RegisterNuiCallbackType(events.NOTE_ADD_NOTE);
+on(`__cfx_nui:${events.NOTE_ADD_NOTE}`, (data: any) => {
+ const note = data;
+ emitNet(events.NOTE_ADD_NOTE, note);
+});
+
+onNet(events.NOTE_SEND_NOTE_SUCCESS, () => {
+ emitNet(events.NOTE_FETCH_ALL_NOTES);
+});
+
+RegisterNuiCallbackType(events.NOTE_DELETE_NOTE);
+on(`__cfx_nui:${events.NOTE_DELETE_NOTE}`, (data: any) => {
+ const noteId = data;
+ emitNet(events.NOTE_DELETE_NOTE, noteId);
+
+ emitNet(events.NOTE_FETCH_ALL_NOTES);
+});
+
+RegisterNuiCallbackType(events.NOTE_UPDATE_NOTE);
+on(`__cfx_nui:${events.NOTE_UPDATE_NOTE}`, (data: any) => {
+ const note = data;
+ emitNet(events.NOTE_UPDATE_NOTE, note);
+});
+
+onNet(events.NOTE_UPDATE_NOTE_SUCCESS, () => {
+ emitNet(events.NOTE_FETCH_ALL_NOTES);
+});
diff --git a/resources/client/client.ts b/resources/client/client.ts
index 2b6c28d..10c3786 100644
--- a/resources/client/client.ts
+++ b/resources/client/client.ts
@@ -4,6 +4,7 @@ import './cl_twitter';
import './cl_contacts';
import './cl_sellout';
import './cl_bank';
+import './cl_notes';
export let ESX: ESXClient = null;
diff --git a/resources/import.sql b/resources/import.sql
index 4891576..18d14b9 100644
--- a/resources/import.sql
+++ b/resources/import.sql
@@ -57,6 +57,36 @@ CREATE TABLE IF NOT EXISTS `npwd_twitter_likes` (
CONSTRAINT `tweet` FOREIGN KEY (`tweet_id`) REFERENCES `npwd_twitter_tweets` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+
+CREATE TABLE IF NOT EXISTS npwd_notes (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ identifier varchar(255) NOT NULL,
+ title varchar(255) NOT NULL,
+ content varchar(255) NOT NULL,
+ PRIMARY KEY (id)
+)
+ENGINE = INNODB,
+AUTO_INCREMENT = 5,
+AVG_ROW_LENGTH = 4096,
+CHARACTER SET utf8mb4,
+COLLATE utf8mb4_general_ci;
+
+CREATE TABLE npwd_sellout_listings (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ identifier varchar(255) DEFAULT NULL,
+ name varchar(50) DEFAULT NULL,
+ number varchar(255) NOT NULL,
+ title varchar(255) DEFAULT NULL,
+ url varchar(255) DEFAULT NULL,
+ description varchar(255) NOT NULL,
+ PRIMARY KEY (id)
+)
+ENGINE = INNODB,
+AUTO_INCREMENT = 26,
+AVG_ROW_LENGTH = 2048,
+CHARACTER SET utf8mb4,
+COLLATE utf8mb4_general_ci;
+
CREATE TABLE IF NOT EXISTS `npwd_twitter_reports` (
`id` int NOT NULL AUTO_INCREMENT,
`profile_id` int NOT NULL,
diff --git a/resources/server/server.ts b/resources/server/server.ts
index 89c065a..88d6dc9 100644
--- a/resources/server/server.ts
+++ b/resources/server/server.ts
@@ -6,6 +6,7 @@ import './sv_main';
import './sv_contacts';
import './sv_sellout';
import './sv_bank';
+import './sv_notes';
export let ESX: ESXServer = null;
diff --git a/resources/server/sv_bank.ts b/resources/server/sv_bank.ts
index b99152b..9843812 100644
--- a/resources/server/sv_bank.ts
+++ b/resources/server/sv_bank.ts
@@ -2,18 +2,9 @@ import events from '../utils/events';
import { ESX } from './server';
import { getSource } from "./functions";
import { pool } from './db';
-import { resourceLimits } from 'worker_threads';
-
-interface Transfer {
- targetID: string;
- amount: number;
- message: string;
-}
-
-interface Credentials {
- name: string;
- balance: number;
-}
+import { Transfer, Credentials } from '../../phone/src/common/interfaces/bank';
+import { useIdentifier } from './functions';
+import { type } from 'os';
async function fetchAllTransactions(identifier: string): Promise {
@@ -33,63 +24,84 @@ function fetchCredentials(): Credentials {
balance
}
- console.log(result.name, result.balance);
-
return result;
}
-
async function addTransfer(identifier: string, transfer: Transfer): Promise {
-
const xPlayer = ESX.GetPlayerFromId(getSource())
const bankBalance = xPlayer.getAccount('bank').money;
- console.log(bankBalance)
- if (transfer.amount > bankBalance) {
- console.log("poor man")
- emitNet(events.BANK_TRANSACTION_ALERT, getSource, 'You do not have enough money on your account', 'error')
- }
- else if (transfer.amount <= bankBalance) {
- const query = "INSERT INTO npwd_bank_transfers (identifier, target, amount, message) VALUES (?, ?, ?, ?)"
+ const sourceName = xPlayer.getName()
+
+ const xTarget = ESX.GetPlayerFromId(transfer.targetID);
- await pool.query(query, [
+
+ if (transfer.transferAmount > bankBalance) {
+ emitNet(events.BANK_TRANSACTION_ALERT, getSource(), false)
+ }
+ else if (transfer.transferAmount < bankBalance) {
+ emitNet(events.BANK_TRANSACTION_ALERT, getSource(), true);
+
+ xTarget.addAccountMoney('bank', transfer.transferAmount);
+ xPlayer.removeAccountMoney('bank', transfer.transferAmount);
+
+ const query = "INSERT INTO npwd_bank_transfers (identifier, target, amount, message, type, source) VALUES (?, ?, ?, ?, ?, ?)"
+
+ const [results] = await pool.query(query, [
identifier,
transfer.targetID,
- transfer.amount,
- transfer.message
+ transfer.transferAmount,
+ transfer.message,
+ "Transfer",
+ sourceName,
])
- emitNet(events.BANK_TRANSACTION_ALERT, getSource, 'You succesfully transferred money to someone', 'success')
+ const insertData = results;
+ return await getTransfer(insertData.insertId)
}
}
+/**
+ * Gets a transfer from its ID
+ * @param transferId - transfer id
+ */
+async function getTransfer(transferId: number): Promise {
+ const query = "SELECT * FROM npwd_bank_transfers WHERE id = ?"
+ const [ results ] = await pool.query(query, [transferId]);
+ const transfers = results;
+ const transfer = transfers[0];
+ return {...transfer};
+}
+
onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
try {
const _source = (global as any).source;
- const _identifier = ESX.GetPlayerFromId(getSource()).getIdentifier()
+ const _identifier = await useIdentifier()
const transfer = await fetchAllTransactions(_identifier);
emitNet(events.BANK_SEND_TRANSFERS, _source, transfer)
- console.log("WOORK")
} catch (error) {
- console.log('Failed to fetch transactions', error)
+ console.log("Failed to fetch transactions");
}
})
-onNet(events.BANK_ADD_TRANSFER, (transfer: Transfer) => {
+onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
+ const xTarget = ESX.GetPlayerFromId(transfer.targetID);
+ const targetSource = xTarget.source;
try {
- const _identifier = ESX.GetPlayerFromId(getSource()).getIdentifier()
- addTransfer(_identifier, transfer)
+ const _identifier = await useIdentifier()
+ const transferNotify = await addTransfer(_identifier, transfer)
+ emitNet(events.BANK_TRANSACTION_NOTIFICATION, targetSource, transferNotify)
+ emitNet(events.BANK_ADD_TRANSFER_SUCCESS, getSource());
} catch (error) {
- console.log('Failed to add transfer', error)
+ emitNet(events.BANK_TRANSACTION_ALERT, getSource(), false)
}
})
onNet(events.BANK_GET_CREDENTIALS, () => {
try {
const credentials = fetchCredentials()
- console.log("New log: ", credentials.balance, credentials.name)
emitNet(events.BANK_SEND_CREDENTIALS, getSource(), credentials)
} catch (error) {
- console.log(error)
+ console.log("Failed to fetch credentials");
}
})
\ No newline at end of file
diff --git a/resources/server/sv_contacts.ts b/resources/server/sv_contacts.ts
index f0fcfba..47b6e0c 100644
--- a/resources/server/sv_contacts.ts
+++ b/resources/server/sv_contacts.ts
@@ -1,12 +1,20 @@
-import { ESX } from "./server";
+import { ESX, getSource } from "./server";
import { pool } from "./db";
import events from "../utils/events";
+import { useIdentifier } from './functions'
interface Contacts {
+ id?: number;
display: string;
number: string;
+ avatar: string;
}
+interface ContactId {
+ id: number;
+}
+
+
async function fetchAllContacts(identifier: string): Promise {
const query = "SELECT * FROM npwd_phone_contacts WHERE identifier = ?";
const [results] = await pool.query(query, [identifier]);
@@ -26,6 +34,25 @@ async function addContact(
await pool.query(query, [identifier, number, display, avatar]);
}
+async function updateContact(contact: Contacts, identifier: string): Promise {
+ 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 {
+ const query = "DELETE FROM npwd_phone_contacts WHERE id = ? AND identifier = ?"
+ await pool.query(query, [
+ contact.id,
+ identifier
+ ])
+}
+
onNet(events.CONTACTS_GET_CONTACTS, async () => {
try {
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 {
const _source = (global as any).source;
- const xPlayer = ESX.GetPlayerFromId(_source);
- const _identifier = xPlayer.getIdentifier()
+ const _identifier = await useIdentifier()
addContact(_identifier, number, display, avatar);
- //emit(events.CONTACTS_GET_CONTACTS);
+ emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source)
} catch(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)
+ }
+})
diff --git a/resources/server/sv_notes.ts b/resources/server/sv_notes.ts
new file mode 100644
index 0000000..786424b
--- /dev/null
+++ b/resources/server/sv_notes.ts
@@ -0,0 +1,72 @@
+import events from "../utils/events";
+import { ESX, getSource } from "./server";
+import { pool } from "./db";
+import { useIdentifier } from "./functions";
+import { Note, NoteId } from "../../phone/src/common/interfaces/notes";
+
+async function addNote(identifier: string, note: Note): Promise {
+ const query =
+ "INSERT INTO npwd_notes (identifier, title, content) VALUES (?, ?, ?)";
+ await pool.query(query, [identifier, note.title, note.content]);
+}
+
+async function fetchAllNotes(identifier: string): Promise {
+ const query =
+ "SELECT * FROM npwd_notes WHERE identifier = ? ORDER BY id DESC";
+ const [result] = await pool.query(query, [identifier]);
+ const notes = result;
+ return notes;
+}
+
+async function deleteNote(noteId: number, identifier: string) {
+ const query = "DELETE FROM npwd_notes WHERE id = ? AND identifier = ?";
+ await pool.query(query, [noteId, identifier]);
+}
+
+async function updateNote(note: Note, identifier: string): Promise {
+ const query =
+ "UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?";
+ await pool.query(query, [note.title, note.content, note.id, identifier]);
+}
+
+onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
+ try {
+ const _identifier = await useIdentifier();
+ addNote(_identifier, note);
+ emitNet(events.NOTE_SEND_NOTE_SUCCESS, getSource());
+ } catch (error) {
+ console.log("NOTES ERROR: ", error);
+ }
+});
+
+onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
+ try {
+ const _source = (global as any).source;
+ const _identifier = await useIdentifier();
+ const notes = await fetchAllNotes(_identifier);
+ emitNet(events.NOTE_SEND_NOTE, _source, notes);
+ } catch (error) {
+ console.log("NOTE ERROR: ", error);
+ }
+});
+
+onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => {
+ try {
+ const _identifier = await useIdentifier();
+ const id = noteId.id;
+ await deleteNote(id, _identifier);
+ } catch (error) {
+ console.log("NOTE ERROR:", error);
+ }
+});
+
+onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
+ const _source = (global as any).source;
+ try {
+ const _identifier = await useIdentifier();
+ updateNote(note, _identifier);
+ emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, _source);
+ } catch (error) {
+ emitNet(events.NOTE_UPDATE_NOTE_FAILURE, _source);
+ }
+});
diff --git a/resources/utils/events.ts b/resources/utils/events.ts
index e9b1f67..0748506 100644
--- a/resources/utils/events.ts
+++ b/resources/utils/events.ts
@@ -32,7 +32,11 @@ export default {
CONTACTS_GET_CONTACTS: 'phone:getContacts',
CONTACTS_ADD_CONTACT_NUI: '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_ADD_LISTING: 'phone:addListing',
@@ -41,12 +45,32 @@ export default {
//
BANK_ADD_TRANSFER: 'phone:addTransfer',
+ BANK_ADD_TRANSFER_SUCCESS: 'phone:addTransferSuccess',
BANK_FETCH_TRANSACTIONS: 'phone:fetchAllTransactions',
BANK_SEND_TRANSFERS: 'phone:sendTransfers',
- BANK_TRANSACTION_ALERT: 'phone:transactionAlert',
+ BANK_TRANSACTION_ALERT: 'phone:bankTransactionAlert',
+ BANK_TRANSACTION_NOTIFICATION: 'phone:bankTransactionNotification',
BANK_SEND_CREDENTIALS: 'phone:sendBankCredentials',
BANK_GET_CREDENTIALS: 'phone:getBankCredentials',
//messages
MESSAGES_SEND_MESSAGE: 'phone:sendMessage',
+ MESSAGES_GET_MESSAGES: 'phone:getMessage',
+
+ // Notes
+ NOTE_ADD_NOTE: 'phone:addNote',
+ NOTE_FETCH_ALL_NOTES: 'phone:fetchAllNotes',
+ NOTE_SEND_NOTE: 'phone:sendNote',
+ NOTE_SEND_NOTE_SUCCESS: 'phone:sendNoteSuccess',
+ NOTE_DELETE_NOTE: 'phone:deleteNote',
+ NOTE_UPDATE_NOTE: 'phone:updateNote',
+ NOTE_UPDATE_NOTE_SUCCESS: 'phone:updateNoteSuccess',
+ NOTE_UPDATE_NOTE_FAILURE: 'phone:updateNoteFailure',
+
+ // DO NOT CHANGE WHATS BELOW, PLEASE - CHIP
+ OPEN_APP_CONTACTS: 'phone:app:CONTACTS',
+ OPEN_APP_BANK: 'phone:app:BANK',
+ OPEN_APP_NOTES: 'phone:app:NOTES',
+ OPEN_APP_LISTINGS: 'phone:app:SELLOUT'
+
}