1
- import { useState } from 'react' ;
1
+ /* This example requires Tailwind CSS v2.0+ */
2
+ import { Fragment , useRef , useState } from 'react'
3
+ import { Dialog , Transition } from '@headlessui/react'
4
+ // import {useState} from 'react';
2
5
3
6
const verify_vote_option = ( vote_option ) => {
4
7
if ( vote_option === "Yes" || vote_option === "No" ) {
@@ -8,26 +11,79 @@ const verify_vote_option = (vote_option) => {
8
11
}
9
12
}
10
13
11
- // SCAFFOLDING FOR VOTE MODAL NOT COMPLETE
12
- function VoteModal ( proposal ) {
13
- // const { proposal } = props.proposal;
14
- return (
15
- < div className = 'bg-green3' >
16
- < div className = "flex flex-col w-full m-3 bg-black bg-opacity-60 text-white rounded-lg" >
17
- { /* <p></p>{proposal.title} */ }
18
- { proposal . votes . map ( vote => {
19
- return (
20
- < div className = "flex flex-row" >
21
- < input type = "checkbox" name = { vote . name } value = "Yes" />
22
- < label > Yes</ label >
23
- < p > Current # { vote . count } </ p >
24
- </ div > ) } ) }
25
-
26
- < div >
27
- < button className = 'cast-vote' > Cast Vote</ button >
28
-
29
- </ div >
14
+
15
+
16
+ function VoteModal ( props ) {
17
+
18
+ const [ vote_option , setVoteOption ] = useState ( null ) ;
19
+
20
+
21
+ const cancelButtonRef = useRef ( null )
22
+
23
+ return (
24
+ < Transition . Root show = { props . open } as = { Fragment } >
25
+ < Dialog as = "div" className = "fixed z-10 inset-0 overflow-y-auto" onClose = { props . setOpen } >
26
+ < div className = "flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0" >
27
+ < Transition . Child
28
+ as = { Fragment }
29
+ enter = "ease-out duration-300"
30
+ enterFrom = "opacity-0"
31
+ enterTo = "opacity-100"
32
+ leave = "ease-in duration-200"
33
+ leaveFrom = "opacity-100"
34
+ leaveTo = "opacity-0"
35
+ >
36
+ < Dialog . Overlay className = "fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
37
+ </ Transition . Child >
38
+
39
+ { /* This element is to trick the browser into centering the modal contents. */ }
40
+ < span className = "hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden = "true" >
41
+ ​
42
+ </ span >
43
+ < Transition . Child
44
+ as = { Fragment }
45
+ enter = "ease-out duration-300"
46
+ enterFrom = "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
47
+ enterTo = "opacity-100 translate-y-0 sm:scale-100"
48
+ leave = "ease-in duration-200"
49
+ leaveFrom = "opacity-100 translate-y-0 sm:scale-100"
50
+ leaveTo = "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
51
+ >
52
+ < div className = "relative inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full" >
53
+ < div className = "bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4" >
54
+ < div className = "flex flex-col" >
55
+ < div className = 'flex flex-row' >
56
+ < p > Vote on # </ p >
57
+ < p > { toString ( props . proposal . id ) } </ p >
58
+ </ div >
59
+ < p > { props . proposal . name } </ p >
60
+ { props . proposal ?? "No proposal??" }
61
+ { props . proposal . weighted ? "Weighted" : "Unweighted" }
30
62
</ div >
31
- </ div > ) ;
63
+ </ div >
64
+ < div className = 'flex flex-row' >
65
+ < button
66
+ type = "button"
67
+ className = "w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:ml-3 sm:w-auto sm:text-sm"
68
+ onClick = { ( ) => props . setOpen ( false ) }
69
+ >
70
+ Approve
71
+ </ button >
72
+ < button
73
+ type = "button"
74
+ className = "rounded-md px-4 py-2 bg-green1 font-bold text-white hover:bg-transparent hover:bg-opacity-0 hover:outline-4 hover:outline-green1 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:ml-3 sm:w-auto sm:text-sm"
75
+ onClick = { ( ) => props . setOpen ( false ) }
76
+ ref = { cancelButtonRef }
77
+ >
78
+ Deny
79
+ </ button >
80
+ </ div >
81
+ </ div >
82
+ </ Transition . Child >
83
+ </ div >
84
+ </ Dialog >
85
+ </ Transition . Root >
86
+ )
32
87
}
88
+
33
89
export default VoteModal ;
0 commit comments