-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
68 lines (59 loc) · 1.55 KB
/
index.tsx
File metadata and controls
68 lines (59 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type { NextPage } from 'next'
import styled from 'styled-components'
import Options from 'components/Options'
import Buttons from 'components/Buttons'
import Header from 'components/Header'
import { DragDropContext, DropResult } from 'react-beautiful-dnd'
import { useAppDispatch } from 'redux/store'
import { dragAndDrop } from 'redux/slice'
const Home: NextPage = () => {
const dispatch = useAppDispatch()
const handleDragEnd = (result: DropResult) => {
if (!result.destination) {
return
}
const draggingItemIndex = result.source.index
const dropItemIndex = result.destination.index
dispatch(
dragAndDrop({
items: result.source.droppableId as 'available' | 'selected',
from: {
type: result.source.droppableId as 'available' | 'selected',
index: draggingItemIndex,
},
to: {
type: result.destination.droppableId as 'available' | 'selected',
index: dropItemIndex,
},
})
)
}
return (
<DragDropContext onDragEnd={handleDragEnd}>
<Header />
<Wrapper>
<Main>
<Options type={'available'} />
<Buttons />
<Options type={'selected'} />
</Main>
</Wrapper>
</DragDropContext>
)
}
const Wrapper = styled.div`
width: 100vw;
display: flex;
justify-content: center;
`
const Main = styled.main`
display: flex;
justify-content: center;
min-width: 120rem;
max-width: 120rem;
height: 100%;
/* min-height: 100vh; */
margin: 0;
position: relative;
`
export default Home