mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Merge pull request #25 from Re-Ignited-Development/feature/sticky-notes
Feature/sticky notes, sorry Kire for not letting you review
This commit is contained in:
26 files changed
+604
-5
No files matched your search
@@ -20,6 +20,7 @@ import { useContactsService } from "./apps/contacts/hooks/useContactsService";
|
|||||||
import { useTwitterService } from "./apps/twitter/hooks/useTwitterService";
|
import { useTwitterService } from "./apps/twitter/hooks/useTwitterService";
|
||||||
import { useSelloutService } from "./apps/sellout/hooks/useSelloutService";
|
import { useSelloutService } from "./apps/sellout/hooks/useSelloutService";
|
||||||
import { useBankService } from './apps/bank/hooks/useBankService';
|
import { useBankService } from './apps/bank/hooks/useBankService';
|
||||||
|
import { useNotesService } from "./apps/notes/hooks/useNotesService";
|
||||||
|
|
||||||
//These events are just for testing. Comment it out before building.
|
//These events are just for testing. Comment it out before building.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -35,6 +36,30 @@ setTimeout(() => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.dispatchEvent(
|
||||||
|
new MessageEvent("message", {
|
||||||
|
data: {
|
||||||
|
app: 'NOTES',
|
||||||
|
method: 'setNotes',
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
title: 'First note',
|
||||||
|
content: 'Hello, this is my shitty note'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
title: 'Second note',
|
||||||
|
content: 'Hello, this is another shitty note'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
@@ -183,6 +208,7 @@ function Phone() {
|
|||||||
useInitKeyboard();
|
useInitKeyboard();
|
||||||
useSelloutService();
|
useSelloutService();
|
||||||
useBankService();
|
useBankService();
|
||||||
|
useNotesService();
|
||||||
|
|
||||||
if (visibility === false) {
|
if (visibility === false) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -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,9 @@
|
|||||||
|
export interface Note {
|
||||||
|
id?: number;
|
||||||
|
title: string;
|
||||||
|
content: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NoteId {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
@@ -39,9 +39,11 @@
|
|||||||
"APPS_TWITTER_TIME_HOURS": "h",
|
"APPS_TWITTER_TIME_HOURS": "h",
|
||||||
"APPS_TWITTER_TIME_DAYS": "d",
|
"APPS_TWITTER_TIME_DAYS": "d",
|
||||||
|
|
||||||
"APPS_BANK_HOME_TITLE": "Welcome, ",
|
"APPS_BANK_HOME_TITLE": "Welcome",
|
||||||
|
"APPS_BANK_ACCOUNT_LINK": "Account",
|
||||||
"APPS_BANK_ACCOUNT_TITLE": "Account Summary",
|
"APPS_BANK_ACCOUNT_TITLE": "Account Summary",
|
||||||
"APPS_BANK_ACCOUNT_TRANSACTIONS": "Transactions",
|
"APPS_BANK_ACCOUNT_TRANSACTIONS": "Transactions",
|
||||||
"APPS_BANK_ACCOUNT_SEE_TRANSACTION": "See all"
|
"APPS_BANK_ACCOUNT_SEE_TRANSACTION": "See all",
|
||||||
|
"APPS_BANK_ACTIONS_TRANSFER": "Transfer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
grey,
|
grey,
|
||||||
green,
|
green,
|
||||||
purple,
|
purple,
|
||||||
|
yellow,
|
||||||
red,
|
red,
|
||||||
amber,
|
amber,
|
||||||
} from "@material-ui/core/colors";
|
} from "@material-ui/core/colors";
|
||||||
@@ -14,7 +15,8 @@ import {
|
|||||||
faAd,
|
faAd,
|
||||||
faPlaneArrival,
|
faPlaneArrival,
|
||||||
faPhoneAlt,
|
faPhoneAlt,
|
||||||
faWonSign
|
faWonSign,
|
||||||
|
faStickyNote
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import { faTwitter } from "@fortawesome/free-brands-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 { TwitterApp } from "../../../apps/twitter/components/TwitterApp";
|
||||||
import { ExampleApp } from "../../../apps/example/components/ExampleApp";
|
import { ExampleApp } from "../../../apps/example/components/ExampleApp";
|
||||||
import { SelloutApp } from "../../../apps/sellout/components/SelloutApp";
|
import { SelloutApp } from "../../../apps/sellout/components/SelloutApp";
|
||||||
|
import { NotesApp } from "../../../apps/notes/NotesApp";
|
||||||
|
|
||||||
const appsState = atom({
|
const appsState = atom({
|
||||||
key: "apps",
|
key: "apps",
|
||||||
@@ -110,6 +113,15 @@ const appsState = atom({
|
|||||||
path: "/sellout",
|
path: "/sellout",
|
||||||
Route: () => <Route path="/sellout" component={SelloutApp} />,
|
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",
|
id: "EXAMPLE",
|
||||||
nameLocale: "APPS_EXAMPLE",
|
nameLocale: "APPS_EXAMPLE",
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ async function Phone() {
|
|||||||
emitNet(events.SELLOUT_FETCH_LISTING);
|
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||||
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
||||||
emitNet(events.BANK_GET_CREDENTIALS);
|
emitNet(events.BANK_GET_CREDENTIALS);
|
||||||
|
emitNet(events.NOTE_FETCH_ALL_NOTES);
|
||||||
console.log("Sellout fetched from client side")// Gets the credentials. Will eventually most likely only get the phone number and name, idk.
|
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
|
SetCursorLocation(0.90, 0.922) //Experimental
|
||||||
let res = GetActiveScreenResolution()
|
let res = GetActiveScreenResolution()
|
||||||
@@ -278,6 +279,7 @@ async function Phone() {
|
|||||||
emitNet(events.SELLOUT_FETCH_LISTING);
|
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||||
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
emitNet(events.BANK_FETCH_TRANSACTIONS);
|
||||||
emitNet(events.BANK_GET_CREDENTIALS);
|
emitNet(events.BANK_GET_CREDENTIALS);
|
||||||
|
emitNet(events.NOTE_FETCH_ALL_NOTES);
|
||||||
console.log("Sellout fetched from client side")
|
console.log("Sellout fetched from client side")
|
||||||
SetCursorLocation(0.936, 0.922) //Experimental
|
SetCursorLocation(0.936, 0.922) //Experimental
|
||||||
let res = GetActiveScreenResolution()
|
let res = GetActiveScreenResolution()
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
// coming soon tm
|
||||||
|
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_contacts';
|
||||||
import './cl_sellout';
|
import './cl_sellout';
|
||||||
import './cl_bank';
|
import './cl_bank';
|
||||||
|
import './cl_notes';
|
||||||
|
|
||||||
export let ESX: ESXClient = null;
|
export let ESX: ESXClient = null;
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,44 @@
|
|||||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="%PUBLIC_URL%/favicon.ico"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><title>React App</title></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="main.js"></script></body></html>
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="icon" href="/favicon.ico" />
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta name="theme-color" content="#000000" />
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="Web site created using create-react-app"
|
||||||
|
/>
|
||||||
|
<!--
|
||||||
|
manifest.json provides metadata used when your web app is installed on a
|
||||||
|
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Notice the use of in the tags above.
|
||||||
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
|
Only files inside the `public` folder can be referenced from the HTML.
|
||||||
|
|
||||||
|
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
|
||||||
|
work correctly both with client-side routing and a non-root public URL.
|
||||||
|
Learn how to configure a non-root public URL by running `npm run build`.
|
||||||
|
-->
|
||||||
|
<title>React App</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
<!--
|
||||||
|
This HTML file is a template.
|
||||||
|
If you open it directly in the browser, you will see an empty page.
|
||||||
|
|
||||||
|
You can add webfonts, meta tags, or analytics to this file.
|
||||||
|
The build step will place the bundled scripts into the <body> tag.
|
||||||
|
|
||||||
|
To begin the development, run `npm start` or `yarn start`.
|
||||||
|
To create a production bundle, use `npm run build` or `yarn build`.
|
||||||
|
-->
|
||||||
|
<script src="dev.js"></script></body>
|
||||||
|
</html>
|
||||||
Binary file not shown.
@@ -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
|
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;
|
) 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` (
|
CREATE TABLE IF NOT EXISTS `npwd_twitter_reports` (
|
||||||
`id` int NOT NULL AUTO_INCREMENT,
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
`profile_id` int NOT NULL,
|
`profile_id` int NOT NULL,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
|
import { ESX, getSource } from './server';
|
||||||
|
|
||||||
interface IPhoneNumber {
|
interface IPhoneNumber {
|
||||||
phone_number: string;
|
phone_number: string;
|
||||||
@@ -10,3 +11,8 @@ export async function usePhoneNumber(identifier: string): Promise<string> {
|
|||||||
const phoneNumber = <IPhoneNumber[]>results;
|
const phoneNumber = <IPhoneNumber[]>results;
|
||||||
return phoneNumber[0].phone_number;
|
return phoneNumber[0].phone_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function useIdentifier(): Promise<string> {
|
||||||
|
const identifier = await ESX.GetPlayerFromId(getSource()).getIdentifier()
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import './sv_main';
|
|||||||
import './sv_contacts';
|
import './sv_contacts';
|
||||||
import './sv_sellout';
|
import './sv_sellout';
|
||||||
import './sv_bank';
|
import './sv_bank';
|
||||||
|
import './sv_notes';
|
||||||
|
|
||||||
export let ESX: ESXServer = null;
|
export let ESX: ESXServer = null;
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
} 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);
|
||||||
|
emitNet(events.NOTE_SEND_NOTE_SUCCESS, _source);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -45,5 +45,15 @@ export default {
|
|||||||
BANK_SEND_TRANSFERS: 'phone:sendTransfers',
|
BANK_SEND_TRANSFERS: 'phone:sendTransfers',
|
||||||
BANK_TRANSACTION_ALERT: 'phone:transactionAlert',
|
BANK_TRANSACTION_ALERT: 'phone:transactionAlert',
|
||||||
BANK_SEND_CREDENTIALS: 'phone:sendBankCredentials',
|
BANK_SEND_CREDENTIALS: 'phone:sendBankCredentials',
|
||||||
BANK_GET_CREDENTIALS: 'phone:getBankCredentials'
|
BANK_GET_CREDENTIALS: 'phone:getBankCredentials',
|
||||||
|
|
||||||
|
// 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'
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user