mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
working updates
This commit is contained in:
1 parent
18be1a7d0f
commit
ce951ceecc
10 files changed
+92
-53
No files matched your search
@@ -11,23 +11,26 @@ import { Fab } from '@material-ui/core';
|
|||||||
import AddIcon from '@material-ui/icons/Add';
|
import AddIcon from '@material-ui/icons/Add';
|
||||||
|
|
||||||
import { useNoteModal } from './hooks/useNoteModal';
|
import { useNoteModal } from './hooks/useNoteModal';
|
||||||
|
import { useNoteDetail } from './hooks/useNoteDetail';
|
||||||
|
|
||||||
import useStyles from './notes.styles';
|
import useStyles from './notes.styles';
|
||||||
|
|
||||||
export const NotesApp = () => {
|
export const NotesApp = () => {
|
||||||
const { noteModal, setNoteModal } = useNoteModal();
|
const { setNoteModal } = useNoteModal();
|
||||||
|
const { detail, setDetail } = useNoteDetail();
|
||||||
const notes = useNotes();
|
const notes = useNotes();
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
const handleModal = () => {
|
const handleModal = () => {
|
||||||
setNoteModal(true)
|
setNoteModal(true)
|
||||||
|
setDetail(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppWrapper id="notes-app">
|
<AppWrapper id="notes-app">
|
||||||
<NotesTitle />
|
<NotesTitle />
|
||||||
<NoteModal />
|
<NoteModal key={detail?.id} />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<NoteList notes={notes}/>
|
<NoteList notes={notes}/>
|
||||||
<Fab
|
<Fab
|
||||||
|
|||||||
@@ -6,14 +6,12 @@ import { useNoteDetail } from '../hooks/useNoteDetail';
|
|||||||
|
|
||||||
// add search bar later
|
// add search bar later
|
||||||
const NoteList = ({notes}) => {
|
const NoteList = ({notes}) => {
|
||||||
|
const { setNoteModal } = useNoteModal();
|
||||||
const { noteModal, setNoteModal } = useNoteModal();
|
const { setDetail } = useNoteDetail();
|
||||||
const { detail, setDetail } = useNoteDetail();
|
|
||||||
|
|
||||||
const handleNoteModal = (note) => {
|
const handleNoteModal = (note) => {
|
||||||
setNoteModal(true)
|
setNoteModal(true)
|
||||||
setDetail(note)
|
setDetail(note)
|
||||||
console.log(note.id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -16,10 +16,9 @@ import Nui from '../../../os/nui-events/utils/Nui';
|
|||||||
export const NoteModal = (note): any => {
|
export const NoteModal = (note): any => {
|
||||||
const { noteModal, setNoteModal } = useNoteModal();
|
const { noteModal, setNoteModal } = useNoteModal();
|
||||||
const { detail, setDetail } = useNoteDetail();
|
const { detail, setDetail } = useNoteDetail();
|
||||||
|
console.log(detail);
|
||||||
const notes = useNotes();
|
const [title, setTitle] = useState(detail ? detail.title : "");
|
||||||
const [title, setTitle] = useState('');
|
const [content, setContent] = useState(detail ? detail.content: "");
|
||||||
const [content, setContent] = useState('');
|
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
@@ -51,20 +50,15 @@ export const NoteModal = (note): any => {
|
|||||||
setDetail(null)
|
setDetail(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
//const handleUpdateNote = () => {
|
const handleUpdateNote = () => {
|
||||||
// const id = detail.id;
|
Nui.send('phone:updateNote', {
|
||||||
// const detailTitle = detail.title;
|
id: detail.id,
|
||||||
// const detailContent = detail.content
|
title,
|
||||||
// console.log("NOTE", detailTitle, detailContent)
|
content
|
||||||
//
|
});
|
||||||
// Nui.send('pone:updateNote', {
|
setNoteModal(false);
|
||||||
// id,
|
setDetail(null)
|
||||||
// detailTitle,
|
}
|
||||||
// detailContent
|
|
||||||
// })
|
|
||||||
// setNoteModal(false);
|
|
||||||
// setDetail(null)
|
|
||||||
//}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={noteModal ? classes.modalRoot : classes.modalHide}>
|
<div className={noteModal ? classes.modalRoot : classes.modalHide}>
|
||||||
@@ -79,8 +73,8 @@ export const NoteModal = (note): any => {
|
|||||||
className: classes.inputPropsTitle
|
className: classes.inputPropsTitle
|
||||||
}}
|
}}
|
||||||
fullWidth
|
fullWidth
|
||||||
value={detail ? detail.title : title}
|
value={title}
|
||||||
onChange={detail ? e => setDetail(e.target.value) : e => setTitle(e.target.value)}
|
onChange={e => setTitle(e.target.value)}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
@@ -92,11 +86,12 @@ export const NoteModal = (note): any => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
rows={19}
|
rows={19}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={detail ? detail.content : content}
|
value={content}
|
||||||
onChange={detail ? e => setDetail(e.target.value) : e => setContent(e.target.value)}
|
onChange={e => setContent(e.target.value)}
|
||||||
/>
|
/>
|
||||||
{detail ? null : <Button className={classes.saveButton} onClick={handleNoteSave}>Save</Button>}
|
{!detail && <Button className={classes.saveButton} onClick={handleNoteSave}>Save</Button>}
|
||||||
{detail ? <Button className={classes.deleteButton} onClick={handleDeleteNote}>Delete</Button> : null}
|
{detail && <Button className={classes.updateButton} onClick={handleUpdateNote}>Update</Button>}
|
||||||
|
{detail && <Button className={classes.deleteButton} onClick={handleDeleteNote}>Delete</Button>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Slide>
|
</Slide>
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
background: '#f9a825',
|
background: '#f9a825',
|
||||||
padding: '10px 30px'
|
padding: '10px 30px'
|
||||||
},
|
},
|
||||||
|
updateButton: {
|
||||||
|
background: '#f9a825',
|
||||||
|
padding: '10px 30px',
|
||||||
|
marginRight: '8px'
|
||||||
|
},
|
||||||
deleteButton: {
|
deleteButton: {
|
||||||
background: '#c62828',
|
background: '#c62828',
|
||||||
padding: '10px 30px'
|
padding: '10px 30px'
|
||||||
|
|||||||
@@ -33,14 +33,12 @@ on(`__cfx_nui:${events.NOTE_DELETE_NOTE}`, (data: any) => {
|
|||||||
|
|
||||||
|
|
||||||
// coming soon tm
|
// coming soon tm
|
||||||
|
RegisterNuiCallbackType(events.NOTE_UPDATE_NOTE);
|
||||||
/*RegisterNuiCallbackType(events.NOTE_UPDATE_NOTE);
|
|
||||||
on(`__cfx_nui:${events.NOTE_UPDATE_NOTE}`, (data: any) => {
|
on(`__cfx_nui:${events.NOTE_UPDATE_NOTE}`, (data: any) => {
|
||||||
const note = data;
|
const note = data;
|
||||||
emitNet(events.NOTE_UPDATE_NOTE, note)
|
emitNet(events.NOTE_UPDATE_NOTE, note)
|
||||||
|
})
|
||||||
|
|
||||||
|
onNet(events.NOTE_UPDATE_NOTE_SUCCESS, () => {
|
||||||
setTimeout(() => {
|
emitNet(events.NOTE_FETCH_ALL_NOTES)
|
||||||
emitNet(events.NOTE_FETCH_ALL_NOTES)
|
});
|
||||||
}, 500);
|
|
||||||
})*/
|
|
||||||
@@ -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.
@@ -58,7 +58,7 @@ CREATE TABLE IF NOT EXISTS `npwd_twitter_likes` (
|
|||||||
) 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 EXIST npwd_notes (
|
CREATE TABLE IF NOT EXISTS npwd_notes (
|
||||||
id int(11) NOT NULL AUTO_INCREMENT,
|
id int(11) NOT NULL AUTO_INCREMENT,
|
||||||
identifier varchar(255) NOT NULL,
|
identifier varchar(255) NOT NULL,
|
||||||
title varchar(255) NOT NULL,
|
title varchar(255) NOT NULL,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { pool } from './db';
|
|||||||
import { useIdentifier } from './functions';
|
import { useIdentifier } from './functions';
|
||||||
|
|
||||||
interface Note {
|
interface Note {
|
||||||
|
id?: number;
|
||||||
title: string;
|
title: string;
|
||||||
content: string;
|
content: string;
|
||||||
}
|
}
|
||||||
@@ -12,12 +13,6 @@ interface NoteId {
|
|||||||
id: number
|
id: number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UpdateNote {
|
|
||||||
id: number;
|
|
||||||
title: string;
|
|
||||||
content: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function addNote(identifier: string, note: Note): Promise<any> {
|
async function addNote(identifier: string, note: Note): Promise<any> {
|
||||||
const query = "INSERT INTO npwd_notes (identifier, title, content) VALUES (?, ?, ?)"
|
const query = "INSERT INTO npwd_notes (identifier, title, content) VALUES (?, ?, ?)"
|
||||||
await pool.query(query,
|
await pool.query(query,
|
||||||
@@ -41,7 +36,7 @@ async function deleteNote(noteId: number, identifier: string) {
|
|||||||
await pool.query(query, [noteId, identifier])
|
await pool.query(query, [noteId, identifier])
|
||||||
}
|
}
|
||||||
|
|
||||||
/*async function updateNote(note: UpdateNote, identifier: string): Promise<any> {
|
async function updateNote(note: Note, identifier: string): Promise<any> {
|
||||||
const query = "UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?"
|
const query = "UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?"
|
||||||
await pool.query(query, [
|
await pool.query(query, [
|
||||||
note.title,
|
note.title,
|
||||||
@@ -49,7 +44,7 @@ async function deleteNote(noteId: number, identifier: string) {
|
|||||||
note.id,
|
note.id,
|
||||||
identifier
|
identifier
|
||||||
])
|
])
|
||||||
}*/
|
}
|
||||||
|
|
||||||
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
||||||
try {
|
try {
|
||||||
@@ -84,13 +79,13 @@ onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// coming soon tm
|
onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
|
||||||
|
const _source = (global as any).source;
|
||||||
/*onNet(events.NOTE_UPDATE_NOTE, async (note: UpdateNote) => {
|
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier();
|
const _identifier = await useIdentifier();
|
||||||
updateNote(note, _identifier)
|
updateNote(note, _identifier)
|
||||||
|
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, _source)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("NOTE ERROR:", error)
|
emitNet(events.NOTE_UPDATE_NOTE_FAILURE, _source)
|
||||||
}
|
}
|
||||||
})*/
|
})
|
||||||
@@ -52,5 +52,7 @@ export default {
|
|||||||
NOTE_FETCH_ALL_NOTES: 'phone:fetchAllNotes',
|
NOTE_FETCH_ALL_NOTES: 'phone:fetchAllNotes',
|
||||||
NOTE_SEND_NOTE: 'phone:sendNote',
|
NOTE_SEND_NOTE: 'phone:sendNote',
|
||||||
NOTE_DELETE_NOTE: 'phone:deleteNote',
|
NOTE_DELETE_NOTE: 'phone:deleteNote',
|
||||||
NOTE_UPDATE_NOTE: 'phone:updateNote'
|
NOTE_UPDATE_NOTE: 'phone:updateNote',
|
||||||
|
NOTE_UPDATE_NOTE_SUCCESS: 'phone:updateNoteSuccess',
|
||||||
|
NOTE_UPDATE_NOTE_FAILURE: 'phone:updateNoteFailure'
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user