Skip to content

Commit

Permalink
Better error handling for 404 error in PlanView (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
SachsenspieltCoding authored May 24, 2023
1 parent 611d650 commit b1f7134
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/lib/api/stundenplan42/class/SchoolPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Class, { fromJson as classParser } from './Class';

export default class SchoolPlan {
schoolnumber: string;
created: Date;
created: Date | undefined;
date: Date;
week: number;
holidays: Date[] = [];
Expand Down
39 changes: 22 additions & 17 deletions src/routes/plan/[short]/[[date]]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
planData = await _fetchPlanData(data.short, force, $date);
} catch (e) {
planData.schedule = [];
planData.schoolPlan.info = [];
planData.schoolPlan.created = undefined;
}
isRefreshing = false;
}
Expand Down Expand Up @@ -69,26 +71,29 @@
</button>
</div>

<div class="flex h-screen max-h-screen flex-col gap-4 pb-10 pt-20">
<div class="flex h-screen max-h-screen flex-col gap-3 pb-10 pt-20">
<h1 class="text-center">{planData.type} <span class="text-accent">{data.short}</span></h1>
<div class="flex items-center justify-between px-8">
<PlanSwitchArrow holidays={planData.schoolPlan.holidays} />
<div class="text-center leading-tight cursor-pointer" on:keypress={() => undefined} on:click={resetDate}>
<p class="text-sm">{format(new Date($date), 'EEEE', { locale: de })}</p>
<p class="text-md">
{new Date($date).toLocaleDateString()}
</p>

<div>
<div class="flex items-center justify-between px-8">
<PlanSwitchArrow holidays={planData.schoolPlan.holidays} />
<div class="text-center leading-tight cursor-pointer" on:keypress={() => undefined} on:click={resetDate}>
<p class="text-md">{format(new Date($date), 'EEEE', { locale: de })}</p>
<p class="text-sm">
{new Date($date).toLocaleDateString()}
</p>
</div>
<PlanSwitchArrow holidays={planData.schoolPlan.holidays} turned />
</div>
<PlanSwitchArrow holidays={planData.schoolPlan.holidays} turned />
</div>

<p class="w-full text-center text-grayedOut">
{#if isRefreshing}
Lade...
{:else}
{planData.schoolPlan.created ? new Date(planData.schoolPlan.created).toLocaleString() : ''}
{/if}
</p>
<p class="w-full text-center text-grayedOut text-sm mt-1">
{#if isRefreshing}
Lade...
{:else}
{planData.schoolPlan.created ? new Date(planData.schoolPlan.created).toLocaleString() : ''}
{/if}
</p>
</div>

<div class="m-auto flex h-full w-[90%] flex-col gap-2 overflow-y-scroll">
{#if planData.schoolPlan.info && planData.schoolPlan.info.length > 0}
Expand Down

0 comments on commit b1f7134

Please sign in to comment.