Skip to content

Commit

Permalink
Update schema for office.id and office.area.id
Browse files Browse the repository at this point in the history
  • Loading branch information
ba1uev committed Mar 24, 2024
1 parent f5fbf22 commit c8671e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import { StackedBarChart, Card } from '#client/components/charts'
import { DATE_FORMAT } from '#client/constants'
import * as stores from '#client/stores'
import * as fp from '#shared/utils/fp'
import { H2, HR, Placeholder, Table, UserLabel, WidgetWrapper } from '#client/components/ui'
import {
H2,
HR,
Placeholder,
Table,
UserLabel,
WidgetWrapper,
} from '#client/components/ui'
import { RoomReservationAdminDashboardStats } from '#shared/types'
import { useAdminDashboardStats } from '../queries'

Expand Down Expand Up @@ -82,15 +89,15 @@ export const AdminDashboardStats: React.FC<Props> = ({ period, unit }) => {

if (!isFetched || !data) {
return (
<WidgetWrapper title="Guest visits">
<WidgetWrapper title="Room reservations">
<Placeholder children="Loading..." />
</WidgetWrapper>
)
}

if (noData) {
return (
<WidgetWrapper title="Guest visits">
<WidgetWrapper title="Room reservations">
<Placeholder children="No data" />
</WidgetWrapper>
)
Expand All @@ -99,26 +106,14 @@ export const AdminDashboardStats: React.FC<Props> = ({ period, unit }) => {
return (
<WidgetWrapper title="Room reservations">
<div className="flex gap-x-2 mb-4 overflow-x-scroll">
<Card
title={data.reservationsToday}
subtitle={'Reservations today'}
/>
<Card
title={data.reservationsTotal}
subtitle={'Total reservations'}
/>
<Card title={data.reservationsToday} subtitle={'Reservations today'} />
<Card title={data.reservationsTotal} subtitle={'Total reservations'} />
<Card
title={data.anonymouseReservationsPercent + '%'}
subtitle={'Anonymous reservations'}
/>
<Card
title={data.bookersToday}
subtitle={'Bookers today'}
/>
<Card
title={data.bookersTotal}
subtitle={'Bookers total'}
/>
<Card title={data.bookersToday} subtitle={'Bookers today'} />
<Card title={data.bookersTotal} subtitle={'Bookers total'} />
</div>
<StackedBarChart
xKey="date"
Expand Down
6 changes: 4 additions & 2 deletions src/server/app-config/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { z } from 'zod'

const SAFE_ID_RE = /^[A-Za-z_][A-Za-z0-9_]*$/

export const componentRef = z
.tuple([z.string(), z.string()])
.or(
Expand Down Expand Up @@ -70,7 +72,7 @@ export const officeAreaDesk = z
)

export const officeArea = z.object({
id: z.string(),
id: z.string().regex(SAFE_ID_RE),
available: z.boolean().default(true),
name: z.string(),
capacity: z.number().min(1),
Expand All @@ -97,7 +99,7 @@ export const officeRoom = z.object({

export const office = z
.object({
id: z.string(),
id: z.string().regex(SAFE_ID_RE),
name: z.string(),
icon: z.string().optional(),
timezone: z.string(),
Expand Down

0 comments on commit c8671e8

Please sign in to comment.