Implement secure client-side favorites loading to fix nginx 502 issues
All checks were successful
CI / update (push) Successful in 16s
All checks were successful
CI / update (push) Successful in 16s
- Create client-side favorites store with secure authentication - Remove server-side favorites fetching that caused nginx routing issues - Update FavoriteButton to properly handle short_name/ObjectId relationship - Use existing /api/rezepte/favorites/check endpoint for status checking - Maintain security by requiring authentication for all favorites operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
<script lang="ts">
|
||||
import type { PageData } from './$types';
|
||||
import { onMount } from 'svelte';
|
||||
import { favorites, addFavoriteStatusToRecipes } from '$lib/stores/favorites';
|
||||
import { page } from '$app/stores';
|
||||
import MediaScroller from '$lib/components/MediaScroller.svelte';
|
||||
import AddButton from '$lib/components/AddButton.svelte';
|
||||
import Card from '$lib/components/Card.svelte';
|
||||
import Search from '$lib/components/Search.svelte';
|
||||
export let data: PageData;
|
||||
export let current_month = new Date().getMonth() + 1
|
||||
const categories = ["Hauptspeise", "Nudel", "Brot", "Dessert", "Suppe", "Beilage", "Salat", "Kuchen", "Frühstück", "Sauce", "Zutat", "Getränk", "Aufstrich", "Guetzli", "Snack"]
|
||||
const categories = ["Hauptspeise", "Nudel", "Brot", "Dessert", "Suppe", "Beilage", "Salat", "Kuchen", "Frühstück", "Sauce", "Zutat", "Getränk", "Aufstrich", "Guetzli", "Snack"];
|
||||
|
||||
// Load favorites when component mounts and user is authenticated
|
||||
onMount(() => {
|
||||
if ($page.data.session?.user) {
|
||||
favorites.load();
|
||||
}
|
||||
});
|
||||
|
||||
// Reactively add favorite status to recipes
|
||||
$: seasonWithFavorites = addFavoriteStatusToRecipes(data.season, $favorites.favorites);
|
||||
$: allBriefWithFavorites = addFavoriteStatusToRecipes(data.all_brief, $favorites.favorites);
|
||||
</script>
|
||||
<style>
|
||||
h1{
|
||||
@@ -35,15 +49,15 @@ h1{
|
||||
<Search></Search>
|
||||
|
||||
<MediaScroller title="In Saison">
|
||||
{#each data.season as recipe}
|
||||
<Card {recipe} {current_month} loading_strat={"eager"} do_margin_right={true} isFavorite={recipe.isFavorite} showFavoriteIndicator={!!data.session?.user}></Card>
|
||||
{#each seasonWithFavorites as recipe}
|
||||
<Card {recipe} {current_month} loading_strat={"eager"} do_margin_right={true} isFavorite={recipe.isFavorite} showFavoriteIndicator={!!$page.data.session?.user}></Card>
|
||||
{/each}
|
||||
</MediaScroller>
|
||||
|
||||
{#each categories as category}
|
||||
<MediaScroller title={category}>
|
||||
{#each data.all_brief.filter(recipe => recipe.category == category) as recipe}
|
||||
<Card {recipe} {current_month} do_margin_right={true} isFavorite={recipe.isFavorite} showFavoriteIndicator={!!data.session?.user}></Card>
|
||||
{#each allBriefWithFavorites.filter(recipe => recipe.category == category) as recipe}
|
||||
<Card {recipe} {current_month} do_margin_right={true} isFavorite={recipe.isFavorite} showFavoriteIndicator={!!$page.data.session?.user}></Card>
|
||||
{/each}
|
||||
</MediaScroller>
|
||||
{/each}
|
||||
|
||||
Reference in New Issue
Block a user