-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAcceptOfferModal.tsx
More file actions
196 lines (177 loc) · 5.53 KB
/
AcceptOfferModal.tsx
File metadata and controls
196 lines (177 loc) · 5.53 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import { FC, Fragment } from "react"
import { Dialog, Transition } from "@headlessui/react"
import styled from "styled-components"
import { useUser } from "@components/user/UserProvider"
import beastTemplates from "data/beastTemplates"
const ContainerDiv = styled.div`
align-items: center;
text-align: center;
z-index: 20;
`
const DialogPanel = styled<any>(Dialog.Panel)`
background: #111823;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
min-height: 30vh;
height: auto;
padding: 40px;
text-align: center;
`
const Container = styled.div`
// overflow: hidden;
display: flex;
flex-direction: column;
gap: 15px;
height: auto;
`
const Button = styled.button`
margin-top: 10px;
font-size: 1.5em;
width: 100%;
color: white;
border: 1px solid;
border-radius: 5px;
font-weight: 900;
&:hover {
color: #f3cb23;
}
&:disabled {
background: gray;
color: #fff;
opacity: 0.35;
}
`
const Title = styled.h1`
font-size: 2em;
margin-bottom: 0px;
line-height: 1em;
text-align: left;
color: #fff;
border-bottom: 2px solid #2e3340;
display: table;
clear: both;
`
const Text = styled.h3`
font-size: 1.2em;
margin-bottom: 0px;
line-height: 1em;
text-align: left;
color: #fff;
border-bottom: 2px solid #2e3340;
padding-bottom: 10px;
display: table;
clear: both;
`
const Img = styled.img`
user-drag: none;
-webkit-user-drag: none;
border-radius: 10px;
`
function classNames(...classes: any) {
return classes.filter(Boolean).join(" ")
}
type Props = {
open: boolean
setOpen: any
beast: any
offer: any
}
const AcceptOfferModal: FC<Props> = ({ open, setOpen, beast, offer }) => {
const { acceptOffer } = useUser()
return (
<Transition.Root show={open} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={setOpen}>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-75 transition-opacity" />
</Transition.Child>
<div className="fixed z-10 inset-0 overflow-y-auto">
<ContainerDiv className="flex items-end sm:items-center justify-center min-h-full p-4 text-center sm:p-0">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
enterTo="opacity-100 translate-y-0 sm:scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
>
<DialogPanel
style={{
borderRadius: "20px",
}}
className="relative rounded-lg text-left transform transition-all sm:my-8 sm:max-w-md w-full md:max-w-md"
>
<Container>
<Img
src={
"https://basicbeasts.mypinata.cloud/ipfs/" +
beastTemplates[
beast?.beastTemplateID as keyof typeof beastTemplates
]?.thumbnail
}
/>
<Title>
{beast?.name} Serial#{beast?.serialNumber}
</Title>
{beast?.name != beast?.nickname && (
<Title>{beast?.nickname}</Title>
)}
<Text>
<span style={{ float: "left" }}>Subtotal:</span>{" "}
<span style={{ float: "right" }}>
${parseFloat(offer?.offerAmount)} FUSD
</span>
</Text>
<Text>
<span style={{ float: "left" }}>Creator royalty:</span>{" "}
<span style={{ float: "right" }}>5%</span>
</Text>
<Text>
<span style={{ float: "left" }}>First owner royalty:</span>{" "}
<span style={{ float: "right" }}>5%</span>
</Text>
<Title style={{ border: "none" }}>
<span style={{ float: "left" }}>Total received:</span>{" "}
<span style={{ float: "right" }}>
${parseFloat(offer?.offerAmount) * 0.9} FUSD
</span>
</Title>
<div
className="text-right absolute top-0 left-0 right-3 sm:hidden"
onClick={() => setOpen(false)}
>
<div style={{ fontSize: "2em", color: "white" }}>x</div>
</div>
<div>
<Button
onClick={() => {
acceptOffer(offer?.offeror, offer?.offerID, beast?.id)
setOpen(false)
}}
>
Accept offer
</Button>
{beast?.id != offer?.beastID && (
<div>Something is wrong</div>
)}
</div>
</Container>
</DialogPanel>
</Transition.Child>
</ContainerDiv>
</div>
</Dialog>
</Transition.Root>
)
}
export default AcceptOfferModal