Update AdventureCard component to remove commented out code and add exportData function to log page
This commit is contained in:
@@ -128,7 +128,7 @@
|
||||
<h2 class="card-title overflow-ellipsis">{name}</h2>
|
||||
<p>{regionId}</p>
|
||||
<div class="card-actions justify-end">
|
||||
<button class="btn btn-info" on:click={moreInfo}>More Info</button>
|
||||
<!-- <button class="btn btn-info" on:click={moreInfo}>More Info</button> -->
|
||||
{#if !visited}
|
||||
<button class="btn btn-primary" on:click={markVisited}
|
||||
>Mark Visited</button
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import AdventureCard from "$lib/components/AdventureCard.svelte";
|
||||
import type { Adventure } from "$lib/utils/types";
|
||||
import { onMount } from "svelte";
|
||||
import { exportData } from "../../services/export";
|
||||
import exportFile from "$lib/assets/exportFile.svg";
|
||||
import deleteIcon from "$lib/assets/deleteIcon.svg";
|
||||
import SucessToast from "$lib/components/SucessToast.svelte";
|
||||
@@ -48,6 +47,18 @@
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function exportData() {
|
||||
let jsonString = JSON.stringify(adventures);
|
||||
let blob = new Blob([jsonString], { type: "application/json" });
|
||||
let url = URL.createObjectURL(blob);
|
||||
|
||||
let link = document.createElement("a");
|
||||
link.download = "data.json";
|
||||
link.href = url;
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
const createNewAdventure = () => {
|
||||
let currentDate = new Date();
|
||||
let dateString = currentDate.toISOString().slice(0, 10); // Get date in "yyyy-mm-dd" format
|
||||
@@ -290,12 +301,7 @@
|
||||
<div
|
||||
class="flex flex-row items-center justify-center mt-2 gap-4 mb-4 flex-wrap"
|
||||
>
|
||||
<button
|
||||
class="btn btn-neutral"
|
||||
on:click={async () => {
|
||||
window.location.href = exportData();
|
||||
}}
|
||||
>
|
||||
<button class="btn btn-neutral" on:click={exportData}>
|
||||
<img src={exportFile} class="inline-block -mt-1" alt="Logo" /> Save as File
|
||||
</button>
|
||||
<button class="btn btn-neutral" on:click={deleteData}>
|
||||
|
||||
Reference in New Issue
Block a user