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 { useNoteModal } from './hooks/useNoteModal';
|
||||
import { useNoteDetail } from './hooks/useNoteDetail';
|
||||
|
||||
import useStyles from './notes.styles';
|
||||
|
||||
export const NotesApp = () => {
|
||||
const { noteModal, setNoteModal } = useNoteModal();
|
||||
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 />
|
||||
<NoteModal key={detail?.id} />
|
||||
<AppContent>
|
||||
<NoteList notes={notes}/>
|
||||
<Fab
|
||||
|
||||
@@ -6,14 +6,12 @@ import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||
|
||||
// add search bar later
|
||||
const NoteList = ({notes}) => {
|
||||
|
||||
const { noteModal, setNoteModal } = useNoteModal();
|
||||
const { detail, setDetail } = useNoteDetail();
|
||||
const { setNoteModal } = useNoteModal();
|
||||
const { setDetail } = useNoteDetail();
|
||||
|
||||
const handleNoteModal = (note) => {
|
||||
setNoteModal(true)
|
||||
setDetail(note)
|
||||
console.log(note.id)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -16,10 +16,9 @@ import Nui from '../../../os/nui-events/utils/Nui';
|
||||
export const NoteModal = (note): any => {
|
||||
const { noteModal, setNoteModal } = useNoteModal();
|
||||
const { detail, setDetail } = useNoteDetail();
|
||||
|
||||
const notes = useNotes();
|
||||
const [title, setTitle] = useState('');
|
||||
const [content, setContent] = useState('');
|
||||
console.log(detail);
|
||||
const [title, setTitle] = useState(detail ? detail.title : "");
|
||||
const [content, setContent] = useState(detail ? detail.content: "");
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
@@ -51,20 +50,15 @@ export const NoteModal = (note): any => {
|
||||
setDetail(null)
|
||||
}
|
||||
|
||||
//const handleUpdateNote = () => {
|
||||
// const id = detail.id;
|
||||
// const detailTitle = detail.title;
|
||||
// const detailContent = detail.content
|
||||
// console.log("NOTE", detailTitle, detailContent)
|
||||
//
|
||||
// Nui.send('pone:updateNote', {
|
||||
// id,
|
||||
// detailTitle,
|
||||
// detailContent
|
||||
// })
|
||||
// setNoteModal(false);
|
||||
// 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}>
|
||||
@@ -79,8 +73,8 @@ export const NoteModal = (note): any => {
|
||||
className: classes.inputPropsTitle
|
||||
}}
|
||||
fullWidth
|
||||
value={detail ? detail.title : title}
|
||||
onChange={detail ? e => setDetail(e.target.value) : e => setTitle(e.target.value)}
|
||||
value={title}
|
||||
onChange={e => setTitle(e.target.value)}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
@@ -92,11 +86,12 @@ export const NoteModal = (note): any => {
|
||||
fullWidth
|
||||
rows={19}
|
||||
variant="outlined"
|
||||
value={detail ? detail.content : content}
|
||||
onChange={detail ? e => setDetail(e.target.value) : e => setContent(e.target.value)}
|
||||
value={content}
|
||||
onChange={e => setContent(e.target.value)}
|
||||
/>
|
||||
{detail ? null : <Button className={classes.saveButton} onClick={handleNoteSave}>Save</Button>}
|
||||
{detail ? <Button className={classes.deleteButton} onClick={handleDeleteNote}>Delete</Button> : null}
|
||||
{!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>
|
||||
|
||||
@@ -35,6 +35,11 @@ const useStyles = makeStyles((theme) => ({
|
||||
background: '#f9a825',
|
||||
padding: '10px 30px'
|
||||
},
|
||||
updateButton: {
|
||||
background: '#f9a825',
|
||||
padding: '10px 30px',
|
||||
marginRight: '8px'
|
||||
},
|
||||
deleteButton: {
|
||||
background: '#c62828',
|
||||
padding: '10px 30px'
|
||||
|
||||
Reference in new issue
Block a user