createqr
This commit is contained in:
49
src/services/CreateQr.ts
Normal file
49
src/services/CreateQr.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { Axios } from '../context/UserContext';
|
||||
|
||||
import React from 'react'
|
||||
import QRCodeStyling from 'qr-code-styling';
|
||||
|
||||
|
||||
const upload = (file: File): Promise<any> =>
|
||||
{
|
||||
let formData = new FormData();
|
||||
|
||||
formData.append("file", file);
|
||||
formData.append("submit", "1");
|
||||
formData.append("qr", "1");
|
||||
|
||||
let uploadRes = Axios.post("upload.php", formData, {
|
||||
headers:
|
||||
{
|
||||
"Content-Type": "multipart/form-data",
|
||||
}
|
||||
});
|
||||
|
||||
// let a: number = 1+3;
|
||||
// a++;
|
||||
return uploadRes;
|
||||
};
|
||||
|
||||
export default function CreateQr({qr_id}:{qr_id: string | undefined})
|
||||
{
|
||||
const qrCode = new QRCodeStyling(
|
||||
{
|
||||
width: 200,
|
||||
height: 200,
|
||||
image:
|
||||
"",
|
||||
data: 'https://hope-fly.de/dog/'+ qr_id,
|
||||
dotsOptions:
|
||||
{
|
||||
color: "#000",
|
||||
type: "square"
|
||||
},
|
||||
imageOptions:
|
||||
{
|
||||
crossOrigin: "anonymous",
|
||||
margin: 0
|
||||
}
|
||||
});
|
||||
// upload(qrCode._svg as File);
|
||||
console.log(qrCode);
|
||||
}
|
||||
Reference in New Issue
Block a user