From ba36ae3ddc661f0d238efe3c3c5ab95ad6af1481 Mon Sep 17 00:00:00 2001 From: chip Date: Sun, 1 Nov 2020 19:28:56 +0100 Subject: [PATCH] cleanup(notes/nui) --- phone/src/apps/notes/NotesApp.tsx | 41 ++++---- phone/src/apps/notes/modal/NoteModal.tsx | 120 +++++++++++++---------- 2 files changed, 88 insertions(+), 73 deletions(-) diff --git a/phone/src/apps/notes/NotesApp.tsx b/phone/src/apps/notes/NotesApp.tsx index 9db0372..d7d51bd 100644 --- a/phone/src/apps/notes/NotesApp.tsx +++ b/phone/src/apps/notes/NotesApp.tsx @@ -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 ( - - + - ) -} + ); +}; diff --git a/phone/src/apps/notes/modal/NoteModal.tsx b/phone/src/apps/notes/modal/NoteModal.tsx index 005d741..141d752 100644 --- a/phone/src/apps/notes/modal/NoteModal.tsx +++ b/phone/src/apps/notes/modal/NoteModal.tsx @@ -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 (
- +
- +
- setTitle(e.target.value)} + onChange={(e) => setTitle(e.target.value)} /> - { rows={19} variant="outlined" value={content} - onChange={e => setContent(e.target.value)} + onChange={(e) => setContent(e.target.value)} /> - {!detail && } - {detail && } - {detail && } + {!detail && ( + + )} + {detail && ( + + )} + {detail && ( + + )}
- ) -} + ); +};