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
0c2d6e53
Commit
0c2d6e53
authored
Nov 28, 2024
by
Нұрасыл Қайратұлы
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add lesson-52
parent
fd54d3c4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
9 deletions
+80
-9
GuestForm.tsx
src/components/GuestForm/GuestForm.tsx
+9
-3
List.tsx
src/components/List/List.tsx
+3
-3
Modal.scss
src/components/Modal/Modal.scss
+14
-0
Modal.tsx
src/components/Modal/Modal.tsx
+15
-0
App.tsx
src/containers/App.tsx
+39
-3
No files found.
src/components/GuestForm/GuestForm.tsx
View file @
0c2d6e53
import
'./GuestForm.scss'
import
'./GuestForm.scss'
const
GuestForm
=
()
=>
{
type
TProps
=
{
onChange
:
(
e
:
React
.
FormEvent
<
HTMLInputElement
>
)
=>
void
onSubmit
:
(
e
:
React
.
SyntheticEvent
<
HTMLFormElement
>
)
=>
void
value
:
string
}
const
GuestForm
=
({
onChange
,
onSubmit
,
value
}:
TProps
)
=>
{
return
(
return
(
<
form
className=
'GuestForm'
>
<
form
className=
'GuestForm'
onSubmit=
{
onSubmit
}
>
<
input
/>
<
input
onChange=
{
onChange
}
value=
{
value
}
/>
</
form
>
</
form
>
)
)
}
}
...
...
src/components/List/List.tsx
View file @
0c2d6e53
...
@@ -6,14 +6,14 @@ type TProps = {
...
@@ -6,14 +6,14 @@ type TProps = {
}
}
const
List
=
({
list
,
title
}:
TProps
)
=>
{
const
List
=
({
list
,
title
}:
TProps
)
=>
{
return
(
return
(
<
div
className=
'List'
>
<
div
className=
'List'
>
<
h2
>
{
title
}
</
h2
>
<
h2
>
{
title
}
</
h2
>
<
div
>
<
div
>
{
{
list
.
map
(
item
=>
(
list
.
map
(
(
item
,
index
)
=>
(
<
p
key=
{
i
tem
}
>
<
p
key=
{
i
ndex
}
>
{
item
}
{
item
}
</
p
>
</
p
>
))
))
...
...
src/components/Modal/Modal.scss
0 → 100644
View file @
0c2d6e53
.Modal
{
position
:
fixed
;
top
:
30%
;
right
:
40%
;
width
:
200px
;
height
:
50px
;
border-radius
:
10px
;
border
:
1px
solid
blueviolet
;
background-color
:
blueviolet
;
color
:
white
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
\ No newline at end of file
src/components/Modal/Modal.tsx
0 → 100644
View file @
0c2d6e53
import
'./Modal.scss'
type
TProps
=
{
show
:
boolean
}
const
Modal
=
({
show
}:
TProps
)
=>
{
return
(
<
div
className=
'Modal'
style=
{
{
display
:
show
?
'flex'
:
'none'
}
}
>
Нужно ввести имя гостя!
</
div
>
)
}
export
default
Modal
\ No newline at end of file
src/containers/App.tsx
View file @
0c2d6e53
...
@@ -3,17 +3,49 @@ import List from "../components/List/List"
...
@@ -3,17 +3,49 @@ import List from "../components/List/List"
import
SendBtn
from
"../components/SendBtn/SendBtn"
import
SendBtn
from
"../components/SendBtn/SendBtn"
import
GuestForm
from
"../components/GuestForm/GuestForm"
import
GuestForm
from
"../components/GuestForm/GuestForm"
import
'./App.scss'
import
'./App.scss'
import
Modal
from
"../components/Modal/Modal"
function
App
()
{
function
App
()
{
const
[
guestList
,
setGuestList
]
=
useState
<
string
[]
>
([
'John'
,
'Alibek'
,
'Tramp'
,
'Jose'
,
'Aida'
])
const
[
guestList
,
setGuestList
]
=
useState
<
string
[]
>
([
'John'
,
'Alibek'
,
'Tramp'
,
'Jose'
,
'Aida'
])
const
[
inComeList
,
setIncomeList
]
=
useState
<
string
[]
>
([])
const
[
inComeList
,
setIncomeList
]
=
useState
<
string
[]
>
([])
const
[
inpVal
,
setInpVal
]
=
useState
<
string
>
(
''
)
const
[
isModal
,
setIsModal
]
=
useState
<
boolean
>
(
false
)
const
onChangeHandler
=
(
e
:
React
.
FormEvent
<
HTMLInputElement
>
)
=>
{
setInpVal
(
e
.
currentTarget
.
value
)
setIsModal
(
false
)
}
const
onSubmitHandler
=
(
e
:
React
.
SyntheticEvent
<
HTMLFormElement
>
)
=>
{
e
.
preventDefault
()
if
(
inpVal
===
''
)
{
setIsModal
(
true
)
}
else
{
setGuestList
((
prevState
)
=>
{
prevState
.
push
(
inpVal
)
return
prevState
})
}
}
const
onClickHandler
=
()
=>
{
const
copyGuestList
=
guestList
const
randomList
=
copyGuestList
.
filter
(
item
=>
{
const
random
=
Math
.
floor
(
Math
.
random
()
*
100
)
if
(
random
>
50
)
return
item
})
setIncomeList
(
randomList
)
}
return
(
return
(
<
div
className=
"App"
>
<
div
className=
"App"
>
<
Modal
show=
{
isModal
}
/>
<
div
className=
"Lists"
>
<
div
className=
"Lists"
>
<
List
<
List
title=
"Список основных гостей"
title=
"Список основных гостей"
list=
{
guestList
}
list=
{
guestList
.
reverse
()
}
/>
/>
<
List
<
List
title=
"Список приглашенных гостей"
title=
"Список приглашенных гостей"
...
@@ -22,8 +54,12 @@ function App() {
...
@@ -22,8 +54,12 @@ function App() {
</
div
>
</
div
>
<
div
className=
"Controllers"
>
<
div
className=
"Controllers"
>
<
GuestForm
/>
<
GuestForm
<
SendBtn
onClick=
{
()
=>
{}
}
/>
onChange=
{
onChangeHandler
}
onSubmit=
{
onSubmitHandler
}
value=
{
inpVal
}
/>
<
SendBtn
onClick=
{
onClickHandler
}
/>
</
div
>
</
div
>
</
div
>
</
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