Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added created at, priority label and priority filter #79

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/assets/scss/components/storiesList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
cursor: pointer;
flex-grow: 2;
margin: 0px 16px;
width: 40%;
width: 30%;

h3 {
margin-bottom: 0.3rem;
Expand All @@ -57,7 +57,7 @@
align-items: center;
display: flex;
justify-content: space-between;
width: 40%;
width: 50%;
}

.story-heading {
Expand Down
38 changes: 37 additions & 1 deletion src/components/Stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const Stories = ({ authorId, followerId }) => {

const [categories, setCategories] = useState([])

const [priority, setPriority] = useState('All')

const [priorities, setPriorities] = useState([])

const [searchTerm, setSearchTerm] = useState('')

const { promiseInProgress } = usePromiseTracker({ area: 'stories-div' })
Expand All @@ -40,10 +44,14 @@ const Stories = ({ authorId, followerId }) => {

const categoryDropdownContainer = useRef()

const priorityDropdownContainer = useRef()

const [productQuery, setProductQuery] = useState(``)

const [categoryQuery, setCategoryQuery] = useState(``)

const [priorityQuery, setPriorityQuery] = useState(``)

const [searchQuery, setSearchQuery] = useState('')

const [userTerm, setUserTerm] = useState('')
Expand Down Expand Up @@ -90,13 +98,18 @@ const Stories = ({ authorId, followerId }) => {
} else {
setCategoryQuery(``)
}
if (priority !== 'All') {
setPriorityQuery(`Priority : "${priority}"`)
} else {
setPriorityQuery(``)
}
if (searchTerm === '') {
setSearchQuery('')
}
if (userTerm === '') {
setAuthorQuery('')
}
}, [category, searchTerm, userTerm])
}, [category, priority, searchTerm, userTerm])

useEffect(() => {
const fetchStories = async () => {
Expand All @@ -106,6 +119,7 @@ const Stories = ({ authorId, followerId }) => {
authorId,
authorQuery,
categoryQuery,
priorityQuery,
productQuery,
searchQuery,
followerId
Expand All @@ -115,6 +129,7 @@ const Stories = ({ authorId, followerId }) => {
trackPromise(fetchStories(), 'stories-div')
}, [
categoryQuery,
priorityQuery,
currentStateSelected,
page,
productQuery,
Expand All @@ -137,6 +152,19 @@ const Stories = ({ authorId, followerId }) => {
fetchCategories()
}, [])

useEffect(() => {
const fetchPriorities = async () => {
const response = await userStory.getPriorities()
setPriorities([
'All',
...response.data.data.__type.enumValues.map((ele) => {
return ele.name
})
])
}
fetchPriorities()
}, [])

useEffect(() => {
const comparatorVotes = (a, b) => {
return a.followers.length > b.followers.length ? -1 : 1
Expand Down Expand Up @@ -209,6 +237,14 @@ const Stories = ({ authorId, followerId }) => {
setAuthorQuery={setAuthorQuery}
/>
<div className='flex flex-row options-bar'>
<Dropdown
title='Priorities'
reference={priorityDropdownContainer}
curr={priority}
setCurr={setPriority}
itemList={priorities}
data-cy='priority-dropdown'
/>
<Dropdown
title='Categories'
reference={categoryDropdownContainer}
Expand Down
8 changes: 8 additions & 0 deletions src/components/StoriesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,18 @@ const StoriesList = (props) => {
</Link>
</div>
</div>
<div className='flex flex-column story-subcontent'>
<small>Created At</small>
<small>{story.createdAt}</small>
</div>
<div className='flex flex-column story-subcontent'>
<small>Category</small>
<span className='category-text'>{story.Category}</span>
</div>
<div className='flex flex-column story-subcontent'>
<small>Priority</small>
<span className='category-text'>{story.Priority}</span>
</div>
<div className='flex flex-column s-metas'>
<span className='story-meta'>
<i className='eos-icons'>attachment</i>
Expand Down
2 changes: 2 additions & 0 deletions src/services/user_story.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const userStory = {
username
}
Category
Priority
createdAt
}
}
`
Expand Down