diff --git a/src/lib/db/utils.js b/src/lib/db/utils.js
index 47a33a5..de5ddb4 100644
--- a/src/lib/db/utils.js
+++ b/src/lib/db/utils.js
@@ -1,5 +1,4 @@
-import { db } from '$lib/db/db';
-
+import { db } from '$lib/db/db.js';
/**
* Return of functions that change change DB, either 'success' or 'failure' with explanation
* @typedef {Object} ChangeDBResult
@@ -58,10 +57,10 @@ export const delUserFromDB = (email) => {
* @param {string} content
* @returns {ChangeDBResult} return
*/
-export const addPosterToDB = (image, template, name = "", content) => {
- console.log(`You passed this paramas:\n image: ${image}\n template: ${template}\n name: ${name}\n content: ${content}`);
+export const addPosterToDB = (image, template, name, content) => {
const id = crypto.randomUUID(); // Create random ID for Poster
+ console.log("New id is: ", id);
if (!image || !template || !content) { // Return error if mandatory info is missing
return {
@@ -85,6 +84,5 @@ export const addPosterToDB = (image, template, name = "", content) => {
export const getAllPostersFromDB = () => {
const getPosters = db.prepare(`SELECT * FROM Posters;`);
const result = getPosters.all();
- console.log("resultado en utils", result);
return result;
}
diff --git a/src/lib/form/Form.svelte b/src/lib/form/Form.svelte
index 3030579..6b1906b 100644
--- a/src/lib/form/Form.svelte
+++ b/src/lib/form/Form.svelte
@@ -32,6 +32,40 @@
$content = editor.firstChild.innerHTML;
}
};
+ const saveCanvas = async () => {
+ if ($canvas !== undefined) {
+ const img = await html2canvas($canvas, { scale: 2 });
+ const image = img.toDataURL('image/png');
+ const data = new FormData();
+ data.set('image', image);
+ data.set('name', 'test');
+ data.set('template', 'verde');
+ data.set(
+ 'content',
+ JSON.stringify({
+ title: $title,
+ heading: $heading,
+ subtitle: $subtitle,
+ content: $content,
+ date: $date,
+ time: $time,
+ weekday: $weekday,
+ address: $address,
+ city: $city
+ })
+ );
+ console.log(data.get('image'));
+
+ // const req = await fetch('/admin', {
+ // method: 'POST',
+ // headers: {
+ // 'content-type': 'multipart/form-data',
+ // accept: 'application/json'
+ // },
+ // body: data
+ // });
+ }
+ };
const downloadCanvas = async () => {
if ($canvas !== undefined) {
@@ -131,6 +165,7 @@
+