@igstack/app-catalog-frontend-core 6.12.4 → 6.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/__tests__/modules/appCatalog/utils/searchServiceDesks.test.d.ts +1 -0
- package/dist/esm/api/infra/trpc.d.ts +45 -0
- package/dist/esm/modules/appCatalog/ui/pages/ServiceDesksPage.d.ts +7 -3
- package/dist/esm/modules/appCatalog/ui/pages/ServiceDesksPage.js +288 -73
- package/dist/esm/modules/appCatalog/ui/pages/ServiceDesksPage.js.map +1 -1
- package/dist/esm/modules/appCatalog/ui/serviceDesks/Marked.d.ts +11 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/Marked.js +23 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/Marked.js.map +1 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.d.ts +25 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.js +161 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.js.map +1 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.d.ts +17 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.js +267 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.js.map +1 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/searchServiceDesks.d.ts +37 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/searchServiceDesks.js +111 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/searchServiceDesks.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/schemas.js +43 -3
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/schemas.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/api.js +72 -1
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/api.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/checks.js +169 -2
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/checks.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/json-schema-processors.js +45 -0
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/json-schema-processors.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/regexes.js +4 -0
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/regexes.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.js +33 -3
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.js +24 -0
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.js.map +1 -1
- package/dist/esm/routeTree.gen.d.ts +3 -0
- package/dist/esm/routes/_layout/service-desks.d.ts +3 -0
- package/dist/esm/routes/_layout/service-desks.js +12 -2
- package/dist/esm/routes/_layout/service-desks.js.map +1 -1
- package/dist/esm/ui/item.d.ts +1 -1
- package/package.json +4 -4
- package/src/__tests__/modules/appCatalog/utils/searchServiceDesks.test.ts +117 -0
- package/src/modules/appCatalog/ui/pages/ServiceDesksPage.tsx +385 -113
- package/src/modules/appCatalog/ui/serviceDesks/Marked.tsx +31 -0
- package/src/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.tsx +221 -0
- package/src/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.tsx +349 -0
- package/src/modules/appCatalog/ui/serviceDesks/searchServiceDesks.ts +173 -0
- package/src/routes/_layout/service-desks.tsx +10 -0
- package/dist/esm/ui/input-group.js +0 -82
- package/dist/esm/ui/input-group.js.map +0 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { ExternalLink } from 'lucide-react'
|
|
2
|
+
import { memo, useState } from 'react'
|
|
3
|
+
import { displayUrl } from '~/modules/appCatalog/utils/displayUrl'
|
|
4
|
+
import { Marked } from './Marked'
|
|
5
|
+
import { hasPortal, liveOptions } from './searchServiceDesks'
|
|
6
|
+
import type { FieldMatch, FormResult, ServiceDesk } from './searchServiceDesks'
|
|
7
|
+
|
|
8
|
+
/** Options shown per matched dropdown before "Show all". */
|
|
9
|
+
const OPTIONS_SHOWN = 8
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* One form in the results. Three styles only: the title in ink, everything
|
|
13
|
+
* else muted, and the search marker as the single accent.
|
|
14
|
+
*
|
|
15
|
+
* The card opens the desk's details; the form's address is the only way out to
|
|
16
|
+
* the portal, so a stray click never leaves the catalog.
|
|
17
|
+
*/
|
|
18
|
+
export const ServiceDeskCard = memo(function ResultCardView({
|
|
19
|
+
result,
|
|
20
|
+
query,
|
|
21
|
+
onOpen,
|
|
22
|
+
}: {
|
|
23
|
+
result: FormResult
|
|
24
|
+
query: string
|
|
25
|
+
/** Stable across renders, so an unchanged card skips re-rendering. */
|
|
26
|
+
onOpen: (deskSlug: string, formId?: string) => void
|
|
27
|
+
}) {
|
|
28
|
+
const { desk, form, fieldMatches } = result
|
|
29
|
+
const onOpenDetails = () => onOpen(desk.slug, form.id)
|
|
30
|
+
const portal = desk.config.portal
|
|
31
|
+
return (
|
|
32
|
+
<li
|
|
33
|
+
// A listitem that is also a button: the whole card is the target, and the
|
|
34
|
+
// link and "Show all" inside it keep their own clicks.
|
|
35
|
+
role="button"
|
|
36
|
+
tabIndex={0}
|
|
37
|
+
aria-label={`Details for ${form.name}, ${desk.displayName}`}
|
|
38
|
+
data-testid="service-desk-result"
|
|
39
|
+
onClick={(e) => {
|
|
40
|
+
if (!(e.target as HTMLElement).closest('a,button')) onOpenDetails()
|
|
41
|
+
}}
|
|
42
|
+
onKeyDown={(e) => {
|
|
43
|
+
if (e.key === 'Enter' && e.target === e.currentTarget) onOpenDetails()
|
|
44
|
+
}}
|
|
45
|
+
className="cursor-pointer rounded-[var(--radius)] border border-border bg-card p-5 transition-colors hover:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
|
|
46
|
+
>
|
|
47
|
+
<h2 className="text-[17px] font-semibold leading-snug">
|
|
48
|
+
<Marked text={form.name} query={query} />
|
|
49
|
+
</h2>
|
|
50
|
+
<p className="mt-0.5 text-[13px] text-muted-foreground">
|
|
51
|
+
<span className="font-semibold tracking-wide" title="Portal key">
|
|
52
|
+
<Marked text={portal.key} query={query} />
|
|
53
|
+
</span>
|
|
54
|
+
{' · '}
|
|
55
|
+
<Marked text={desk.displayName} query={query} />
|
|
56
|
+
</p>
|
|
57
|
+
{form.description ? (
|
|
58
|
+
<p className="max-w-[68ch] py-3 text-[15px] leading-[1.6]">
|
|
59
|
+
<Marked text={form.description} query={query} />
|
|
60
|
+
</p>
|
|
61
|
+
) : (
|
|
62
|
+
<div className="h-3" />
|
|
63
|
+
)}
|
|
64
|
+
{fieldMatches.length > 0 && (
|
|
65
|
+
<div className="flex flex-col gap-0.5 pb-3">
|
|
66
|
+
{fieldMatches.map((m) => (
|
|
67
|
+
<MatchedOptions key={m.field.name} match={m} />
|
|
68
|
+
))}
|
|
69
|
+
</div>
|
|
70
|
+
)}
|
|
71
|
+
<div className="flex flex-wrap items-end justify-between gap-x-4 gap-y-2">
|
|
72
|
+
<a
|
|
73
|
+
href={form.url}
|
|
74
|
+
target="_blank"
|
|
75
|
+
rel="noopener noreferrer"
|
|
76
|
+
className="inline-flex items-center gap-1 break-all text-[13.5px] text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:text-foreground hover:decoration-foreground"
|
|
77
|
+
>
|
|
78
|
+
{displayUrl(form.url)}
|
|
79
|
+
<ExternalLink className="size-3.5 shrink-0" aria-hidden="true" />
|
|
80
|
+
</a>
|
|
81
|
+
{portal.area && (
|
|
82
|
+
<span className="whitespace-nowrap rounded-full bg-muted px-2 py-1 text-[11.5px] leading-none text-muted-foreground">
|
|
83
|
+
{portal.area}
|
|
84
|
+
</span>
|
|
85
|
+
)}
|
|
86
|
+
</div>
|
|
87
|
+
</li>
|
|
88
|
+
)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A desk on the Service Desks home: the same anatomy as a result card, minus
|
|
93
|
+
* the form and its fields. A desk with a portal opens its details; one without
|
|
94
|
+
* (a chat bot, a web form) is only its link.
|
|
95
|
+
*/
|
|
96
|
+
export const DeskCard = memo(function DeskCardView({
|
|
97
|
+
desk,
|
|
98
|
+
onOpen,
|
|
99
|
+
showArea = true,
|
|
100
|
+
}: {
|
|
101
|
+
desk: ServiceDesk
|
|
102
|
+
onOpen: (deskSlug: string) => void
|
|
103
|
+
/** Off inside an area's own section, where the tag would repeat its heading. */
|
|
104
|
+
showArea?: boolean
|
|
105
|
+
}) {
|
|
106
|
+
const portal = hasPortal(desk) ? desk.config.portal : undefined
|
|
107
|
+
const url = desk.config.url
|
|
108
|
+
const forms = portal?.requestTypes.length ?? 0
|
|
109
|
+
const open = () =>
|
|
110
|
+
portal
|
|
111
|
+
? onOpen(desk.slug)
|
|
112
|
+
: url && window.open(url, '_blank', 'noopener,noreferrer')
|
|
113
|
+
return (
|
|
114
|
+
<li
|
|
115
|
+
role="button"
|
|
116
|
+
tabIndex={0}
|
|
117
|
+
aria-label={
|
|
118
|
+
portal ? `Details for ${desk.displayName}` : `Open ${desk.displayName}`
|
|
119
|
+
}
|
|
120
|
+
onClick={(e) => {
|
|
121
|
+
if (!(e.target as HTMLElement).closest('a,button')) open()
|
|
122
|
+
}}
|
|
123
|
+
onKeyDown={(e) => {
|
|
124
|
+
if (e.key === 'Enter' && e.target === e.currentTarget) open()
|
|
125
|
+
}}
|
|
126
|
+
className="flex cursor-pointer flex-col rounded-[var(--radius)] border border-border bg-card p-5 transition-colors hover:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
|
|
127
|
+
>
|
|
128
|
+
<h3
|
|
129
|
+
className="text-[17px] font-semibold leading-snug"
|
|
130
|
+
data-testid="service-desk-name"
|
|
131
|
+
>
|
|
132
|
+
{desk.displayName}
|
|
133
|
+
</h3>
|
|
134
|
+
{portal && (
|
|
135
|
+
<p
|
|
136
|
+
className="mt-0.5 text-[13px] font-semibold tracking-wide text-muted-foreground"
|
|
137
|
+
title="Portal key"
|
|
138
|
+
>
|
|
139
|
+
{portal.key}
|
|
140
|
+
</p>
|
|
141
|
+
)}
|
|
142
|
+
{desk.config.description && (
|
|
143
|
+
<p className="line-clamp-3 max-w-[68ch] py-3 text-[15px] leading-[1.6]">
|
|
144
|
+
{desk.config.description}
|
|
145
|
+
</p>
|
|
146
|
+
)}
|
|
147
|
+
<div className="mt-auto flex flex-wrap items-end justify-between gap-x-4 gap-y-2 pt-1">
|
|
148
|
+
{url ? (
|
|
149
|
+
<a
|
|
150
|
+
href={url}
|
|
151
|
+
target="_blank"
|
|
152
|
+
rel="noopener noreferrer"
|
|
153
|
+
className="inline-flex min-w-0 items-center gap-1 text-[13.5px] text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:text-foreground hover:decoration-foreground"
|
|
154
|
+
>
|
|
155
|
+
<span className="truncate">{displayUrl(url)}</span>
|
|
156
|
+
<ExternalLink className="size-3.5 shrink-0" aria-hidden="true" />
|
|
157
|
+
</a>
|
|
158
|
+
) : (
|
|
159
|
+
<span />
|
|
160
|
+
)}
|
|
161
|
+
<span className="flex flex-wrap justify-end gap-1">
|
|
162
|
+
{forms > 0 && <Tag>{forms === 1 ? '1 form' : `${forms} forms`}</Tag>}
|
|
163
|
+
{showArea && portal?.area && <Tag>{portal.area}</Tag>}
|
|
164
|
+
</span>
|
|
165
|
+
</div>
|
|
166
|
+
</li>
|
|
167
|
+
)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
function Tag({ children }: { children: React.ReactNode }) {
|
|
171
|
+
return (
|
|
172
|
+
<span className="whitespace-nowrap rounded-full bg-muted px-2 py-1 text-[11.5px] leading-none text-muted-foreground">
|
|
173
|
+
{children}
|
|
174
|
+
</span>
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* A dropdown as one comma-separated line in the form's own order, the matched
|
|
180
|
+
* options marked. Long lists stop after a few, never dropping a match.
|
|
181
|
+
*/
|
|
182
|
+
function MatchedOptions({ match }: { match: FieldMatch }) {
|
|
183
|
+
const [all, setAll] = useState(false)
|
|
184
|
+
const options = liveOptions(match.field)
|
|
185
|
+
const others = options.filter((o) => !match.matched.includes(o))
|
|
186
|
+
const keep = new Set([
|
|
187
|
+
...match.matched,
|
|
188
|
+
...others.slice(0, Math.max(0, OPTIONS_SHOWN - match.matched.length)),
|
|
189
|
+
])
|
|
190
|
+
const shown = all ? options : options.filter((o) => keep.has(o))
|
|
191
|
+
return (
|
|
192
|
+
<p className="max-w-[68ch] text-[12.5px] leading-[1.55] text-muted-foreground">
|
|
193
|
+
{match.field.name}:{' '}
|
|
194
|
+
{shown.map((option, i) => (
|
|
195
|
+
<span key={option}>
|
|
196
|
+
{i > 0 && ', '}
|
|
197
|
+
{match.matched.includes(option) ? (
|
|
198
|
+
<mark className="whitespace-nowrap rounded-[3px] bg-highlight px-0.5 text-foreground">
|
|
199
|
+
{option}
|
|
200
|
+
</mark>
|
|
201
|
+
) : (
|
|
202
|
+
option
|
|
203
|
+
)}
|
|
204
|
+
</span>
|
|
205
|
+
))}
|
|
206
|
+
{options.length > keep.size && (
|
|
207
|
+
<>
|
|
208
|
+
{' '}
|
|
209
|
+
<button
|
|
210
|
+
type="button"
|
|
211
|
+
aria-expanded={all}
|
|
212
|
+
onClick={() => setAll(!all)}
|
|
213
|
+
className="cursor-pointer whitespace-nowrap underline decoration-muted-foreground/40 underline-offset-2 hover:text-foreground"
|
|
214
|
+
>
|
|
215
|
+
{all ? 'Show fewer' : `Show all ${options.length}`}
|
|
216
|
+
</button>
|
|
217
|
+
</>
|
|
218
|
+
)}
|
|
219
|
+
</p>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ServiceRequestField,
|
|
3
|
+
ServiceRequestType,
|
|
4
|
+
} from '@igstack/app-catalog-backend-core'
|
|
5
|
+
import {
|
|
6
|
+
ArrowUpRight,
|
|
7
|
+
ExternalLink,
|
|
8
|
+
MessageSquareText,
|
|
9
|
+
User,
|
|
10
|
+
} from 'lucide-react'
|
|
11
|
+
import { displayUrl } from '~/modules/appCatalog/utils/displayUrl'
|
|
12
|
+
import { DetailDialogShell } from '../catalog/DetailDialogShell'
|
|
13
|
+
import { MarkdownText } from '../components/MarkdownText'
|
|
14
|
+
import { DetailTabs } from '../detail/DetailTabs'
|
|
15
|
+
import { liveOptions } from './searchServiceDesks'
|
|
16
|
+
import type { PortalDesk } from './searchServiceDesks'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A desk's card, opened from a result (then `form` is the form clicked) or from
|
|
20
|
+
* the desk list (then it covers every form). Overview reads top to bottom like a
|
|
21
|
+
* short page: what the request is for, the one way into it, what it asks, and
|
|
22
|
+
* what happens after. Behind this card says where the card comes from.
|
|
23
|
+
*
|
|
24
|
+
* One link only: the button. The header is the subject, not a second door.
|
|
25
|
+
*/
|
|
26
|
+
export function ServiceDeskDetail({
|
|
27
|
+
desk,
|
|
28
|
+
form,
|
|
29
|
+
onClose,
|
|
30
|
+
}: {
|
|
31
|
+
desk: PortalDesk
|
|
32
|
+
form?: ServiceRequestType
|
|
33
|
+
onClose: () => void
|
|
34
|
+
}) {
|
|
35
|
+
const portal = desk.config.portal
|
|
36
|
+
|
|
37
|
+
const band = (
|
|
38
|
+
<div className="pr-20">
|
|
39
|
+
<h2 className="m-0 font-serif text-[28px] font-semibold leading-tight tracking-tight">
|
|
40
|
+
{form?.name ?? desk.displayName}
|
|
41
|
+
</h2>
|
|
42
|
+
<p className="mt-1 text-[14px] text-muted-foreground">
|
|
43
|
+
<span className="font-semibold tracking-wide" title="Portal key">
|
|
44
|
+
{portal.key}
|
|
45
|
+
</span>
|
|
46
|
+
{form && <> · {desk.displayName}</>}
|
|
47
|
+
</p>
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<DetailDialogShell
|
|
53
|
+
label={`${form?.name ?? desk.displayName} details`}
|
|
54
|
+
shownKey={`${desk.slug}:${form?.id ?? ''}`}
|
|
55
|
+
maxWidthClass="max-w-[min(1000px,94vw)]"
|
|
56
|
+
focusSelector="[data-primary-action]"
|
|
57
|
+
onClose={onClose}
|
|
58
|
+
>
|
|
59
|
+
<DetailTabs
|
|
60
|
+
band={band}
|
|
61
|
+
bandClassName="-mx-6 -mt-5 px-6 pt-5 sm:-mx-8 sm:-mt-7 sm:px-8 sm:pt-7"
|
|
62
|
+
tabs={[
|
|
63
|
+
{
|
|
64
|
+
id: 'overview',
|
|
65
|
+
label: 'Overview',
|
|
66
|
+
render: () => <Overview desk={desk} form={form} />,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'behind',
|
|
70
|
+
label: 'Behind this card',
|
|
71
|
+
render: () => <Behind desk={desk} />,
|
|
72
|
+
},
|
|
73
|
+
]}
|
|
74
|
+
/>
|
|
75
|
+
</DetailDialogShell>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The card's one link out. The address is in its tooltip, not on the page. */
|
|
80
|
+
function OpenButton({ url, label }: { url: string; label: string }) {
|
|
81
|
+
return (
|
|
82
|
+
<a
|
|
83
|
+
href={url}
|
|
84
|
+
target="_blank"
|
|
85
|
+
rel="noopener noreferrer"
|
|
86
|
+
title={url}
|
|
87
|
+
data-primary-action
|
|
88
|
+
className="inline-flex h-11 items-center gap-1.5 rounded-full bg-primary px-5 text-[15px] font-semibold text-primary-foreground transition-colors hover:bg-primary/90"
|
|
89
|
+
>
|
|
90
|
+
{label}
|
|
91
|
+
<ArrowUpRight className="size-4" aria-hidden="true" />
|
|
92
|
+
</a>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function Heading({ children }: { children: React.ReactNode }) {
|
|
97
|
+
return <h3 className="m-0 mb-2 text-[15px] font-semibold">{children}</h3>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function Overview({
|
|
101
|
+
desk,
|
|
102
|
+
form,
|
|
103
|
+
}: {
|
|
104
|
+
desk: PortalDesk
|
|
105
|
+
form?: ServiceRequestType
|
|
106
|
+
}) {
|
|
107
|
+
const portal = desk.config.portal
|
|
108
|
+
const url = form?.url ?? desk.config.url
|
|
109
|
+
return (
|
|
110
|
+
<div className="flex max-w-[760px] flex-col gap-8 pt-1">
|
|
111
|
+
<div>
|
|
112
|
+
{form?.description && (
|
|
113
|
+
<p className="text-[17px] leading-[1.6]">{form.description}</p>
|
|
114
|
+
)}
|
|
115
|
+
{desk.config.description && (
|
|
116
|
+
<p
|
|
117
|
+
className={
|
|
118
|
+
form?.description
|
|
119
|
+
? 'mt-2 text-[14px] text-muted-foreground'
|
|
120
|
+
: 'text-[17px] leading-[1.6]'
|
|
121
|
+
}
|
|
122
|
+
>
|
|
123
|
+
{desk.config.description}
|
|
124
|
+
</p>
|
|
125
|
+
)}
|
|
126
|
+
{url && (
|
|
127
|
+
<div className="mt-5">
|
|
128
|
+
<OpenButton
|
|
129
|
+
url={url}
|
|
130
|
+
label={form ? 'Open the form' : 'Open the portal'}
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
)}
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
{form ? (
|
|
137
|
+
<div>
|
|
138
|
+
<Heading>You will be asked for</Heading>
|
|
139
|
+
<FieldList fields={form.fields} />
|
|
140
|
+
</div>
|
|
141
|
+
) : (
|
|
142
|
+
<div>
|
|
143
|
+
<Heading>Forms on this portal</Heading>
|
|
144
|
+
{portal.requestTypes.length ? (
|
|
145
|
+
<ul className="flex flex-col gap-4">
|
|
146
|
+
{portal.requestTypes.map((rt) => (
|
|
147
|
+
<li key={rt.id}>
|
|
148
|
+
<a
|
|
149
|
+
href={rt.url}
|
|
150
|
+
target="_blank"
|
|
151
|
+
rel="noopener noreferrer"
|
|
152
|
+
className="inline-flex items-center gap-1 text-[15px] font-medium underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-foreground"
|
|
153
|
+
>
|
|
154
|
+
{rt.name}
|
|
155
|
+
<ExternalLink
|
|
156
|
+
className="size-3.5 text-muted-foreground"
|
|
157
|
+
aria-hidden="true"
|
|
158
|
+
/>
|
|
159
|
+
</a>
|
|
160
|
+
{rt.description && (
|
|
161
|
+
<p className="text-[14px] text-muted-foreground">
|
|
162
|
+
{rt.description}
|
|
163
|
+
</p>
|
|
164
|
+
)}
|
|
165
|
+
</li>
|
|
166
|
+
))}
|
|
167
|
+
</ul>
|
|
168
|
+
) : (
|
|
169
|
+
<p className="text-[14px] text-muted-foreground">
|
|
170
|
+
This desk publishes no forms.
|
|
171
|
+
</p>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
)}
|
|
175
|
+
|
|
176
|
+
<div>
|
|
177
|
+
<Heading>After you file</Heading>
|
|
178
|
+
{portal.followUp || portal.keyPeople?.length || portal.examples ? (
|
|
179
|
+
<FollowUp desk={desk} />
|
|
180
|
+
) : (
|
|
181
|
+
<p className="text-[14px] text-muted-foreground">
|
|
182
|
+
Nobody has written follow-up notes for this desk yet: what happens
|
|
183
|
+
after you file, who to ask when it stalls.
|
|
184
|
+
</p>
|
|
185
|
+
)}
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
{portal.area && (
|
|
189
|
+
<p className="text-[13px] text-muted-foreground">Area: {portal.area}</p>
|
|
190
|
+
)}
|
|
191
|
+
</div>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** What the form asks, one line per field. A preview: nothing here is an input. */
|
|
196
|
+
function FieldList({ fields }: { fields: ServiceRequestField[] }) {
|
|
197
|
+
if (!fields.length) {
|
|
198
|
+
return (
|
|
199
|
+
<p className="text-[14px] text-muted-foreground">
|
|
200
|
+
Only a summary and a description of the problem.
|
|
201
|
+
</p>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
return (
|
|
205
|
+
<ul className="flex flex-col gap-2 text-[14.5px]">
|
|
206
|
+
{fields.map((f) => (
|
|
207
|
+
<li key={f.name}>
|
|
208
|
+
<span className="font-medium">{f.name}</span>
|
|
209
|
+
{!f.required && (
|
|
210
|
+
<span className="text-muted-foreground"> (optional)</span>
|
|
211
|
+
)}
|
|
212
|
+
<span className="text-muted-foreground"> — {describeField(f)}</span>
|
|
213
|
+
</li>
|
|
214
|
+
))}
|
|
215
|
+
</ul>
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const OPTIONS_LISTED = 12
|
|
220
|
+
|
|
221
|
+
/** What a field takes, in words: its choices, or the kind of value. */
|
|
222
|
+
export function describeField(f: ServiceRequestField): string {
|
|
223
|
+
const options = liveOptions(f)
|
|
224
|
+
if (options.length) {
|
|
225
|
+
const listed = options.slice(0, OPTIONS_LISTED).join(', ')
|
|
226
|
+
const more =
|
|
227
|
+
options.length > OPTIONS_LISTED
|
|
228
|
+
? ` and ${options.length - OPTIONS_LISTED} more`
|
|
229
|
+
: ''
|
|
230
|
+
return `${f.type === 'array' ? 'One or more of' : 'One of'}: ${listed}${more}`
|
|
231
|
+
}
|
|
232
|
+
if (f.type === 'user') return 'A person, picked from the directory'
|
|
233
|
+
if (f.type === 'date' || f.type === 'datetime') return 'A date'
|
|
234
|
+
return 'A short text'
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function FollowUp({ desk }: { desk: PortalDesk }) {
|
|
238
|
+
const { followUp, keyPeople, examples } = desk.config.portal
|
|
239
|
+
return (
|
|
240
|
+
<div className="flex max-w-[68ch] flex-col gap-5">
|
|
241
|
+
{followUp && <MarkdownText>{followUp}</MarkdownText>}
|
|
242
|
+
{keyPeople?.length ? (
|
|
243
|
+
<div>
|
|
244
|
+
<p className="mb-2 text-[13px] font-semibold">Key people</p>
|
|
245
|
+
<div className="flex flex-wrap gap-2">
|
|
246
|
+
{keyPeople.map((p) => (
|
|
247
|
+
<span
|
|
248
|
+
key={p.name}
|
|
249
|
+
className="inline-flex items-center gap-1.5 rounded-md border border-border bg-card px-2 py-1 text-[13px]"
|
|
250
|
+
>
|
|
251
|
+
<User
|
|
252
|
+
className="size-3.5 text-muted-foreground"
|
|
253
|
+
aria-hidden="true"
|
|
254
|
+
/>
|
|
255
|
+
{p.name}
|
|
256
|
+
{p.role && (
|
|
257
|
+
<span className="text-muted-foreground">{p.role}</span>
|
|
258
|
+
)}
|
|
259
|
+
</span>
|
|
260
|
+
))}
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
) : null}
|
|
264
|
+
{examples && (
|
|
265
|
+
<div>
|
|
266
|
+
<p className="mb-2 text-[13px] font-semibold">See examples</p>
|
|
267
|
+
<a
|
|
268
|
+
href={examples.url}
|
|
269
|
+
target="_blank"
|
|
270
|
+
rel="noopener noreferrer"
|
|
271
|
+
className="flex items-center gap-3 rounded-[var(--radius)] border border-border bg-card px-3.5 py-3 transition-colors hover:border-ring"
|
|
272
|
+
>
|
|
273
|
+
<MessageSquareText
|
|
274
|
+
className="size-5 shrink-0 text-muted-foreground"
|
|
275
|
+
aria-hidden="true"
|
|
276
|
+
/>
|
|
277
|
+
<span className="min-w-0 flex-1">
|
|
278
|
+
<span className="block text-[14px] font-semibold">
|
|
279
|
+
{examples.label}
|
|
280
|
+
</span>
|
|
281
|
+
<span className="block truncate text-[13px] text-muted-foreground">
|
|
282
|
+
{displayUrl(examples.url)}
|
|
283
|
+
</span>
|
|
284
|
+
</span>
|
|
285
|
+
</a>
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
288
|
+
</div>
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function Behind({ desk }: { desk: PortalDesk }) {
|
|
293
|
+
const portal = desk.config.portal
|
|
294
|
+
const sources = [
|
|
295
|
+
...new Set([
|
|
296
|
+
...(desk.config.url ? [desk.config.url] : []),
|
|
297
|
+
...(portal.sources ?? []),
|
|
298
|
+
]),
|
|
299
|
+
]
|
|
300
|
+
return (
|
|
301
|
+
<div className="behind-panel">
|
|
302
|
+
<section className="behind-group">
|
|
303
|
+
<h2 className="behind-group__title">Kept up to date from</h2>
|
|
304
|
+
<ul className="space-y-2">
|
|
305
|
+
{sources.map((url, i) => (
|
|
306
|
+
<li key={url} className="flex items-center gap-2 text-xs">
|
|
307
|
+
<span className="shrink-0 tabular-nums text-muted-foreground">
|
|
308
|
+
{i + 1}.
|
|
309
|
+
</span>
|
|
310
|
+
<a
|
|
311
|
+
href={url}
|
|
312
|
+
target="_blank"
|
|
313
|
+
rel="noopener noreferrer"
|
|
314
|
+
className="inline-flex items-center gap-1 truncate hover:text-primary"
|
|
315
|
+
>
|
|
316
|
+
{displayUrl(url)}
|
|
317
|
+
<ExternalLink className="size-3 shrink-0" aria-hidden="true" />
|
|
318
|
+
</a>
|
|
319
|
+
</li>
|
|
320
|
+
))}
|
|
321
|
+
</ul>
|
|
322
|
+
{portal.syncedAt && (
|
|
323
|
+
<p className="behind-dates">
|
|
324
|
+
Forms and fields last read {portal.syncedAt.slice(0, 10)}.
|
|
325
|
+
</p>
|
|
326
|
+
)}
|
|
327
|
+
</section>
|
|
328
|
+
{(portal.aiPrompt || portal.aiMemory) && (
|
|
329
|
+
<section className="behind-group">
|
|
330
|
+
<h2 className="behind-group__title">
|
|
331
|
+
How the AI maintains this card
|
|
332
|
+
</h2>
|
|
333
|
+
{portal.aiPrompt && (
|
|
334
|
+
<>
|
|
335
|
+
<p className="behind-ai__label">Prompt</p>
|
|
336
|
+
<p className="behind-ai">{portal.aiPrompt}</p>
|
|
337
|
+
</>
|
|
338
|
+
)}
|
|
339
|
+
{portal.aiMemory && (
|
|
340
|
+
<>
|
|
341
|
+
<p className="behind-ai__label">Memory</p>
|
|
342
|
+
<p className="behind-ai">{portal.aiMemory}</p>
|
|
343
|
+
</>
|
|
344
|
+
)}
|
|
345
|
+
</section>
|
|
346
|
+
)}
|
|
347
|
+
</div>
|
|
348
|
+
)
|
|
349
|
+
}
|