Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions apps/www/src/lib/components/downloads/ClaimedCredits.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
import { Download } from '@lucide/svelte';
import Input from '../ui/Input.svelte';
import Button from '../ui/Button.svelte';
import { ISOStandard } from '$lib/date';

let startDate = $state('');
let loading = $state(false);
let endDate = $state('');

$effect(() => {
if (!endDate) {
const today = new Date();
const formattedDate = today.toISOString().slice(0, 16);
endDate = formattedDate;
}
});
let endDate = $derived(ISOStandard(new Date()));
</script>

<div class="flex max-w-xs flex-col gap-4">
Expand Down
15 changes: 1 addition & 14 deletions apps/www/src/routes/portal/claim-beer/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fail } from '@sveltejs/kit';
import { getProducts } from '$lib/api/sanity/products';
import { claimedCredits, users } from '$lib/db/schemas';
import { gte, eq, desc, lte, and } from 'drizzle-orm';
import { formatDate } from '$lib/date';

export const load: PageServerLoad = async ({ locals }) => {
const userId = await locals.user?.id;
Expand Down Expand Up @@ -177,20 +178,6 @@ export const actions: Actions = {
return `"${stringField}"`;
};

const formatDate = (date: Date): string => {
return date
.toLocaleString('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false
})
.replace(/,/g, '');
};

const headers = ['Product', 'Name', 'Cost', 'Created At'];
const csvRows = [headers.join(',')];

Expand Down
13 changes: 2 additions & 11 deletions apps/www/src/routes/portal/claim-beer/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { FilterState } from '$lib/states/filter-state.svelte';
import { urlFor } from '$lib/api/sanity/image';
import Button from '$lib/components/ui/Button.svelte';
import { normalDate } from '$lib/date';

let loading = $state(false);
let selectedProduct = $state<null | Product>(null);
Expand Down Expand Up @@ -88,16 +89,6 @@
}
claimedProduct = null;
}

function formatDate(date: Date) {
return new Date(date).toLocaleString('no-NO', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
}
</script>

<svelte:head>
Expand Down Expand Up @@ -254,7 +245,7 @@

{#if data.lastClaimed}
<p class="mt-8 text-center text-lg text-gray-600">
Historikk: {data.lastClaimed.productName} - {formatDate(data.lastClaimed.claimedAt)}
Historikk: {data.lastClaimed.productName} - {normalDate(data.lastClaimed.claimedAt)}
</p>
{/if}
{/if}
6 changes: 4 additions & 2 deletions internal/emails/emails/shiftemail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ const ShiftEmail = ({ shift, user }: ShiftEmailProps) => {
</Text>

<Text className="mt-2">
<strong>Fra:</strong> {new Date(shift.startAt).toLocaleString()}
<strong>Fra:</strong>{" "}
{new Date(shift.startAt).toLocaleString("nb-NO")}
</Text>

<Text className="mt-1">
<strong>Til:</strong> {new Date(shift.endAt).toLocaleString()}
<strong>Til:</strong>{" "}
{new Date(shift.endAt).toLocaleString("nb-NO")}
</Text>

{shift.description && (
Expand Down