mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
feat(phone): Doucment list component
This commit is contained in:
1 parent
b7ff65f74e
commit
0f2cc6da35
2 files changed
+41
-2
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import { List, ListItem, ListItemIcon, ListItemText } from '@material-ui/core';
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import NoteIcon from '@material-ui/icons/Note';
|
||||
import RecentActorsIcon from '@material-ui/icons/RecentActors';
|
||||
import { useHistory } from 'react-router';
|
||||
|
||||
export default function DoucmentList() {
|
||||
const { t } = useTranslation();
|
||||
const history = useHistory();
|
||||
|
||||
const [list, setList] = useState([
|
||||
{
|
||||
id: 1,
|
||||
name: t('APPS_DOCUMENTS_NOTES_TITLE'),
|
||||
icon: <NoteIcon />,
|
||||
route: '/documents/notes',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: t('APPS_DOCUMENTS_LICENSE_TITLE'),
|
||||
icon: <RecentActorsIcon />,
|
||||
route: '/documents/licenses',
|
||||
},
|
||||
]);
|
||||
|
||||
return (
|
||||
<List disablePadding>
|
||||
{list.map((l) => (
|
||||
<ListItem divider button key={l.id} onClick={() => history.push(l.route)}>
|
||||
<ListItemIcon>{l.icon}</ListItemIcon>
|
||||
<ListItemText primary={l.name} />
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { List, ListItem, ListItemText } from '@material-ui/core';
|
||||
import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||
import { useNotes } from '../hooks/useNotes';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import useStyles from '../notes.styles';
|
||||
|
||||
// add search bar later
|
||||
// TODO: Add interface for note
|
||||
@@ -10,17 +11,18 @@ const NoteList = () => {
|
||||
const history = useHistory();
|
||||
const { notes } = useNotes();
|
||||
const { setDetail } = useNoteDetail();
|
||||
const classes = useStyles();
|
||||
|
||||
const handleNoteModal = (note) => {
|
||||
setDetail(note);
|
||||
history.push('/notes/detail');
|
||||
history.push('/documents/notes/detail');
|
||||
};
|
||||
|
||||
return (
|
||||
<List disablePadding>
|
||||
{notes.map((note) => (
|
||||
<ListItem key={note.id} button divider onClick={() => handleNoteModal(note)}>
|
||||
<ListItemText>{note.title}</ListItemText>
|
||||
<ListItemText primary={note.title} secondary={`${note.content.slice(0, 35)}...`} />
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
|
||||
Reference in new issue
Block a user