@@ -83,5 +83,30 @@ export const getEventFormValuesFromEvent = (
|
||||
recurrenceRule: event?.recurrenceRule || undefined,
|
||||
});
|
||||
|
||||
export const getEventValidationIssues = (
|
||||
event: Pick<CalendarEvent, "start" | "end" | "url">,
|
||||
) => {
|
||||
const issues: string[] = [];
|
||||
|
||||
if (event.end) {
|
||||
const startDate = new Date(event.start);
|
||||
const endDate = new Date(event.end);
|
||||
|
||||
if (
|
||||
!Number.isNaN(startDate.getTime()) &&
|
||||
!Number.isNaN(endDate.getTime()) &&
|
||||
endDate.getTime() < startDate.getTime()
|
||||
) {
|
||||
issues.push("end time is before start time");
|
||||
}
|
||||
}
|
||||
|
||||
if (event.url && !URL.canParse(event.url)) {
|
||||
issues.push("link is invalid");
|
||||
}
|
||||
|
||||
return issues;
|
||||
};
|
||||
|
||||
export const validateEventFormValues = (values: EventFormValues) =>
|
||||
eventFormSchema.safeParse(values);
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const APP_HEADER_SURFACE_CLASSES =
|
||||
"glass-surface mb-4 flex items-center justify-between gap-3 px-4 py-3";
|
||||
"mb-6 flex min-h-14 items-center justify-between gap-3 border-b border-foreground/10 bg-background/95 px-4 py-3 sm:px-6";
|
||||
|
||||
export const APP_SECTION_SURFACE_CLASSES = "glass-panel p-4 sm:p-5";
|
||||
export const APP_SECTION_SURFACE_CLASSES =
|
||||
"rounded-[10px] bg-card px-4 py-4 shadow-[0_0_0_1px_rgba(0,0,0,0.08),0_2px_2px_rgba(0,0,0,0.04),0_0_0_1px_#fafafa] sm:px-5";
|
||||
|
||||
export const APP_ACTION_BAR_CLASSES = "glass-subtle mb-4 p-3";
|
||||
export const APP_ACTION_BAR_CLASSES =
|
||||
"rounded-[10px] bg-card px-3 py-3 shadow-[0_0_0_1px_rgba(0,0,0,0.08)]";
|
||||
|
||||
export const APP_NAV_SURFACE_CLASSES =
|
||||
"glass-surface fixed inset-x-4 bottom-4 mx-auto flex max-w-3xl items-center justify-between px-3 py-2 sm:inset-x-6 lg:inset-x-8";
|
||||
"fixed inset-x-4 bottom-4 mx-auto flex max-w-3xl items-center justify-between rounded-[10px] bg-background/95 px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.08),0_8px_24px_rgba(0,0,0,0.08)] sm:inset-x-6 lg:hidden";
|
||||
|
||||
const CONNECTION_BADGE_BASE_CLASSES =
|
||||
"gap-1.5 border px-2.5 py-1 text-xs font-medium shadow-none";
|
||||
"gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium shadow-[0_0_0_1px_rgba(0,0,0,0.08)]";
|
||||
|
||||
export const getConnectionBadgeClasses = (isOnline: boolean) =>
|
||||
cn(
|
||||
CONNECTION_BADGE_BASE_CLASSES,
|
||||
isOnline
|
||||
? "border-emerald-500/35 bg-emerald-500/15 text-emerald-700 dark:border-emerald-400/25 dark:bg-emerald-500/15 dark:text-emerald-300 [&>svg]:text-emerald-500"
|
||||
: "border-border/70 bg-muted/55 text-muted-foreground dark:bg-muted/35 [&>svg]:text-muted-foreground",
|
||||
? "bg-[#ebf5ff] text-[#0068d6]"
|
||||
: "bg-muted text-muted-foreground",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user