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
Show 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'
...
@@ -3,9 +3,10 @@ import './List.scss'
type
TProps
=
{
type
TProps
=
{
list
:
string
[]
list
:
string
[]
title
:
string
title
:
string
onDelete
?:
(
item
:
string
)
=>
void
}
}
const
List
=
({
list
,
title
}:
TProps
)
=>
{
const
List
=
({
list
,
title
,
onDelete
}:
TProps
)
=>
{
return
(
return
(
<
div
className=
'List'
>
<
div
className=
'List'
>
<
h2
>
{
title
}
</
h2
>
<
h2
>
{
title
}
</
h2
>
...
@@ -13,7 +14,7 @@ const List = ({list, title}: TProps) => {
...
@@ -13,7 +14,7 @@ const List = ({list, title}: TProps) => {
<
div
>
<
div
>
{
{
list
.
map
((
item
,
index
)
=>
(
list
.
map
((
item
,
index
)
=>
(
<
p
key=
{
index
}
>
<
p
key=
{
index
}
onClick=
{
()
=>
onDelete
&&
onDelete
(
item
)
}
>
{
item
}
{
item
}
</
p
>
</
p
>
))
))
...
...
src/containers/App.tsx
View file @
0a013cfe
...
@@ -30,7 +30,7 @@ function App() {
...
@@ -30,7 +30,7 @@ function App() {
}
}
const
onClickHandler
=
()
=>
{
const
onClickHandler
=
()
=>
{
const
copyGuestList
=
guestList
const
copyGuestList
=
[...
guestList
]
const
randomList
=
copyGuestList
.
filter
(
item
=>
{
const
randomList
=
copyGuestList
.
filter
(
item
=>
{
const
random
=
Math
.
floor
(
Math
.
random
()
*
100
)
const
random
=
Math
.
floor
(
Math
.
random
()
*
100
)
if
(
random
>
50
)
return
item
if
(
random
>
50
)
return
item
...
@@ -39,6 +39,13 @@ function App() {
...
@@ -39,6 +39,13 @@ function App() {
setIncomeList
(
randomList
)
setIncomeList
(
randomList
)
}
}
const
onDeleteHandler
=
(
item
:
string
)
=>
{
const
index
=
guestList
.
findIndex
(
str
=>
str
===
item
)
const
copyGuestList
=
[...
guestList
]
copyGuestList
.
splice
(
index
,
1
)
setGuestList
(
copyGuestList
)
}
return
(
return
(
<
div
className=
"App"
>
<
div
className=
"App"
>
<
Modal
show=
{
isModal
}
/>
<
Modal
show=
{
isModal
}
/>
...
@@ -46,6 +53,7 @@ function App() {
...
@@ -46,6 +53,7 @@ function App() {
<
List
<
List
title=
"Список основных гостей"
title=
"Список основных гостей"
list=
{
guestList
.
reverse
()
}
list=
{
guestList
.
reverse
()
}
onDelete=
{
onDeleteHandler
}
/>
/>
<
List
<
List
title=
"Список приглашенных гостей"
title=
"Список приглашенных гостей"
...
...
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