-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
add solution #2684
Open
TargoniyAnatoliy
wants to merge
6
commits into
mate-academy:master
Choose a base branch
from
TargoniyAnatoliy:develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add solution #2684
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
de4a8fc
add solution
TargoniyAnatoliy b88fcb2
add solution after reinstall modules
TargoniyAnatoliy e586c1a
add condition render in query button
TargoniyAnatoliy 9f9390f
change modal header
TargoniyAnatoliy b91cc60
add solution after tests
TargoniyAnatoliy 706481f
add changes after review
TargoniyAnatoliy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,57 @@ | ||
export const TodoFilter = () => ( | ||
<form className="field has-addons"> | ||
<p className="control"> | ||
<span className="select"> | ||
<select data-cy="statusSelect"> | ||
<option value="all">All</option> | ||
<option value="active">Active</option> | ||
<option value="completed">Completed</option> | ||
</select> | ||
</span> | ||
</p> | ||
import React, { Dispatch, SetStateAction } from 'react'; | ||
import { Filters } from '../../types/Filters'; | ||
|
||
<p className="control is-expanded has-icons-left has-icons-right"> | ||
<input | ||
data-cy="searchInput" | ||
type="text" | ||
className="input" | ||
placeholder="Search..." | ||
/> | ||
<span className="icon is-left"> | ||
<i className="fas fa-magnifying-glass" /> | ||
</span> | ||
type Props = { | ||
query: string; | ||
setQuery: Dispatch<SetStateAction<string>>; | ||
setFilter: Dispatch<SetStateAction<Filters>>; | ||
}; | ||
|
||
<span className="icon is-right" style={{ pointerEvents: 'all' }}> | ||
{/* eslint-disable-next-line jsx-a11y/control-has-associated-label */} | ||
<button data-cy="clearSearchButton" type="button" className="delete" /> | ||
</span> | ||
</p> | ||
</form> | ||
); | ||
export const TodoFilter: React.FC<Props> = props => { | ||
const { query, setQuery, setFilter } = props; | ||
|
||
return ( | ||
<form className="field has-addons"> | ||
<p className="control"> | ||
<span className="select"> | ||
<select | ||
data-cy="statusSelect" | ||
onChange={e => setFilter(e.target.value as Filters)} | ||
> | ||
<option value={Filters.All}>All</option> | ||
<option value={Filters.Active}>Active</option> | ||
<option value={Filters.Completed}>Completed</option> | ||
</select> | ||
</span> | ||
</p> | ||
|
||
<p className="control is-expanded has-icons-left has-icons-right"> | ||
<input | ||
data-cy="searchInput" | ||
type="text" | ||
className="input" | ||
placeholder="Search..." | ||
value={query} | ||
onChange={(event: React.ChangeEvent<HTMLInputElement>) => | ||
setQuery(event.target.value) | ||
} | ||
/> | ||
<span className="icon is-left"> | ||
<i className="fas fa-magnifying-glass" /> | ||
</span> | ||
|
||
{query && ( | ||
<span className="icon is-right" style={{ pointerEvents: 'all' }}> | ||
{/* eslint-disable-next-line jsx-a11y/control-has-associated-label */} | ||
<button | ||
data-cy="clearSearchButton" | ||
type="button" | ||
className="delete" | ||
onClick={() => setQuery('')} | ||
/> | ||
</span> | ||
)} | ||
</p> | ||
</form> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,83 @@ | ||
import React from 'react'; | ||
import React, { Dispatch, SetStateAction } from 'react'; | ||
import cn from 'classnames'; | ||
import { Todo } from '../../types/Todo'; | ||
|
||
export const TodoList: React.FC = () => ( | ||
<table className="table is-narrow is-fullwidth"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th> | ||
<span className="icon"> | ||
<i className="fas fa-check" /> | ||
</span> | ||
</th> | ||
<th>Title</th> | ||
<th> </th> | ||
</tr> | ||
</thead> | ||
type Props = { | ||
todos: Todo[]; | ||
selectTodoId: Dispatch<SetStateAction<number | null>>; | ||
selectedTodoId: number | null; | ||
}; | ||
|
||
<tbody> | ||
<tr data-cy="todo" className=""> | ||
<td className="is-vcentered">1</td> | ||
<td className="is-vcentered" /> | ||
<td className="is-vcentered is-expanded"> | ||
<p className="has-text-danger">delectus aut autem</p> | ||
</td> | ||
<td className="has-text-right is-vcentered"> | ||
<button data-cy="selectButton" className="button" type="button"> | ||
<span className="icon"> | ||
<i className="far fa-eye" /> | ||
</span> | ||
</button> | ||
</td> | ||
</tr> | ||
<tr data-cy="todo" className="has-background-info-light"> | ||
<td className="is-vcentered">2</td> | ||
<td className="is-vcentered" /> | ||
<td className="is-vcentered is-expanded"> | ||
<p className="has-text-danger">quis ut nam facilis et officia qui</p> | ||
</td> | ||
<td className="has-text-right is-vcentered"> | ||
<button data-cy="selectButton" className="button" type="button"> | ||
<span className="icon"> | ||
<i className="far fa-eye-slash" /> | ||
</span> | ||
</button> | ||
</td> | ||
</tr> | ||
export const TodoList: React.FC<Props> = props => { | ||
const { todos, selectTodoId, selectedTodoId } = props; | ||
|
||
<tr data-cy="todo" className=""> | ||
<td className="is-vcentered">1</td> | ||
<td className="is-vcentered" /> | ||
<td className="is-vcentered is-expanded"> | ||
<p className="has-text-danger">delectus aut autem</p> | ||
</td> | ||
<td className="has-text-right is-vcentered"> | ||
<button data-cy="selectButton" className="button" type="button"> | ||
return ( | ||
<table className="table is-narrow is-fullwidth"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th> | ||
<span className="icon"> | ||
<i className="far fa-eye" /> | ||
<i className="fas fa-check" /> | ||
</span> | ||
</button> | ||
</td> | ||
</tr> | ||
</th> | ||
<th>Title</th> | ||
<th> </th> | ||
</tr> | ||
</thead> | ||
|
||
<tr data-cy="todo" className=""> | ||
<td className="is-vcentered">6</td> | ||
<td className="is-vcentered" /> | ||
<td className="is-vcentered is-expanded"> | ||
<p className="has-text-danger"> | ||
qui ullam ratione quibusdam voluptatem quia omnis | ||
</p> | ||
</td> | ||
<td className="has-text-right is-vcentered"> | ||
<button data-cy="selectButton" className="button" type="button"> | ||
<span className="icon"> | ||
<i className="far fa-eye" /> | ||
</span> | ||
</button> | ||
</td> | ||
</tr> | ||
|
||
<tr data-cy="todo" className=""> | ||
<td className="is-vcentered">8</td> | ||
<td className="is-vcentered"> | ||
<span className="icon" data-cy="iconCompleted"> | ||
<i className="fas fa-check" /> | ||
</span> | ||
</td> | ||
<td className="is-vcentered is-expanded"> | ||
<p className="has-text-success">quo adipisci enim quam ut ab</p> | ||
</td> | ||
<td className="has-text-right is-vcentered"> | ||
<button data-cy="selectButton" className="button" type="button"> | ||
<span className="icon"> | ||
<i className="far fa-eye" /> | ||
</span> | ||
</button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
); | ||
<tbody> | ||
{todos.length === 0 ? ( | ||
<tr> | ||
<td colSpan={4}>No data</td> | ||
</tr> | ||
) : ( | ||
todos.map(todo => ( | ||
<tr | ||
data-cy="todo" | ||
className={cn( | ||
todo.id === selectedTodoId && 'has-background-info-light', | ||
)} | ||
key={todo.id} | ||
> | ||
<td className="is-vcentered">{todo.id}</td> | ||
<td className="is-vcentered"> | ||
{todo.completed && ( | ||
<span className="icon" data-cy="iconCompleted"> | ||
<i className="fas fa-check" /> | ||
</span> | ||
)} | ||
</td> | ||
<td className="is-vcentered is-expanded"> | ||
<p | ||
className={ | ||
todo.completed ? 'has-text-success' : 'has-text-danger' | ||
} | ||
> | ||
{todo.title} | ||
</p> | ||
</td> | ||
<td className="has-text-right is-vcentered"> | ||
<button | ||
data-cy="selectButton" | ||
className="button" | ||
type="button" | ||
onClick={() => selectTodoId(todo.id)} | ||
> | ||
<span className="icon"> | ||
<i | ||
className={cn( | ||
'far', | ||
todo.id === selectedTodoId ? 'fa-eye-slash' : 'fa-eye', | ||
)} | ||
/> | ||
</span> | ||
</button> | ||
</td> | ||
</tr> | ||
)) | ||
)} | ||
</tbody> | ||
</table> | ||
); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can show these options using
.map()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good idea, but I don't know how to use map to the enum object Filters: enum Filters {
All = 'all',
Active = 'active',
Completed = 'completed',
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
Object.values/key/entries
to convert enum into an array