-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5104638
commit df6a7fd
Showing
17 changed files
with
817 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 111 additions & 30 deletions
141
src/lib/assets/images/tool-thumbnails/AttendanceThumbnail.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
<script lang="ts"> | ||
import { browser } from '$app/environment'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/svelte-query'; | ||
import { MagnoliaUIRoot } from 'magnolia-ui-svelte'; | ||
</script> | ||
<MagnoliaUIRoot> | ||
<!-- <ProgressBar color="var(--victory-purple)" /> --> | ||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
enabled: browser | ||
} | ||
} | ||
}); | ||
</script> | ||
|
||
<slot /> | ||
</MagnoliaUIRoot> | ||
<QueryClientProvider client={queryClient}> | ||
<MagnoliaUIRoot> | ||
<slot /> | ||
</MagnoliaUIRoot> | ||
</QueryClientProvider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import type { RequestHandler } from './$types'; | ||
import prisma from '$lib/server/util/prisma'; | ||
import { DateTime } from 'luxon'; | ||
import { error } from '@sveltejs/kit'; | ||
|
||
const getFilteredPeople = async (search: string, noAttendanceOnDay: DateTime | null) => { | ||
const people = await prisma.person.findMany({ | ||
select: { | ||
id: true, | ||
name: true | ||
}, | ||
where: { | ||
AND: { | ||
OR: [ | ||
{ | ||
name: { | ||
contains: search, | ||
mode: 'insensitive' | ||
} | ||
}, | ||
{ | ||
email: { | ||
contains: search, | ||
mode: 'insensitive' | ||
} | ||
} | ||
], | ||
attendanceLogEntries: noAttendanceOnDay | ||
? { | ||
none: { | ||
timestamp: { | ||
lte: noAttendanceOnDay.endOf('day').toJSDate(), | ||
gte: noAttendanceOnDay.startOf('day').toJSDate() | ||
} | ||
} | ||
} | ||
: undefined | ||
} | ||
}, | ||
take: 10 | ||
}); | ||
|
||
return people; | ||
}; | ||
|
||
export const GET: RequestHandler = async ({ url }) => { | ||
const { searchParams } = new URL(url); | ||
const search = searchParams.get('search') ?? ''; | ||
const noAttendanceOnDayString = searchParams.get('noAttendanceOnDay'); | ||
|
||
let noAttendanceOnDay: DateTime | null = null; | ||
|
||
if (noAttendanceOnDayString) { | ||
noAttendanceOnDay = DateTime.fromFormat(noAttendanceOnDayString, 'yyyy-MM-dd'); | ||
if (!noAttendanceOnDay.isValid) { | ||
throw error(400, 'Invalid date'); | ||
} | ||
} | ||
|
||
const people = await getFilteredPeople(search, noAttendanceOnDay); | ||
|
||
return new Response(JSON.stringify(people), { | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
}; | ||
|
||
export type FilteredPerson = Awaited<ReturnType<typeof getFilteredPeople>>[number]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { redirect } from '@sveltejs/kit'; | ||
import { DateTime } from 'luxon'; | ||
|
||
export const load = () => { | ||
// Redirect to today's date if no date is specified | ||
throw redirect(307, `/tools/attendance/day/${DateTime.now().toFormat('yyyy-MM-dd')}`); | ||
}; |
Oops, something went wrong.