mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 13:15:18 +02:00
Added new trip plan creator and removed visit count stores
This commit is contained in:
parent
01865951ac
commit
7565279e61
3 changed files with 28 additions and 7 deletions
|
@ -85,7 +85,7 @@
|
||||||
<div>
|
<div>
|
||||||
<label for="date">End Date</label>
|
<label for="date">End Date</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="date"
|
||||||
id="endDate"
|
id="endDate"
|
||||||
bind:value={newTrip.endDate}
|
bind:value={newTrip.endDate}
|
||||||
class="input input-bordered w-full max-w-xs"
|
class="input input-bordered w-full max-w-xs"
|
||||||
|
|
|
@ -49,7 +49,7 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
tirp: body.newTrip,
|
trip: body.newTrip,
|
||||||
message: { message: "Trip added" },
|
message: { message: "Trip added" },
|
||||||
id: insertedId,
|
id: insertedId,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -18,14 +18,15 @@
|
||||||
let adventuresPlans: Adventure[] = [];
|
let adventuresPlans: Adventure[] = [];
|
||||||
let tripPlans: Trip[] = [];
|
let tripPlans: Trip[] = [];
|
||||||
|
|
||||||
let isLoading = true;
|
let isLoadingIdeas: boolean = true;
|
||||||
|
let isLoadingTrips: boolean = true;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
getAllTrips();
|
||||||
console.log(tripPlans);
|
console.log(tripPlans);
|
||||||
adventuresPlans = data.result;
|
adventuresPlans = data.result;
|
||||||
isLoading = false;
|
isLoadingIdeas = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
let isShowingMoreFields: boolean = false;
|
let isShowingMoreFields: boolean = false;
|
||||||
|
@ -127,12 +128,32 @@
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log("Success:", data);
|
console.log("Success:", data);
|
||||||
|
newTrip = data.trip;
|
||||||
|
console.log(newTrip);
|
||||||
tripPlans = [...tripPlans, newTrip];
|
tripPlans = [...tripPlans, newTrip];
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getAllTrips() {
|
||||||
|
const response = await fetch("/api/trips", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data) => {
|
||||||
|
console.log("Success:", data);
|
||||||
|
tripPlans = data;
|
||||||
|
isLoadingTrips = false;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
showToast("Failed to get trips");
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isShowingToast}
|
{#if isShowingToast}
|
||||||
|
@ -172,7 +193,7 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if isLoading}
|
{#if isLoadingIdeas && isLoadingTrips}
|
||||||
<div class="flex justify-center items-center w-full mt-16">
|
<div class="flex justify-center items-center w-full mt-16">
|
||||||
<span class="loading loading-spinner w-24 h-24"></span>
|
<span class="loading loading-spinner w-24 h-24"></span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -192,7 +213,7 @@
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if adventuresPlans.length == 0 && !isLoading}
|
{#if adventuresPlans.length == 0 && !isLoadingIdeas}
|
||||||
<div class="flex flex-col items-center justify-center mt-16">
|
<div class="flex flex-col items-center justify-center mt-16">
|
||||||
<article class="prose mb-4"><h2>Add some plans!</h2></article>
|
<article class="prose mb-4"><h2>Add some plans!</h2></article>
|
||||||
<img src={mapDrawing} width="25%" alt="Logo" />
|
<img src={mapDrawing} width="25%" alt="Logo" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue