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