Merge remote-tracking branch 'origin/main' into feat/absences

This commit is contained in:
Karl Ludwig Weise
2025-10-12 15:09:11 +02:00
7 changed files with 12 additions and 33 deletions
+1 -2
View File
@@ -4,10 +4,9 @@ End-to-end encrypted appointment booking platform
## Local development
- Create your own local `.env` file. You can base it on [.env.example](./.env.example)
- `npm install`
- `npm run docker:dev:up`
- `npm run db:migrate`
- `npm run db:push`
- `npm run dev`
## Funding
@@ -12,7 +12,6 @@ const CHANNEL_COLORS = ["#FF0000", "#00FF00", "#0000FF"] as const;
const NEXT_COLOR_KEY = "nextChannelColor";
const slotTemplateSchema = z.object({
name: z.string().min(1).max(100),
weekdays: z.number().int().min(0).max(127).optional(),
from: z.string().regex(/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/),
to: z.string().regex(/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/),
@@ -15,7 +15,7 @@
import { get } from "svelte/store";
import { superForm } from "sveltekit-superforms";
import { zodClient } from "sveltekit-superforms/adapters";
import { generateSlotTemplate } from "../utils";
import { DEFAULT_SLOT_TEMPLATE } from "../utils";
import { formSchema } from "./schema";
let { done }: { done: () => void } = $props();
@@ -35,7 +35,7 @@
agentIds: [] as string[],
isPublic: true,
requiresConfirmation: false,
slotTemplates: [generateSlotTemplate(0)],
slotTemplates: [DEFAULT_SLOT_TEMPLATE],
},
{
dataType: "json",
@@ -58,10 +58,7 @@
const { form: formData, enhance } = form;
const onAddSlotTemplate = () => {
$formData.slotTemplates = [
...$formData.slotTemplates,
generateSlotTemplate($formData.slotTemplates.length),
];
$formData.slotTemplates = [...$formData.slotTemplates, DEFAULT_SLOT_TEMPLATE];
};
const onRemoveSlotTemplate = (index: number) => {
@@ -166,7 +163,8 @@
{m["channels.add.fields.slotTemplates.description"]()}
</Text>
<div class="flex flex-col gap-2 pt-2">
{#each $formData.slotTemplates as template, i (`${template.name}-${i}`)}
<!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
{#each $formData.slotTemplates as _, i (`template-${i}`)}
<SlotTemplate
index={i}
{form}
@@ -18,7 +18,6 @@ export const formSchema = z.object({
slotTemplates: z
.array(
z.object({
name: z.string().min(1).max(100),
weekdays: z.number().int().min(0).max(127).default(15),
from: z.string().regex(/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/),
to: z.string().regex(/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/),
@@ -17,7 +17,7 @@
import { superForm } from "sveltekit-superforms";
import { zodClient } from "sveltekit-superforms/adapters";
import { formSchema } from ".";
import { generateSlotTemplate } from "../utils";
import { DEFAULT_SLOT_TEMPLATE } from "../utils";
let { entity, done }: { entity: TChannelWithFullAgents; done: () => void } = $props();
@@ -51,14 +51,7 @@
}
isSubmitting = false;
},
// onSubmit: () => (isSubmitting = true),
onSubmit: ({ formData }) => {
// TODO: Fix editing of channels with slot templates
console.log("formData", formData);
const validation = formSchema.safeParse(formData);
console.log("validation", validation);
isSubmitting = true;
},
onSubmit: () => (isSubmitting = true),
},
);
@@ -69,7 +62,7 @@
const onAddSlotTemplate = () => {
$formData.slotTemplates = [
...$formData.slotTemplates,
generateSlotTemplate($formData.slotTemplates.length),
DEFAULT_SLOT_TEMPLATE,
] as TSlotTemplate[];
};
@@ -182,7 +175,8 @@
{m["channels.add.fields.slotTemplates.description"]()}
</Text>
<div class="flex flex-col gap-2 pt-2">
{#each $formData.slotTemplates as template, i (`${template.name}-${i}`)}
<!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
{#each $formData.slotTemplates as _, i (`template-${i}`)}
<SlotTemplate
index={i}
{form}
@@ -20,7 +20,6 @@ export const formSchema = z.object({
.array(
z.object({
id: z.string().optional(),
name: z.string().min(1).max(100),
weekdays: z.number().int().min(0).max(127).default(15),
from: z.string().regex(/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/),
to: z.string().regex(/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/),
@@ -1,17 +1,8 @@
import { m } from "$i18n/messages";
import type { TNewSlotTemplate } from "$lib/types/channel";
const DEFAULT_SLOT_TEMPLATE: TNewSlotTemplate = {
name: "test",
export const DEFAULT_SLOT_TEMPLATE: TNewSlotTemplate = {
weekdays: 31,
from: "09:00:00",
to: "17:00:00",
duration: 15,
};
export const generateSlotTemplate = (index: number) => {
return {
...DEFAULT_SLOT_TEMPLATE,
name: m["components.slotTemplate.template"]({ no: index + 1 }),
};
};