Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
classwork-51
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Нұрасыл Қайратұлы
classwork-51
Commits
0a013cfe
Commit
0a013cfe
authored
Nov 28, 2024
by
Нұрасыл Қайратұлы
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add lesson-52
parent
0c2d6e53
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
List.tsx
src/components/List/List.tsx
+3
-2
App.tsx
src/containers/App.tsx
+10
-2
No files found.
src/components/List/List.tsx
View file @
0a013cfe
...
...
@@ -3,9 +3,10 @@ import './List.scss'
type
TProps
=
{
list
:
string
[]
title
:
string
onDelete
?:
(
item
:
string
)
=>
void
}
const
List
=
({
list
,
title
}:
TProps
)
=>
{
const
List
=
({
list
,
title
,
onDelete
}:
TProps
)
=>
{
return
(
<
div
className=
'List'
>
<
h2
>
{
title
}
</
h2
>
...
...
@@ -13,7 +14,7 @@ const List = ({list, title}: TProps) => {
<
div
>
{
list
.
map
((
item
,
index
)
=>
(
<
p
key=
{
index
}
>
<
p
key=
{
index
}
onClick=
{
()
=>
onDelete
&&
onDelete
(
item
)
}
>
{
item
}
</
p
>
))
...
...
src/containers/App.tsx
View file @
0a013cfe
...
...
@@ -30,7 +30,7 @@ function App() {
}
const
onClickHandler
=
()
=>
{
const
copyGuestList
=
guestList
const
copyGuestList
=
[...
guestList
]
const
randomList
=
copyGuestList
.
filter
(
item
=>
{
const
random
=
Math
.
floor
(
Math
.
random
()
*
100
)
if
(
random
>
50
)
return
item
...
...
@@ -39,6 +39,13 @@ function App() {
setIncomeList
(
randomList
)
}
const
onDeleteHandler
=
(
item
:
string
)
=>
{
const
index
=
guestList
.
findIndex
(
str
=>
str
===
item
)
const
copyGuestList
=
[...
guestList
]
copyGuestList
.
splice
(
index
,
1
)
setGuestList
(
copyGuestList
)
}
return
(
<
div
className=
"App"
>
<
Modal
show=
{
isModal
}
/>
...
...
@@ -46,10 +53,11 @@ function App() {
<
List
title=
"Список основных гостей"
list=
{
guestList
.
reverse
()
}
onDelete=
{
onDeleteHandler
}
/>
<
List
title=
"Список приглашенных гостей"
list=
{
inComeList
}
list=
{
inComeList
}
/>
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment