Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load availability view with date from url-parameter #13

Merged
merged 2 commits into from
Jun 13, 2024
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
16 changes: 8 additions & 8 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"prettier-plugin-svelte": "^3.1.2",
"svelte": "^5.0.0-next.1",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.4.3",
"tailwindcss": "^3.4.4",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3",
"vite": "^5.2.13",
"vitest": "^1.2.0"
},
"type": "module",
Expand Down
7 changes: 3 additions & 4 deletions ui/src/routes/taxi/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { db } from '$lib/database';

export async function load({ url }) {
const day = url.searchParams.get('date') ?? new Date().toISOString().slice(0, 10);
console.log(new Date(day));

const day = new Date(url.searchParams.get('date') ?? new Date().toISOString().slice(0, 10));
const company_id = 1;
const vehicles = await db
.selectFrom('vehicle')
Expand All @@ -18,6 +16,7 @@ export async function load({ url }) {
.execute();
return {
vehicles,
tours
tours,
day
};
}
28 changes: 15 additions & 13 deletions ui/src/routes/taxi/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import { getCompany } from '$lib/api';
import type { Company } from '$lib/types';

import { DateFormatter, today, getLocalTimeZone } from '@internationalized/date';
import {
DateFormatter,
fromDate,
toCalendarDate,
getLocalTimeZone
} from '@internationalized/date';

import CalendarIcon from 'lucide-svelte/icons/calendar';
import { Calendar } from '$lib/components/ui/calendar/index.js';
Expand Down Expand Up @@ -37,9 +42,8 @@
vehicle_id!: number;
}

let vehicles = $state<Map<number, Vehicle>>(new Map<number, Vehicle>());
onMount(async () => {
vehicles = new Map<number, Vehicle>(
let vehicles = $state<Map<number, Vehicle>>(
new Map<number, Vehicle>(
data.vehicles.map((v) => [
v.id,
{
Expand All @@ -56,20 +60,18 @@
]
}
])
);
});

let tours = $state<Array<Tour>>([]);
onMount(async () => {
tours = data.tours.map((t) => ({
)
);
let tours = $state<Array<Tour>>(
data.tours.map((t) => ({
id: t.id,
from: t.departure,
to: t.arrival,
vehicle_id: t.vehicle
}));
});
}))
);

let value = $state(today('CET'));
let value = $state(toCalendarDate(fromDate(data.day, 'CET')));
let day = $derived(new ReactiveDate(value));

$effect(() => {
Expand Down