mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
cleanup(notes/nui)
This commit is contained in:
1 parent
2baa566883
commit
ba36ae3ddc
2 files changed
+88
-73
No files matched your search
@@ -1,19 +1,18 @@
|
||||
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 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 { 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 { useNoteModal } from './hooks/useNoteModal';
|
||||
import { useNoteDetail } from './hooks/useNoteDetail';
|
||||
|
||||
import useStyles from './notes.styles';
|
||||
import useStyles from "./notes.styles";
|
||||
|
||||
export const NotesApp = () => {
|
||||
const { setNoteModal } = useNoteModal();
|
||||
@@ -23,27 +22,27 @@ export const NotesApp = () => {
|
||||
const classes = useStyles();
|
||||
|
||||
const handleModal = () => {
|
||||
setNoteModal(true)
|
||||
setNoteModal(true);
|
||||
setDetail(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<AppWrapper id="notes-app">
|
||||
<NotesTitle />
|
||||
<NoteModal key={detail?.id} />
|
||||
<AppContent>
|
||||
<NoteList notes={notes}/>
|
||||
<Fab
|
||||
<NoteList notes={notes} />
|
||||
<Fab
|
||||
className={classes.absolute}
|
||||
onClick={handleModal}
|
||||
style={{
|
||||
background: '#f9a825',
|
||||
color: '#fff'
|
||||
background: "#f9a825",
|
||||
color: "#fff",
|
||||
}}
|
||||
>
|
||||
<AddIcon />
|
||||
</Fab>
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -1,85 +1,83 @@
|
||||
import { Button, List, ListItem, TextField, Slide, Paper } from '@material-ui/core';
|
||||
import React, { useState } from 'react'
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
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 { useNoteModal } from "../hooks/useNoteModal";
|
||||
import { useNoteDetail } from "../hooks/useNoteDetail";
|
||||
|
||||
import useStyles from './modal.styles';
|
||||
import useStyles from "./modal.styles";
|
||||
|
||||
import { useNotes } from '../hooks/useNotes';
|
||||
import "../NotesApp.css";
|
||||
import Nui from "../../../os/nui-events/utils/Nui";
|
||||
|
||||
|
||||
import '../NotesApp.css'
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
|
||||
export const NoteModal = (note): any => {
|
||||
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 [content, setContent] = useState(detail ? detail.content : "");
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
const _handleClose = () => {
|
||||
setNoteModal(false);
|
||||
console.log(note.title)
|
||||
setDetail(null)
|
||||
console.log(detail)
|
||||
}
|
||||
setDetail(null);
|
||||
};
|
||||
|
||||
const handleNoteSave = () => {
|
||||
console.log(detail)
|
||||
console.log(title, content)
|
||||
setNoteModal(false);
|
||||
setDetail(null)
|
||||
Nui.send('phone:addNote', {
|
||||
setDetail(null);
|
||||
Nui.send("phone:addNote", {
|
||||
title,
|
||||
content
|
||||
})
|
||||
}
|
||||
content,
|
||||
});
|
||||
};
|
||||
|
||||
const handleDeleteNote = () => {
|
||||
const id = detail.id
|
||||
const id = detail.id;
|
||||
setNoteModal(false);
|
||||
console.log("NoteID: " + id)
|
||||
Nui.send('phone:deleteNote', {
|
||||
id
|
||||
})
|
||||
setDetail(null)
|
||||
}
|
||||
Nui.send("phone:deleteNote", {
|
||||
id,
|
||||
});
|
||||
setDetail(null);
|
||||
};
|
||||
|
||||
const handleUpdateNote = () => {
|
||||
Nui.send('phone:updateNote', {
|
||||
id: detail.id,
|
||||
title,
|
||||
content
|
||||
});
|
||||
setNoteModal(false);
|
||||
setDetail(null)
|
||||
}
|
||||
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}>
|
||||
<Slide direction="left" in={noteModal} mountOnEnter unmountOnExit>
|
||||
<div>
|
||||
<Button className={classes.closeButton} onClick={_handleClose}><ArrowBackIcon /></Button>
|
||||
<Button className={classes.closeButton} onClick={_handleClose}>
|
||||
<ArrowBackIcon />
|
||||
</Button>
|
||||
<div id="notes-modal" className={classes.noteContainer}>
|
||||
<TextField
|
||||
<TextField
|
||||
className={classes.input}
|
||||
placeholder="Title"
|
||||
inputProps={{
|
||||
className: classes.inputPropsTitle
|
||||
className: classes.inputPropsTitle,
|
||||
}}
|
||||
fullWidth
|
||||
value={title}
|
||||
onChange={e => setTitle(e.target.value)}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
/>
|
||||
<TextField
|
||||
<TextField
|
||||
className={classes.input}
|
||||
inputProps={{
|
||||
className: classes.inputPropsContent
|
||||
className: classes.inputPropsContent,
|
||||
}}
|
||||
placeholder="Content"
|
||||
multiline
|
||||
@@ -87,14 +85,32 @@ export const NoteModal = (note): any => {
|
||||
rows={19}
|
||||
variant="outlined"
|
||||
value={content}
|
||||
onChange={e => setContent(e.target.value)}
|
||||
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>}
|
||||
{!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>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user