From 2216e75659a2d3b54ba25be71a8be8b0a421e0ca Mon Sep 17 00:00:00 2001 From: sylenien Date: Thu, 29 Sep 2022 18:04:14 +0200 Subject: [PATCH] feat(ui): tags and some bugfixes --- .../Session_/EventsBlock/NoteEvent.tsx | 4 +-- .../components/Notes/NoteList.tsx | 24 ++++++++++++++++-- .../components/Notes/NoteTags.tsx | 25 +++++++++++++++++++ .../SessionHeader/SessionHeader.tsx | 24 ++++++++++++------ .../components/SessionTags/SessionTags.tsx | 2 +- .../components/SessionTags/index.ts | 2 +- frontend/app/mstore/notesStore.ts | 13 ++++++++-- 7 files changed, 78 insertions(+), 16 deletions(-) create mode 100644 frontend/app/components/shared/SessionListContainer/components/Notes/NoteTags.tsx diff --git a/frontend/app/components/Session_/EventsBlock/NoteEvent.tsx b/frontend/app/components/Session_/EventsBlock/NoteEvent.tsx index ae7a7245a..ba0003e3f 100644 --- a/frontend/app/components/Session_/EventsBlock/NoteEvent.tsx +++ b/frontend/app/components/Session_/EventsBlock/NoteEvent.tsx @@ -30,7 +30,7 @@ function NoteEvent(props: Props) { const onEdit = () => {}; const onCopy = () => { - copy(`${session(props.sessionId)}${props.timestamp > 0 ? '?jumpto=' + props.timestamp : ''}`); + copy(`${window.location.origin}${session(props.sessionId)}${props.timestamp > 0 ? '?jumpto=' + props.timestamp : ''}`); toast.success('Note URL copied to clipboard'); }; @@ -70,7 +70,7 @@ function NoteEvent(props: Props) {
- +
{props.message}
diff --git a/frontend/app/components/shared/SessionListContainer/components/Notes/NoteList.tsx b/frontend/app/components/shared/SessionListContainer/components/Notes/NoteList.tsx index f958bf917..8ee864dc4 100644 --- a/frontend/app/components/shared/SessionListContainer/components/Notes/NoteList.tsx +++ b/frontend/app/components/shared/SessionListContainer/components/Notes/NoteList.tsx @@ -4,17 +4,37 @@ import { sliceListPerPage } from 'App/utils'; import NoteItem from './NoteItem'; import { observer } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; +import { Note } from 'App/services/NotesService'; function NotesList({ members }: {members: Array>}) { const { notesStore } = useStore() + const [list, setList] = React.useState([]) React.useEffect(() => { if (!notesStore.notes.length) { - notesStore.fetchNotes() + notesStore.fetchNotes().then(notes => setList(notes)) } }, []) - const list = notesStore.notes + React.useEffect(() => { + if (notesStore.notes.length) { + if (notesStore.activeTags.length) { + const tagsLen = notesStore.activeTags.length + const filteredList: Note[] = notesStore.notes.filter(note => { + for (let i = 0; i < tagsLen; i++) { + const tag = notesStore.activeTags[i] + if (note.tags.includes(tag)) { + return note + } + } + }) + setList(filteredList) + } else { + setList(notesStore.notes) + } + } + }, [notesStore.activeTags]) + return ( + {TAGS.map((tag: iTag) => ( +
+ notesStore.toggleTag(tag)} + label={tag} + isActive={notesStore.activeTags.includes(tag)} + /> +
+ ))} + + ); +} + +export default observer(NoteTags); diff --git a/frontend/app/components/shared/SessionListContainer/components/SessionHeader/SessionHeader.tsx b/frontend/app/components/shared/SessionListContainer/components/SessionHeader/SessionHeader.tsx index b22500419..f3dd775d7 100644 --- a/frontend/app/components/shared/SessionListContainer/components/SessionHeader/SessionHeader.tsx +++ b/frontend/app/components/shared/SessionListContainer/components/SessionHeader/SessionHeader.tsx @@ -4,6 +4,7 @@ import { applyFilter } from 'Duck/search'; import Period from 'Types/app/period'; import SelectDateRange from 'Shared/SelectDateRange'; import SessionTags from '../SessionTags'; +import NoteTags from '../Notes/NoteTags'; import { connect } from 'react-redux'; import SessionSort from '../SessionSort'; import cn from 'classnames'; @@ -69,14 +70,21 @@ function SessionHeader(props: Props) { - {activeTab === 'all' &&
- -
- -
- - -
} + {activeTab === 'all' && ( +
+ +
+ +
+ + +
+ )} + {activeTab === 'notes' && ( +
+ +
+ )}
); } diff --git a/frontend/app/components/shared/SessionListContainer/components/SessionTags/SessionTags.tsx b/frontend/app/components/shared/SessionListContainer/components/SessionTags/SessionTags.tsx index 22824e6e5..b8eb23d1e 100644 --- a/frontend/app/components/shared/SessionListContainer/components/SessionTags/SessionTags.tsx +++ b/frontend/app/components/shared/SessionListContainer/components/SessionTags/SessionTags.tsx @@ -47,7 +47,7 @@ export default connect( } )(SessionTags); -function TagItem({ isActive, onClick, label, icon = '', disabled = false }: any) { +export function TagItem({ isActive, onClick, label, icon = '', disabled = false }: any) { return (