mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
Merge branch 'master' of github.com:Re-Ignited-Development/new-phone-who-dis into feature/messages
This commit is contained in:
commit
b87baeb12e
52 files changed
+1214
-210
No files matched your search
+4
-1
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,9 @@
|
||||
top: 100px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.PhoneAppContainer {
|
||||
|
||||
+43
-52
@@ -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;
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
color: #388CF8 !important;
|
||||
}
|
||||
|
||||
|
||||
#bank-app .MuiSnackbar-root {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#bank-title {
|
||||
font-family: 'Bebas Neue', cursive;
|
||||
font-size: 50px;
|
||||
|
||||
@@ -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 = () => {
|
||||
<Route path="/bank/account" exact component={BankAccount} />
|
||||
<Route path="/bank/transactions" exact component={TransactionList} />
|
||||
</Switch>
|
||||
<BankAlert />
|
||||
</AppContent>
|
||||
<NavigationBar />
|
||||
</AppWrapper>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import React from "react";
|
||||
import MuiAlert from "@material-ui/lab/Alert";
|
||||
|
||||
export function Alert(props) {
|
||||
return <MuiAlert elevation={6} variant="filled" {...props} />;
|
||||
}
|
||||
|
||||
export default Alert;
|
||||
@@ -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 (
|
||||
<Snackbar
|
||||
style={{ width: "80%" }}
|
||||
open={open}
|
||||
autoHideDuration={6000}
|
||||
onClose={_handleClose}
|
||||
>
|
||||
<Alert onClose={_handleClose} severity={severity}>
|
||||
{message}
|
||||
</Alert>
|
||||
</Snackbar>
|
||||
);
|
||||
};
|
||||
@@ -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 (
|
||||
<div></div>
|
||||
)
|
||||
}
|
||||
<Notification
|
||||
key={notification.id}
|
||||
open={visible}
|
||||
handleClose={() => setVisible(false)}
|
||||
>
|
||||
<div className={classes.content}>
|
||||
<div className={classes.title}>
|
||||
<div className={classes.titleLeft}>
|
||||
<div className={classes.icon}>
|
||||
<FontAwesomeIcon icon={faWonSign} />
|
||||
</div>
|
||||
<div className={classes.heading}>{notification.type}</div>
|
||||
</div>
|
||||
<div className={classes.justNow}>{t("APPS_BANK_TIME_JUST_NOW")}</div>
|
||||
</div>
|
||||
<div className={classes.message}>{notification.source} sent you ${notification.transferAmount}. <br></br> {notification.message}</div>
|
||||
</div>
|
||||
</Notification>
|
||||
)
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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 (
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
@@ -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 };
|
||||
}
|
||||
@@ -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<Transfer | null>(bankState.notification);
|
||||
return { notification }
|
||||
}
|
||||
@@ -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 };
|
||||
}
|
||||
@@ -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 = () => {
|
||||
<AppTitle app={contacts}></AppTitle>
|
||||
<SearchContacts />
|
||||
<AddContactModal />
|
||||
<InfoModal key={contactDetail?.id} />
|
||||
<div className={showModal ? classes.backgroundModal : undefined} />
|
||||
<AppContent>
|
||||
<ContactList />
|
||||
|
||||
@@ -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 (
|
||||
<List>
|
||||
{contacts.contacts.filter(contact => contact.display.includes(filteredContacts) || contact.number.includes(filteredContacts)).map((contact) => (
|
||||
<>
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemAvatar>
|
||||
{contact.avatar ? (
|
||||
<MuiAvatar src={contact.avatar} />
|
||||
): (
|
||||
<MuiAvatar>{contact.display.slice(0, 1).toUpperCase()}</MuiAvatar>
|
||||
)}
|
||||
</ListItemAvatar>
|
||||
<ListItemText primary={contact.display} secondary={contact.number} />
|
||||
<Button onClick={() => startCall(contact.number)}>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log("Message: " + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
<Button onClick={openContactInfo}>
|
||||
<FontAwesomeIcon icon={faPen} size="lg"/>
|
||||
</Button>
|
||||
</ListItem>
|
||||
<Collapse in={showContactModal} timeout="auto" unmountOnExit>
|
||||
<List component="div" disablePadding>
|
||||
<ListItem className={classes.collapseItem}>
|
||||
<TextField
|
||||
value={contact.display}
|
||||
{contacts.contacts
|
||||
.filter(
|
||||
(contact) =>
|
||||
contact.display.includes(filteredContacts) ||
|
||||
contact.number.includes(filteredContacts)
|
||||
)
|
||||
.map((contact) => (
|
||||
<>
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemAvatar>
|
||||
{contact.avatar ? (
|
||||
<MuiAvatar src={contact.avatar} />
|
||||
) : (
|
||||
<MuiAvatar>
|
||||
{contact.display.slice(0, 1).toUpperCase()}
|
||||
</MuiAvatar>
|
||||
)}
|
||||
</ListItemAvatar>
|
||||
<ListItemText
|
||||
primary={contact.display}
|
||||
secondary={contact.number}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem className={classes.collapseItem}>
|
||||
<TextField
|
||||
value={contact.number}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem className={classes.collapseItem}>
|
||||
<Button className={classes.updateButton}>
|
||||
Update contact
|
||||
<Button onClick={() => startCall(contact.number)}>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log("Message: " + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
<Button
|
||||
style={{ margin: -15 }}
|
||||
onClick={() => openContactInfo(contact)}
|
||||
>
|
||||
<MoreVertIcon />
|
||||
</Button>
|
||||
</ListItem>
|
||||
</List>
|
||||
</Collapse>
|
||||
</>
|
||||
))}
|
||||
</>
|
||||
))}
|
||||
</List>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,111 @@
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Paper,
|
||||
Slide,
|
||||
Button,
|
||||
TextField,
|
||||
Avatar as MuiAvatar,
|
||||
} from "@material-ui/core";
|
||||
import useStyles from "./modal.styles";
|
||||
import { useContactModal } from "../../hooks/useContactModal";
|
||||
import ArrowBackIcon from "@material-ui/icons/ArrowBack";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useContactDetail } from "../../hooks/useContactDetail";
|
||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||
|
||||
export const InfoModal = () => {
|
||||
const classes = useStyles();
|
||||
const { showContactModal, setShowContactModal } = useContactModal();
|
||||
const { t } = useTranslation();
|
||||
const { contactDetail, setContactDetail } = useContactDetail();
|
||||
|
||||
const [display, setDisplay] = useState(
|
||||
contactDetail ? contactDetail.display : ""
|
||||
);
|
||||
console.log(contactDetail);
|
||||
const [number, setNumber] = useState(
|
||||
contactDetail ? contactDetail.number : ""
|
||||
);
|
||||
const [avatar, setAvatar] = useState(
|
||||
contactDetail ? contactDetail.avatar : ""
|
||||
);
|
||||
|
||||
const closeModal = () => {
|
||||
setShowContactModal(false);
|
||||
setContactDetail(null);
|
||||
};
|
||||
|
||||
const updateContact = () => {
|
||||
Nui.send("phone:updateContact", {
|
||||
id: contactDetail.id,
|
||||
display,
|
||||
number,
|
||||
avatar,
|
||||
});
|
||||
setContactDetail(null);
|
||||
setShowContactModal(false);
|
||||
};
|
||||
|
||||
const deleteContact = () => {
|
||||
Nui.send("phone:deleteContact", {
|
||||
id: contactDetail.id,
|
||||
});
|
||||
setContactDetail(null);
|
||||
setShowContactModal(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Slide direction="up" in={showContactModal}>
|
||||
<Paper
|
||||
className={showContactModal ? classes.modalRoot : classes.modalHide}
|
||||
>
|
||||
<Button style={{ margin: 10 }} onClick={closeModal}>
|
||||
<ArrowBackIcon />
|
||||
</Button>
|
||||
<div className={classes.listContainer}>
|
||||
<MuiAvatar className={classes.avatar} src={avatar} />
|
||||
<TextField
|
||||
className={classes.input}
|
||||
value={display}
|
||||
onChange={(e) => setDisplay(e.target.value)}
|
||||
placeholder={t("APPS_CONTACT_FORM_NAME")}
|
||||
fullWidth
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
value={number}
|
||||
onChange={(e) => setNumber(e.target.value)}
|
||||
placeholder={t("APPS_CONTACT_FORM_NUMBER")}
|
||||
fullWidth
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
placeholder={t("APPS_CONTACT_FORM_AVATAR")}
|
||||
fullWidth
|
||||
value={avatar}
|
||||
onChange={(e) => setAvatar(e.target.value)}
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
/>
|
||||
|
||||
<div style={{ display: "block" }}>
|
||||
<Button onClick={updateContact} className={classes.updateButton}>
|
||||
Update
|
||||
</Button>
|
||||
<Button onClick={deleteContact} className={classes.deleteButton}>
|
||||
Delete
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Paper>
|
||||
</Slide>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
import { makeStyles } from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
modalRoot: {
|
||||
zIndex: 10,
|
||||
position: 'absolute',
|
||||
height: '100%',
|
||||
width: '100%'
|
||||
},
|
||||
modalHide: {
|
||||
display: 'none'
|
||||
},
|
||||
listContainer: {
|
||||
marginTop: 30,
|
||||
width: '75%',
|
||||
margin: '0 auto',
|
||||
textAlign: 'center',
|
||||
},
|
||||
avatar: {
|
||||
margin: 'auto',
|
||||
height: '125px',
|
||||
width: '124px',
|
||||
marginBottom: 29
|
||||
},
|
||||
input: {
|
||||
marginBottom: 20,
|
||||
margin: 'auto',
|
||||
textAlign: 'center',
|
||||
},
|
||||
inputProps: {
|
||||
fontSize: 22
|
||||
},
|
||||
updateButton: {
|
||||
background: '#2196f3',
|
||||
width: 150,
|
||||
height: 45,
|
||||
fontSize: 16,
|
||||
marginTop: 29,
|
||||
marginBottom: 29
|
||||
},
|
||||
deleteButton: {
|
||||
background: '#d32f2f',
|
||||
width: 150,
|
||||
height: 40,
|
||||
fontSize: 16
|
||||
}
|
||||
}))
|
||||
|
||||
export default useStyles;
|
||||
@@ -16,5 +16,9 @@ export const contactsState = {
|
||||
showContactsModal: atom({
|
||||
key: 'showContactModal',
|
||||
default: false
|
||||
}),
|
||||
contactDetail: atom({
|
||||
key: 'contactDetail',
|
||||
default: null
|
||||
})
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { contactsState } from './state';
|
||||
|
||||
export const useContactDetail = (): any => {
|
||||
const [ contactDetail, setContactDetail ] = useRecoilState(contactsState.contactDetail);
|
||||
return { contactDetail, setContactDetail };
|
||||
}
|
||||
@@ -3,12 +3,6 @@ import { useRecoilState, atom } from "recoil";
|
||||
const dialerHistoryState = atom({
|
||||
key: "dialerHistory",
|
||||
default: [
|
||||
{
|
||||
id: 0,
|
||||
caller: "Kidz",
|
||||
phoneNumber: "000-1111",
|
||||
type: "incoming",
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
caller: "ROCKY",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#notes-app .Mui-focused::after {
|
||||
border-bottom: 3px solid #f9a825;
|
||||
}
|
||||
|
||||
#notes-app .MuiOutlinedInput-root {
|
||||
border: 2px soild #f9a825;
|
||||
}
|
||||
@@ -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 (
|
||||
<AppWrapper id="notes-app">
|
||||
<NotesTitle />
|
||||
<NoteModal key={detail?.id} />
|
||||
<AppContent>
|
||||
<NoteList notes={notes} />
|
||||
<Fab
|
||||
className={classes.absolute}
|
||||
onClick={handleModal}
|
||||
style={{
|
||||
background: "#f9a825",
|
||||
color: "#fff",
|
||||
}}
|
||||
>
|
||||
<AddIcon />
|
||||
</Fab>
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
@@ -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 (
|
||||
<Paper elevation={24} square variant="outlined" className={classes.header}>
|
||||
<FontAwesomeIcon icon={faStickyNote} color={yellow[800]} size="lg" />
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
|
||||
export default NotesTitle;
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
@@ -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 };
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { noteStates } from './state';
|
||||
|
||||
export const useNoteModal = () => {
|
||||
const [noteModal, setNoteModal] = useRecoilState(noteStates.noteModal);
|
||||
return { noteModal, setNoteModal };
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { noteStates } from './state';
|
||||
|
||||
export const useNotes = () => {
|
||||
const notes = useRecoilValue(noteStates.noteItems);
|
||||
return notes;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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 (
|
||||
<List>
|
||||
{notes.map((note) => (
|
||||
<ListItem key={note.id} button divider onClick={() => handleNoteModal(note)}>
|
||||
<ListItemText><strong>{note.title}</strong></ListItemText>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
)
|
||||
}
|
||||
|
||||
export default NoteList;
|
||||
@@ -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 (
|
||||
<div className={noteModal ? classes.modalRoot : classes.modalHide}>
|
||||
<Slide direction="left" in={noteModal} mountOnEnter unmountOnExit>
|
||||
<div>
|
||||
<Button className={classes.closeButton} onClick={_handleClose}>
|
||||
<ArrowBackIcon />
|
||||
</Button>
|
||||
<div id="notes-modal" className={classes.noteContainer}>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
placeholder="Title"
|
||||
inputProps={{
|
||||
className: classes.inputPropsTitle,
|
||||
}}
|
||||
fullWidth
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
inputProps={{
|
||||
className: classes.inputPropsContent,
|
||||
}}
|
||||
placeholder="Content"
|
||||
multiline
|
||||
fullWidth
|
||||
rows={19}
|
||||
variant="outlined"
|
||||
value={content}
|
||||
onChange={(e) => setContent(e.target.value)}
|
||||
/>
|
||||
{!detail && (
|
||||
<Button className={classes.saveButton} onClick={handleNoteSave}>
|
||||
Save
|
||||
</Button>
|
||||
)}
|
||||
{detail && (
|
||||
<Button
|
||||
className={classes.updateButton}
|
||||
onClick={handleUpdateNote}
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
)}
|
||||
{detail && (
|
||||
<Button
|
||||
className={classes.deleteButton}
|
||||
onClick={handleDeleteNote}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Slide>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export interface Note {
|
||||
id?: number;
|
||||
title: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface NoteId {
|
||||
id: number;
|
||||
}
|
||||
@@ -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(
|
||||
<HashRouter>
|
||||
<RecoilRoot>
|
||||
<TwitterNotification />
|
||||
<BankNotification />
|
||||
<Phone />
|
||||
</RecoilRoot>
|
||||
</HashRouter>,
|
||||
|
||||
@@ -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"
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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: () => <Route path="/sellout" component={SelloutApp} />,
|
||||
},
|
||||
{
|
||||
id: 'NOTES',
|
||||
name: 'APPS_NOTES',
|
||||
icon: <FontAwesomeIcon icon={faStickyNote} fixedWidth />,
|
||||
backgroundColor: yellow[800],
|
||||
color: common.white,
|
||||
path: "/notes",
|
||||
Route: () => <Route path="/notes" component={NotesApp}/>
|
||||
},
|
||||
{
|
||||
id: "EXAMPLE",
|
||||
nameLocale: "APPS_EXAMPLE",
|
||||
|
||||
@@ -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 (
|
||||
<Button className={classes.root}>
|
||||
<Button onClick={openAppCallback} className={classes.root}>
|
||||
<Avatar className={classes.avatar}>
|
||||
{icon || name[0].toUpperCase()}
|
||||
</Avatar>
|
||||
|
||||
@@ -32,7 +32,7 @@ function Notification({ children, handleClose, open }) {
|
||||
<Snackbar
|
||||
className={classes.snackBar}
|
||||
anchorOrigin={{ horizontal, vertical }}
|
||||
ClickAwayListenerProps={{ onClickAway: () => null }}
|
||||
ClickAwayListenerProps={{ onClickAway: () => setTimeout(() => { handleClose() }, 5000) }}
|
||||
onClose={handleClose}
|
||||
open={open}
|
||||
TransitionComponent={Fade}
|
||||
|
||||
@@ -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
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -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)
|
||||
})
|
||||
@@ -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",
|
||||
() => {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
@@ -4,6 +4,7 @@ import './cl_twitter';
|
||||
import './cl_contacts';
|
||||
import './cl_sellout';
|
||||
import './cl_bank';
|
||||
import './cl_notes';
|
||||
|
||||
export let ESX: ESXClient = null;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -6,6 +6,7 @@ import './sv_main';
|
||||
import './sv_contacts';
|
||||
import './sv_sellout';
|
||||
import './sv_bank';
|
||||
import './sv_notes';
|
||||
|
||||
export let ESX: ESXServer = null;
|
||||
|
||||
|
||||
+48
-36
@@ -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<Transfer[]> {
|
||||
@@ -33,63 +24,84 @@ function fetchCredentials(): Credentials {
|
||||
balance
|
||||
}
|
||||
|
||||
console.log(result.name, result.balance);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
async function addTransfer(identifier: string, transfer: Transfer): Promise<any> {
|
||||
|
||||
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 = <any>results;
|
||||
return await getTransfer(insertData.insertId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a transfer from its ID
|
||||
* @param transferId - transfer id
|
||||
*/
|
||||
async function getTransfer(transferId: number): Promise<Transfer> {
|
||||
const query = "SELECT * FROM npwd_bank_transfers WHERE id = ?"
|
||||
const [ results ] = await pool.query(query, [transferId]);
|
||||
const transfers = <Transfer[]>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");
|
||||
}
|
||||
})
|
||||
@@ -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<Contacts[]> {
|
||||
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<any> {
|
||||
const query = "UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?"
|
||||
await pool.query(query, [
|
||||
contact.number,
|
||||
contact.display,
|
||||
contact.avatar,
|
||||
contact.id,
|
||||
identifier
|
||||
])
|
||||
}
|
||||
|
||||
async function deleteContact(contact: ContactId, identifier: string): Promise<any> {
|
||||
const query = "DELETE FROM npwd_phone_contacts WHERE id = ? AND identifier = ?"
|
||||
await pool.query(query, [
|
||||
contact.id,
|
||||
identifier
|
||||
])
|
||||
}
|
||||
|
||||
onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
||||
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)
|
||||
}
|
||||
})
|
||||
@@ -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<any> {
|
||||
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<Note[]> {
|
||||
const query =
|
||||
"SELECT * FROM npwd_notes WHERE identifier = ? ORDER BY id DESC";
|
||||
const [result] = await pool.query(query, [identifier]);
|
||||
const notes = <Note[]>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<any> {
|
||||
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);
|
||||
}
|
||||
});
|
||||
@@ -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'
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user