-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDarujme.js
157 lines (135 loc) · 4.55 KB
/
Darujme.js
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
import {useState} from "react";
const Darujme = ({projectId, currency}) => {
const [amount, setAmount] = useState(1);
const [frequency, setFrequency] = useState("once");
const submitForm = () => {
const url = `https://www.darujme.cz/darovat/${projectId}/?amount=${amount}¤cy=${currency}&frequency=${frequency}`;
// window.location.replace(url);
window.open(url, '_blank').focus();
}
return <>
<div style={WidgetStyle}>
<div style={WidgetHeadStyle}>
<div style={WidgetHeadTitleStyle}>
Pomozte nám pomáhat!
</div>
</div>
<div style={WidgetBodyStyle}>
<div style={FrequencyStyle}>
<div style={frequency === "once" ? FrequencyButtonActiveStyle : FrequencyButtonStyle}
onClick={() => setFrequency("once")}>
Jednorázově
</div>
<div style={frequency === "monthly" ? FrequencyButtonActiveStyle : FrequencyButtonStyle}
onClick={() => setFrequency("monthly")}>
Měsíčně
</div>
</div>
<div style={AmountBlockStyle}>
<input type="number" min="1" value={amount} onChange={(e) => setAmount(e.target.value)}/>
<div style={WidgetEntriesStyle}>
<WidgetEntryItem amount={100} currency={currency} set={(a) => setAmount(a)}/>
<WidgetEntryItem amount={300} currency={currency} set={(a) => setAmount(a)}/>
<WidgetEntryItem amount={500} currency={currency} set={(a) => setAmount(a)}/>
<WidgetEntryItem amount={1000} currency={currency} set={(a) => setAmount(a)}/>
<WidgetEntryItem amount={2000} currency={currency} set={(a) => setAmount(a)}/>
</div>
</div>
<button style={SubmitButtonStyle}
onClick={submitForm}>Daruj {amount} {prettyCurrency(currency)}</button>
<div>
zabezpečeno Darujme.cz
</div>
</div>
</div>
</>;
};
const WidgetEntryItem = ({amount, currency, set}) => {
return (<div style={WidgetEntryStyle}
onClick={() => set(amount)}>
{amount} {prettyCurrency(currency)}
</div>);
}
const prettyCurrency = (currency) => {
if (currency === "CZK") {
return "Kč";
}
return currency;
}
const WidgetStyle = {
fontSize: '14px',
textAlign: 'center',
color: '#0b3369',
background: '#fff',
width: '270px',
maxWidth: '100%',
overflow: 'hidden',
border: '1px solid rgb(220, 220, 220)',
boxShadow: 'rgba(0, 0, 0, 0.09) 0px 2px 18px 0px',
height: '324px',
}
const WidgetHeadStyle = {
padding: '10px 10px', background: '#f5f5f5', borderBottom: 'solid 2px #dcdcdc',
}
const WidgetHeadTitleStyle = {
margin: '0.7em 0 0 0', fontSize: '14px', fontWeight: '700',
}
const WidgetBodyStyle = {
padding: '10px 10px',
}
const FrequencyStyle = {
marginBottom: '10px', position: 'relative',
display: 'flex',
justifyContent: 'center',
}
const FrequencyButtonStyle = {
fontSize: '14px',
position: 'relative',
padding: '10px 5px 9px 5px',
marginLeft: '5px',
marginRight: '5px',
cursor: 'pointer',
textAlign: 'center',
letterSpacing: '0.3px',
lineHeight: '1.2',
fontWeight: '700',
color: '#7c7c7c',
border: '1px solid #cacaca',
borderRadius: '3px',
zIndex: '3',
float: 'left',
}
const FrequencyButtonActiveStyle = {
...FrequencyButtonStyle, zIndex: '2', color: '#347ddf', borderColor: '#347ddf',
}
const AmountBlockStyle = {
fontSize: '100%', verticalAlign: 'baseline',
}
const WidgetEntriesStyle = {
paddingTop: '10px',
zoom: '1', position: 'relative', margin: '0 -3px',
}
const WidgetEntryStyle = {
float: 'left', padding: '3px', width: '30%', whiteSpace: 'nowrap',
border: '1px solid #dcdcdc', cursor: 'pointer',
margin: '1%',
borderRadius: '5px',
}
const SubmitButtonStyle = {
fontSize: '14px',
position: 'relative',
padding: '10px 5px 9px 5px',
cursor: 'pointer',
textAlign: 'center',
letterSpacing: '0.3px',
lineHeight: '1.2',
fontWeight: '700',
color: '#000',
border: '1px solid #347ddf',
borderRadius: '6px',
margin: '12px 0',
width: '100%',
background: '#347ddf',
overflow: 'hidden',
}
export default Darujme;