Add employee type management and filtering functionality
- Introduced a new `Type` field in the `EmployeeRecord` interface to categorize employees as 'Employee', 'Sub-Contractor', etc. - Updated forms and tables in Svelte to include type selection and display. - Enhanced API endpoints to support filtering employees by type in search queries. - Implemented type filtering buttons and a dropdown in the employee management interface for improved user experience.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import { Label } from '$lib/components/ui/label/index.js';
|
||||
import * as Dialog from '$lib/components/ui/dialog/index.js';
|
||||
import * as Card from '$lib/components/ui/card/index.js';
|
||||
import { badgeVariants } from '$lib/components/ui/badge/index.js';
|
||||
import { Badge, badgeVariants } from '$lib/components/ui/badge/index.js';
|
||||
import type {
|
||||
EmployeeRecord,
|
||||
EmployeeReportRecord,
|
||||
@@ -270,8 +270,11 @@
|
||||
<Button variant="ghost" size="icon" href="/" class="shrink-0">
|
||||
<ArrowLeftIcon class="size-4" />
|
||||
</Button>
|
||||
<h1 class="text-2xl font-semibold tracking-tight shrink-0">
|
||||
<h1 class="text-2xl font-semibold tracking-tight shrink-0 flex items-center gap-2 flex-wrap">
|
||||
{employee?.First_Name} {employee?.Last_Name}
|
||||
{#if employee?.Type}
|
||||
<Badge variant="secondary">{employee.Type}</Badge>
|
||||
{/if}
|
||||
</h1>
|
||||
{#if employee}
|
||||
<div class="flex items-center gap-2 ml-auto">
|
||||
@@ -325,6 +328,38 @@
|
||||
<dd>{employee.Last_Name || '—'}</dd>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label for="emp-type" class="text-muted-foreground text-sm">Type</Label>
|
||||
{#if editMode}
|
||||
<Select.Root
|
||||
type="single"
|
||||
value={employee.Type ?? ''}
|
||||
onValueChange={(v) => {
|
||||
employee = { ...employee!, Type: v ?? undefined };
|
||||
if (v !== undefined) patchField('Type', v ?? '');
|
||||
}}
|
||||
disabled={patchSaving}
|
||||
>
|
||||
<Select.Trigger class="w-full" id="emp-type">
|
||||
{employee.Type || 'Select type…'}
|
||||
</Select.Trigger>
|
||||
<Select.Content>
|
||||
<Select.Item value="" label="(none)">(none)</Select.Item>
|
||||
{#each ['Employee', 'Sub-Contractor', 'Former-Employee', 'Applicant', 'Blacklisted'] as opt}
|
||||
<Select.Item value={opt} label={opt}>{opt}</Select.Item>
|
||||
{/each}
|
||||
</Select.Content>
|
||||
</Select.Root>
|
||||
{:else}
|
||||
<dd>
|
||||
{#if employee.Type}
|
||||
<Badge variant="secondary">{employee.Type}</Badge>
|
||||
{:else}
|
||||
—
|
||||
{/if}
|
||||
</dd>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label for="emp-status" class="text-muted-foreground text-sm">Status</Label>
|
||||
{#if editMode}
|
||||
|
||||
Reference in New Issue
Block a user