|
@@ -1,10 +1,21 @@ |
|
|
import React from "react"; |
|
|
|
|
|
|
|
|
import React, { useState } from "react"; |
|
|
import styles from './AddShelf.module.scss'; |
|
|
import styles from './AddShelf.module.scss'; |
|
|
import { ReactComponent as CloseIcon } from '../../assets/icons/close.svg'; |
|
|
import { ReactComponent as CloseIcon } from '../../assets/icons/close.svg'; |
|
|
import { ReactComponent as PlusIcon } from '../../assets/icons/plus.svg'; |
|
|
import { ReactComponent as PlusIcon } from '../../assets/icons/plus.svg'; |
|
|
|
|
|
import { ReactComponent as CheckCircle } from '../../assets/icons/check.svg'; |
|
|
import { userProfileData } from "../home/Home"; |
|
|
import { userProfileData } from "../home/Home"; |
|
|
|
|
|
import { IShelf } from "../../structure/shelf"; |
|
|
|
|
|
|
|
|
export const AddShelf: React.FC = () => { |
|
|
export const AddShelf: React.FC = () => { |
|
|
|
|
|
const [selectedCategoryIndex, setCategoryIndex] = useState<number>(); |
|
|
|
|
|
const [newShelf, setnewSelf] = useState<IShelf>({ |
|
|
|
|
|
name: '', |
|
|
|
|
|
words: [], |
|
|
|
|
|
revisedWords: [], |
|
|
|
|
|
description: '', |
|
|
|
|
|
viewPermission: 'PRIVATE' |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
return <section className={styles.createShelfModal}> |
|
|
return <section className={styles.createShelfModal}> |
|
|
|
|
|
|
|
|
<header className={styles.modalHeader}> |
|
|
<header className={styles.modalHeader}> |
|
@@ -15,8 +26,18 @@ export const AddShelf: React.FC = () => { |
|
|
</header> |
|
|
</header> |
|
|
|
|
|
|
|
|
<section className={styles.form}> |
|
|
<section className={styles.form}> |
|
|
<input type="text" placeholder={'Shelf Name'} /> |
|
|
|
|
|
<textarea placeholder={'Add description'}></textarea> |
|
|
|
|
|
|
|
|
<input type="text" placeholder={'Shelf Name'} onInput={ (event) => { |
|
|
|
|
|
setnewSelf({ |
|
|
|
|
|
...newShelf, |
|
|
|
|
|
name: event.currentTarget.value, |
|
|
|
|
|
}); |
|
|
|
|
|
} } /> |
|
|
|
|
|
<textarea placeholder={'Add description'} onInput={ (event) => { |
|
|
|
|
|
setnewSelf({ |
|
|
|
|
|
...newShelf, |
|
|
|
|
|
description: event.currentTarget.value, |
|
|
|
|
|
}); |
|
|
|
|
|
} }></textarea> |
|
|
|
|
|
|
|
|
<section className={styles.Grid}> |
|
|
<section className={styles.Grid}> |
|
|
<header className={styles.blockHeader}> |
|
|
<header className={styles.blockHeader}> |
|
@@ -28,8 +49,10 @@ export const AddShelf: React.FC = () => { |
|
|
</button> |
|
|
</button> |
|
|
</header> |
|
|
</header> |
|
|
<ul> |
|
|
<ul> |
|
|
{ userProfileData.categories.map(category => { |
|
|
|
|
|
return <li key={category.name}> |
|
|
|
|
|
|
|
|
{ userProfileData.categories.map((category, index) => { |
|
|
|
|
|
return <li key={category.name} onClick={() => setCategoryIndex(index)} |
|
|
|
|
|
className={index === selectedCategoryIndex ? '' : styles.inactive}> |
|
|
|
|
|
{ index === selectedCategoryIndex && <span className={styles.checkmark}> <CheckCircle /> </span> } |
|
|
<div className={styles.icon}> |
|
|
<div className={styles.icon}> |
|
|
{ category.icon } |
|
|
{ category.icon } |
|
|
</div> |
|
|
</div> |
|
@@ -44,12 +67,24 @@ export const AddShelf: React.FC = () => { |
|
|
|
|
|
|
|
|
<section className={styles.toggleHolder}> |
|
|
<section className={styles.toggleHolder}> |
|
|
<label> Public </label> |
|
|
<label> Public </label> |
|
|
<div className={styles.toggle}> |
|
|
|
|
|
|
|
|
<div className={styles.toggle + ' ' + (newShelf.viewPermission === 'PUBLIC' ? styles.on : styles.off)} onClick={ () => { |
|
|
|
|
|
setnewSelf({ |
|
|
|
|
|
...newShelf, |
|
|
|
|
|
viewPermission: newShelf.viewPermission === 'PRIVATE' ? 'PUBLIC' : 'PRIVATE', |
|
|
|
|
|
}); |
|
|
|
|
|
} }> |
|
|
<span></span> |
|
|
<span></span> |
|
|
</div> |
|
|
</div> |
|
|
</section> |
|
|
</section> |
|
|
|
|
|
|
|
|
<button className={styles.publishButton}> Publish </button> |
|
|
|
|
|
|
|
|
<button className={styles.publishButton} onClick={() => { |
|
|
|
|
|
if (selectedCategoryIndex !== undefined) { |
|
|
|
|
|
userProfileData.categories[selectedCategoryIndex].shelves.push(newShelf); |
|
|
|
|
|
window.history.back(); |
|
|
|
|
|
} else { |
|
|
|
|
|
alert("select category"); |
|
|
|
|
|
} |
|
|
|
|
|
}}> Publish </button> |
|
|
</section> |
|
|
</section> |
|
|
</section> |
|
|
</section> |
|
|
} |
|
|
} |