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
6a947e4b
Commit
6a947e4b
authored
Dec 02, 2024
by
Нұрасыл Қайратұлы
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hrllo
parent
0a013cfe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
59 deletions
+26
-59
Imagine Dragons - Believer.mp3
public/Imagine Dragons - Believer.mp3
+0
-0
App.tsx
src/containers/App.tsx
+26
-59
No files found.
public/Imagine Dragons - Believer.mp3
0 → 100644
View file @
6a947e4b
File added
src/containers/App.tsx
View file @
6a947e4b
import
{
useState
}
from
"react"
import
{
useRef
,
useState
}
from
'react'
import
List
from
"../components/List/List"
import
SendBtn
from
"../components/SendBtn/SendBtn"
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
[
playList
,
setPlayList
]
=
useState
([
const
[
inComeList
,
setIncomeList
]
=
useState
<
string
[]
>
([])
{
name
:
'/Imagine Dragons - Believer.mp3'
,
duration
:
600
,
author
:
'Кто то'
},
const
[
inpVal
,
setInpVal
]
=
useState
<
string
>
(
''
)
{
name
:
'/Imagine Dragons - Believer.mp3'
,
duration
:
600
,
author
:
'Кто то'
},
const
[
isModal
,
setIsModal
]
=
useState
<
boolean
>
(
false
)
{
name
:
'/Imagine Dragons - Believer.mp3'
,
duration
:
600
,
author
:
'Кто то'
},
{
name
:
'/Imagine Dragons - Believer.mp3'
,
duration
:
600
,
author
:
'Кто то'
},
const
onChangeHandler
=
(
e
:
React
.
FormEvent
<
HTMLInputElement
>
)
=>
{
{
name
:
'/Imagine Dragons - Believer.mp3'
,
duration
:
600
,
author
:
'Кто то'
}
setInpVal
(
e
.
currentTarget
.
value
)
])
setIsModal
(
false
)
const
auidoRef
=
useRef
<
HTMLAudioElement
|
null
>
(
null
)
const
playHandler
=
()
=>
{
auidoRef
?.
current
?.
play
()
}
}
const
onSubmitHandler
=
(
e
:
React
.
SyntheticEvent
<
HTMLFormElement
>
)
=>
{
const
pauseHandler
=
()
=>
{
e
.
preventDefault
()
auidoRef
?.
current
?.
pause
()
if
(
inpVal
===
''
)
{
setIsModal
(
true
)
}
else
{
setGuestList
((
prevState
)
=>
{
prevState
.
push
(
inpVal
)
return
prevState
})
}
}
}
const
onClickHandler
=
()
=>
{
console
.
log
(
auidoRef
);
const
copyGuestList
=
[...
guestList
]
const
randomList
=
copyGuestList
.
filter
(
item
=>
{
const
random
=
Math
.
floor
(
Math
.
random
()
*
100
)
if
(
random
>
50
)
return
item
})
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
}
/>
<
div
className=
"Lists"
>
<
List
title=
"Список основных гостей"
list=
{
guestList
.
reverse
()
}
onDelete=
{
onDeleteHandler
}
/>
<
List
title=
"Список приглашенных гостей"
list=
{
inComeList
}
/>
</
div
>
<
div
className=
"Controllers"
>
<
div
style=
{
{
height
:
'10px'
,
width
:
'40px'
,
backgroundColor
:
'white'
}
}
>
<
GuestForm
onChange=
{
onChangeHandler
}
onSubmit=
{
onSubmitHandler
}
value=
{
inpVal
}
/>
<
SendBtn
onClick=
{
onClickHandler
}
/>
</
div
>
</
div
>
<
button
onClick=
{
playHandler
}
>
Play
</
button
>
<
button
onClick=
{
pauseHandler
}
>
Pause
</
button
>
<
audio
controls
style=
{
{
display
:
'none'
}
}
ref=
{
auidoRef
}
>
<
source
src=
{
playList
[
4
].
name
}
type=
"audio/mpeg"
/>
</
audio
>
</
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