-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.js
152 lines (127 loc) · 3.64 KB
/
Main.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
import "./App.css";
import { useState, useEffect } from "react";
import Button from 'react-bootstrap/Button';
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
import TextExample from './Card.js';
import Card from 'react-bootstrap/Card';
import GooglePayButton from '@google-pay/button-react';
import { FileUploader } from "react-drag-drop-files";
import Image from './bg.png'; // Import using relative path
import {
ref,
uploadBytes,
getDownloadURL,
listAll,
list,
} from "firebase/storage";
import {storage } from "./firebase";
import { v4 } from "uuid";
import {
MDBCard,
MDBCardBody,
MDBCardTitle,
MDBCardText,
MDBCardImage,
MDBBtn
} from 'mdb-react-ui-kit';
function Main() {
const [imageUpload, setImageUpload] = useState(null);
const [imageUrls, setImageUrls] = useState([]);
const [imageName, setImageName] = useState([]);
const imagesListRef = ref(storage, "images/");
const [deleteStatus, setDeleteStatus] = useState('idle');
const uploadFile = () => {
if (imageUpload == null) return;
const imageRef = ref(storage, `images/${imageUpload.name + v4()}`);
uploadBytes(imageRef, imageUpload).then((snapshot) => {
getDownloadURL(snapshot.ref).then((url) => {
setImageUrls((prev) => [...prev, url]);
});
});
};
useEffect(() => {
listAll(imagesListRef).then((response) => {
response.items.forEach((item) => {
getDownloadURL(item).then((url) => {
setImageUrls((prev) => [...prev, url]);
setImageName((arr) => [...arr, item.name]);
});
});
});
}, []);
return (
<div style={{ backgroundImage: `url(${Image})` }} id="cols">
<input id="ip" class="custom-file-input"
type="file"
onChange={(event) => {
setImageUpload(event.target.files[0]);
}}
/>
<button id="ip" class="btn btn-warning" onClick={uploadFile}> Upload Image </button>
<center>
{imageUrls.map((url) =>
<div>
<Card id="Tex" style={{ width: '750px',display:'flex' }}>
<Card.Body>
<Card.Title>
<Card.Link target="blank" href={url}>
<button id="free" type="button" class="btn btn-success">
Free Download
</button></Card.Link>
<div>
</div>
<center class="iframe-loading">
<iframe src={url} loading="lazy" width="500px" height="500px"
onload="$('.iframe-loading').css('background-image', 'none');">
</iframe>
</center>
</Card.Title>
<Card.Text>
Enjoy Downloading with both free and payable versions !!!
</Card.Text>
<GooglePayButton
environment="TEST"
paymentRequest={{
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods: [
{
type: 'CARD',
parameters: {
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
allowedCardNetworks: ['MASTERCARD', 'VISA'],
},
tokenizationSpecification: {
type: 'PAYMENT_GATEWAY',
parameters: {
gateway: 'example',
gatewayMerchantId: 'exampleGatewayMerchantId',
},
},
},
],
merchantInfo: {
merchantId: '12345678901234567890',
merchantName: 'Demo Merchant',
},
transactionInfo: {
totalPriceStatus: 'FINAL',
totalPriceLabel: 'Total',
totalPrice: '100.00',
currencyCode: 'USD',
countryCode: 'US',
},
}}
onLoadPaymentData={paymentRequest => {
console.log('load payment data', paymentRequest);
}}
/>
</Card.Body>
</Card>
</div>
)}
</center>
</div>
);
}
export default Main;