feat: add basic functionality
This commit is contained in:
parent
e0f0cca337
commit
30e4e40301
@ -1,2 +1,53 @@
|
||||
<h1>Welcome to SvelteKit</h1>
|
||||
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import type { WorkoutEntry } from "$lib/types";
|
||||
import { getWorkouts, saveWorkouts } from "$lib/storage";
|
||||
|
||||
let workouts: WorkoutEntry[] = [];
|
||||
|
||||
let date = "";
|
||||
let workout_type = "";
|
||||
let duration_hours = 0;
|
||||
|
||||
onMount(() => {
|
||||
const today = new Date();
|
||||
date = today.toISOString().split("T")[0];
|
||||
workouts = getWorkouts();
|
||||
});
|
||||
|
||||
function on_save() {
|
||||
const workout: WorkoutEntry = {
|
||||
date: date,
|
||||
workout_type: workout_type,
|
||||
duration_hours: duration_hours,
|
||||
};
|
||||
|
||||
workouts = [...workouts, workout];
|
||||
|
||||
saveWorkouts(workouts);
|
||||
workout_type = "";
|
||||
duration_hours = 0;
|
||||
}
|
||||
</script>
|
||||
|
||||
<h1>FitLog</h1>
|
||||
|
||||
<input type="date" bind:value={date} placeholder="Enter date" />
|
||||
<input type="text" bind:value={workout_type} placeholder="Enter workout type" />
|
||||
<input
|
||||
type="number"
|
||||
bind:value={duration_hours}
|
||||
placeholder="Enter duration in Hours"
|
||||
/>
|
||||
|
||||
<button on:click={on_save}>Save</button>
|
||||
|
||||
{#if workouts.length}
|
||||
<ul>
|
||||
{#each workouts as workout}
|
||||
<li>
|
||||
{workout.date} - {workout.workout_type} - {workout.duration_hours}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
Loading…
x
Reference in New Issue
Block a user