Skip to content

Commit

Permalink
fix: routes to non-existend events threw 500. They respond appropriat…
Browse files Browse the repository at this point in the history
…ely now
  • Loading branch information
brettski committed Oct 9, 2023
1 parent de86b49 commit f4512e1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thatconference.com",
"version": "5.0.9",
"version": "5.0.10",
"description": "THATConference.com website",
"main": "index.js",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { error } from '@sveltejs/kit';
import eventsApi from '$dataSources/api.that.tech/events/queries';

export async function load({ params, fetch }) {
Expand All @@ -6,8 +7,11 @@ export async function load({ params, fetch }) {

const { queryEventWithSpeakersBySlug } = eventsApi(fetch);

const eventRecord = await queryEventWithSpeakersBySlug(eventSlug);
if (!eventRecord) throw error(404, 'Event not found');

return {
eventSlug,
event: await queryEventWithSpeakersBySlug(eventSlug)
event: eventRecord
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
</div>
</div>
<div class="mt-4 flex items-baseline text-6xl font-extrabold">
{#if eventTickets['CLAIMABLE_TICKET'].price === 0}
{#if eventTickets['CLAIMABLE_TICKET']?.price === 0}
Free
{:else}
${eventTickets['CLAIMABLE_TICKET'].price}
${eventTickets['CLAIMABLE_TICKET']?.price ?? 15}
<span class="ml-1 text-2xl font-medium text-gray-500"> USD </span>
{/if}
</div>
Expand Down Expand Up @@ -107,7 +107,7 @@

<StandardButton
on:click={() =>
dispatch('claim-ticket', { product: { id: eventTickets['CLAIMABLE_TICKET'].id } })}>
dispatch('claim-ticket', { product: { id: eventTickets['CLAIMABLE_TICKET']?.id } })}>
Claim Your Ticket
</StandardButton>
</div>
Expand All @@ -133,7 +133,7 @@
<p class="text-lg text-gray-500">
{dayjs(event.startDate).format('dddd, MMMM D, YYYY - h:mm A z')}
</p>
<p class="mt-6 text-lg text-gray-500">
<p class="mt-6 text-lg text-gray-500">
{eventTickets['VIRTUAL_CAMPER'].description}
</p>
</div>
Expand Down Expand Up @@ -175,7 +175,7 @@
</div>
</div>

<div class="relative mt-12 lg:mt-24">
<div class="relative mt-12 lg:mt-24">
<div class="flex flex-col">
<h3 class="text-2xl font-extrabold tracking-tight text-thatBlue-800 sm:text-3xl">
Built to support the practitioners
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</h1>

<h2
class="mt-1 text-4xl font-extrabold tracking-tight text-white sm:mt-2 sm:text-6xl lg:mt-3 xl:text-6xl ">
class="mt-1 text-4xl font-extrabold tracking-tight text-white sm:mt-2 sm:text-6xl lg:mt-3 xl:text-6xl">
{dayjs(event.startDate).format('MMMM D, YYYY')}
</h2>
</div>
Expand All @@ -60,15 +60,15 @@
<div class="col-span-3 mt-6 flex flex-col items-center space-y-6 font-extrabold">
<div>
<div class="transform transition duration-500 ease-in-out hover:scale-105">
<a href={`/activities/${event.slug}`}>
<a href={`https://that.us/activities/${event.slug}`}>
<span
class="rounded-md bg-thatOrange-400 px-4 py-2 text-lg uppercase leading-5 tracking-wide text-white transition duration-500 ease-in-out hover:bg-thatOrange-500"
>View Event Schedule</span>
>View Event Schedule on THAT.us</span>
</a>
</div>
</div>

<p class="text-lg lowercase italic tracking-tight text-white ">
<p class="text-lg lowercase italic tracking-tight text-white">
all dates/times are represented in your time zone.
</p>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/routes/(that conferences)/+layout.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { error } from '@sveltejs/kit';
import eventsApi from '$dataSources/api.that.tech/events/queries';

export const trailingSlash = 'always';
Expand All @@ -18,6 +19,8 @@ export async function load({ params, url }) {
const { queryEventWithSpeakersBySlug } = eventsApi();
const event = await queryEventWithSpeakersBySlug(eventSlug);

if (!event) throw error(404, 'Event not found');

return {
eventName,
event
Expand Down

0 comments on commit f4512e1

Please sign in to comment.