diff --git a/.eslintrc.js b/.eslintrc.js index dda1fed..6162820 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -37,7 +37,7 @@ module.exports = { 'explicit-module-boundary-types': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', 'jsx-a11y/no-autofocus': 'off', - 'no-console': 2, + 'no-console': 1, }, settings: { react: { diff --git a/src/components/AddEntryButton/AddEntryButton.tsx b/src/components/AddEntryButton/AddEntryButton.tsx index d877cc3..be5259b 100644 --- a/src/components/AddEntryButton/AddEntryButton.tsx +++ b/src/components/AddEntryButton/AddEntryButton.tsx @@ -14,7 +14,7 @@ const AddEntryButton = ({ onClick, errors }: AddEntryButtonProps) => { - - - - - - - {entriesFromDay.map(item => ( - - ))} - {entriesFromDay.length === 0 && ( - -

No time entries

- -
- )} -
- + + +
+ Selected date: + + + + + + +
+ + {entriesFromDay.map(item => ( + + ))} + {entriesFromDay.length === 0 && ( + +

No time entries

+ +
+ )} +
+
+
) } diff --git a/src/components/EntryList/ListItem/ListItem.tsx b/src/components/EntryList/ListItem/ListItem.tsx index d3c87d2..674c277 100644 --- a/src/components/EntryList/ListItem/ListItem.tsx +++ b/src/components/EntryList/ListItem/ListItem.tsx @@ -1,15 +1,16 @@ -import { SPACING_SMALL } from 'config' -import { useContext } from 'react' -import { BsFillPencilFill, BsFillTrashFill } from 'react-icons/bs' -import { DB, TimeEntry } from 'services' -import { Button, TextArea } from 'shared/components' +import { DISABLED_ENTRY_LIST_ITEMS_TEXT, SPACING_SMALL } from 'config' +import { BsCheckLg, BsFillPencilFill, BsFillTrashFill } from 'react-icons/bs' +import { TimeEntry } from 'services' +import { Button, TextArea, Tooltip } from 'shared/components' import { Label } from 'shared/types' -import { EntryListContext } from 'shared/utils' import { EntryTimeField, Labels } from '../../index' import { ActionsWrapper, Item } from './ListItem.style' -import { calculateTimeEntry, getSelectedLabels } from './ListItem.utils' - -const db = new DB() +import { + calculateTimeEntry, + getSelectedLabels, + useDeleteEntry, + useEdit, +} from './ListItem.utils' interface ListItemProps extends TimeEntry { labels: Label[] @@ -23,25 +24,34 @@ const ListItem = ({ labels, id, }: ListItemProps) => { - const { setUpdateEntryList } = useContext(EntryListContext) || {} - const deleteEntry = () => { - db.deleteTimeEntry(id) - setUpdateEntryList?.(true) - } + const deleteEntry = useDeleteEntry(id) + const { disabled, toggleEditing } = useEdit(id) return ( -