diff --git a/src/components/shelf-details/ShelfDetails.tsx b/src/components/shelf-details/ShelfDetails.tsx index 5fa62ff..0937084 100644 --- a/src/components/shelf-details/ShelfDetails.tsx +++ b/src/components/shelf-details/ShelfDetails.tsx @@ -112,7 +112,7 @@ export const ShelfDetails: React.FC = () => { history.push('/word-details/category_id=' + category_id + '&&shelf_id=' + shelf_id + '&&word_id=' + word.word._id); }}>
-

{ word.word.name } { word.word.pronounciation }

+

{ word.word.name } { word.word.pronounciation?.text }

diff --git a/src/components/word-details/WordDetails.module.scss b/src/components/word-details/WordDetails.module.scss index ca4d1ef..6c00380 100644 --- a/src/components/word-details/WordDetails.module.scss +++ b/src/components/word-details/WordDetails.module.scss @@ -24,18 +24,8 @@ h5 { font-size: 1.5rem; - } - - figure { - display: block; - - img { - display: block; - width: 4rem; - height: 4rem; - border-radius: 50%; - border: 1px solid var(--creamy-white); - } + margin-right: auto; + width: calc(100% - 8rem); } } @@ -146,6 +136,11 @@ &.sentence { opacity: 0.7; + + span { + font-style: italic; + font-size: 1.2rem; + } } } diff --git a/src/components/word-details/WordDetails.tsx b/src/components/word-details/WordDetails.tsx index 7cdb8a0..f9e2b80 100644 --- a/src/components/word-details/WordDetails.tsx +++ b/src/components/word-details/WordDetails.tsx @@ -1,25 +1,37 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import styles from './WordDetails.module.scss'; -import { userProfileData } from "../../App"; import queryString from 'query-string'; import { useLocation } from "react-router-dom"; -import { IShelf } from "../../structure/shelf"; -import { IWord } from "../../structure/word"; + import { ReactComponent as SpeakerIcon } from '../../assets/icons/speaker.svg'; import { ReactComponent as MoreIcon } from '../../assets/icons/more-alt.svg'; import { ReactComponent as ChevronLeft } from '../../assets/icons/chevron-left.svg'; import { ReactComponent as PlusIcon } from '../../assets/icons/plus.svg'; +import { MobileUser } from "../../shared/models/user"; +import { updateShelf } from "../../services/shelf"; +import { getAllData } from "../../services/user"; export const WordDetails: React.FC = () => { const location = useLocation(); - const category_id: any = queryString.parse(location.pathname)['/word-details/category_id']; - const shelf_id: any = queryString.parse(location.pathname)['shelf_id']; - const word_id: any = queryString.parse(location.pathname)['word_id']; - const shelf: IShelf = userProfileData.categories[category_id].shelves[shelf_id]; - const word: IWord = shelf.words[word_id]; + + const category_id = queryString.parse(location.pathname)['/word-details/category_id'] as string; + const shelf_id = queryString.parse(location.pathname)['shelf_id'] as string; + const word_id = queryString.parse(location.pathname)['word_id'] as string; + + const userProfile: MobileUser = JSON.parse(localStorage.getItem('userProfile') || ""); + const currentCategory = userProfile.categories.find(category => category._id === category_id); + let currentShelf = currentCategory?.shelves?.find(shelf => shelf._id === shelf_id); + const currentWord = currentShelf?.words?.find(word => word.word._id === word_id); + + const [notes, setNotes] = useState>(currentWord?.notes ? currentWord.notes : []); + const [showAddWord, setShowAddWord] = useState(false); const [newNote, setNewNote] = useState(''); + + useEffect(() => { + console.log("Rendering Word details"); + }, [notes]) return
@@ -27,38 +39,38 @@ export const WordDetails: React.FC = () => { -
{ shelf.name }
- -
- {/* eslint-disable-next-line */} - profile-image -
+
{ currentShelf?.name }
- { word.tag && { word.tag } }
-

{ word.name } { word.pronounciation }

+

{ currentWord?.word.name } { currentWord?.word.pronounciation?.text }

    - { word.grammaticalDetails.map((detail, index) => { + { currentWord?.word.grammaticalDetails.map((detail, index) => { return
  • -
    { detail.typeName }
    +
    { detail.type }

    { detail.description }

    - { detail.sentence &&

    "{ detail.sentence }"

    } + { detail.examples?.map((example, index) =>

    "{ example }" - { detail.context }

    ) }
  • }) } - { word.similarWords.length > 0 &&
  • -
    Similar:
    + { currentWord?.word.similarWords &&
  • +
    Synonyms:
    - { word.similarWords.map((similarWord, index) => ) } + { currentWord.word.similarWords.map((similarWord, index) => ) } +
    +
  • } + { currentWord?.word.oppositeWords &&
  • +
    Antonyms:
    +
    + { currentWord.word.oppositeWords.map((similarWord, index) => ) }
  • }
@@ -69,8 +81,8 @@ export const WordDetails: React.FC = () => {
My Notes:
- { word.notes &&
    - { word.notes.map((note, index) =>
  1. {note}
  2. ) } + { notes &&
      + { notes.map((note, index) =>
    1. {note}
    2. ) }
    } @@ -83,14 +95,47 @@ export const WordDetails: React.FC = () => {
    Add Category
    -