@bsv/create-dpp-app 0.0.0-stage → 0.1.0-beta.1

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.
Files changed (81) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +73 -2
  3. package/dist/index.js +97 -0
  4. package/package.json +53 -4
  5. package/template/Dockerfile +35 -0
  6. package/template/README.md +134 -0
  7. package/template/_dockerignore +6 -0
  8. package/template/_env.example +53 -0
  9. package/template/_github/workflows/ci.yml +23 -0
  10. package/template/_gitignore +8 -0
  11. package/template/_prettierrc +6 -0
  12. package/template/apps/api/API.md +49 -0
  13. package/template/apps/api/package.json +34 -0
  14. package/template/apps/api/src/auth.ts +55 -0
  15. package/template/apps/api/src/claims.ts +85 -0
  16. package/template/apps/api/src/cli.ts +42 -0
  17. package/template/apps/api/src/config.ts +66 -0
  18. package/template/apps/api/src/custody.ts +186 -0
  19. package/template/apps/api/src/dev-index.ts +71 -0
  20. package/template/apps/api/src/env.ts +14 -0
  21. package/template/apps/api/src/identifiers.ts +57 -0
  22. package/template/apps/api/src/index-client.ts +136 -0
  23. package/template/apps/api/src/main.ts +50 -0
  24. package/template/apps/api/src/parties.ts +68 -0
  25. package/template/apps/api/src/platform.ts +121 -0
  26. package/template/apps/api/src/profiles.ts +100 -0
  27. package/template/apps/api/src/reader.ts +96 -0
  28. package/template/apps/api/src/server.ts +420 -0
  29. package/template/apps/api/src/store.ts +249 -0
  30. package/template/apps/api/src/wallet.ts +346 -0
  31. package/template/apps/api/src/worker.ts +106 -0
  32. package/template/apps/api/src/writer.ts +351 -0
  33. package/template/apps/api/test/config.test.ts +15 -0
  34. package/template/apps/api/test/external-index.test.ts +31 -0
  35. package/template/apps/api/test/lifecycle.test.ts +136 -0
  36. package/template/apps/api/tsconfig.json +9 -0
  37. package/template/apps/api/vitest.config.ts +9 -0
  38. package/template/apps/web/components.json +21 -0
  39. package/template/apps/web/index.html +12 -0
  40. package/template/apps/web/package.json +33 -0
  41. package/template/apps/web/src/app.tsx +51 -0
  42. package/template/apps/web/src/components/bits.tsx +188 -0
  43. package/template/apps/web/src/components/layout.tsx +118 -0
  44. package/template/apps/web/src/components/passport-form.tsx +244 -0
  45. package/template/apps/web/src/components/read-passport.tsx +48 -0
  46. package/template/apps/web/src/components/reading.tsx +157 -0
  47. package/template/apps/web/src/components/ui/alert.tsx +65 -0
  48. package/template/apps/web/src/components/ui/badge.tsx +47 -0
  49. package/template/apps/web/src/components/ui/button.tsx +63 -0
  50. package/template/apps/web/src/components/ui/card.tsx +91 -0
  51. package/template/apps/web/src/components/ui/dialog.tsx +156 -0
  52. package/template/apps/web/src/components/ui/input.tsx +20 -0
  53. package/template/apps/web/src/components/ui/label.tsx +21 -0
  54. package/template/apps/web/src/components/ui/select.tsx +189 -0
  55. package/template/apps/web/src/components/ui/separator.tsx +25 -0
  56. package/template/apps/web/src/components/ui/table.tsx +115 -0
  57. package/template/apps/web/src/components/ui/tabs.tsx +90 -0
  58. package/template/apps/web/src/components/ui/textarea.tsx +17 -0
  59. package/template/apps/web/src/index.css +81 -0
  60. package/template/apps/web/src/lib/api.ts +286 -0
  61. package/template/apps/web/src/lib/auth.ts +10 -0
  62. package/template/apps/web/src/lib/format.ts +64 -0
  63. package/template/apps/web/src/lib/session.tsx +92 -0
  64. package/template/apps/web/src/lib/use-load.ts +46 -0
  65. package/template/apps/web/src/main.tsx +18 -0
  66. package/template/apps/web/src/pages/accept.tsx +108 -0
  67. package/template/apps/web/src/pages/brand.tsx +94 -0
  68. package/template/apps/web/src/pages/brands.tsx +104 -0
  69. package/template/apps/web/src/pages/home.tsx +51 -0
  70. package/template/apps/web/src/pages/new-passport.tsx +114 -0
  71. package/template/apps/web/src/pages/operations.tsx +150 -0
  72. package/template/apps/web/src/pages/passport.tsx +568 -0
  73. package/template/apps/web/src/pages/public-passport.tsx +24 -0
  74. package/template/apps/web/src/pages/sign-in.tsx +93 -0
  75. package/template/apps/web/src/pages/verify.tsx +30 -0
  76. package/template/apps/web/src/pages/wallet.tsx +141 -0
  77. package/template/apps/web/tsconfig.json +29 -0
  78. package/template/apps/web/vite.config.ts +15 -0
  79. package/template/deploy/compose.yml +26 -0
  80. package/template/package.json +42 -0
  81. package/template/tsconfig.base.json +13 -0
@@ -0,0 +1,94 @@
1
+ import { Link, useParams } from 'react-router'
2
+ import { Button } from '@/components/ui/button'
3
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
4
+ import { ErrorNotice, Loading, PageTitle, ToneBadge, statusTone } from '@/components/bits'
5
+ import { RequireAccount } from '@/components/layout'
6
+ import { api, passportRef } from '@/lib/api'
7
+ import { parseIdentifier } from '@/lib/format'
8
+ import { useLoad } from '@/lib/use-load'
9
+
10
+ export function Brand() {
11
+ return (
12
+ <RequireAccount>
13
+ <BrandPage />
14
+ </RequireAccount>
15
+ )
16
+ }
17
+
18
+ function BrandPage() {
19
+ const { brandId = '' } = useParams()
20
+ const passports = useLoad(() => api.brandPassports(brandId), [brandId])
21
+ const brands = useLoad(() => api.brands(), [])
22
+ const brand = brands.data?.find((b) => b.id === brandId)
23
+
24
+ return (
25
+ <div className="space-y-8">
26
+ <PageTitle
27
+ title={brand?.name ?? brandId}
28
+ description={
29
+ <span>
30
+ Brand {brandId}.{' '}
31
+ <Link to="/brands" className="underline underline-offset-4">
32
+ All brands
33
+ </Link>
34
+ </span>
35
+ }
36
+ action={
37
+ <Button asChild>
38
+ <Link to={`/brands/${encodeURIComponent(brandId)}/new`}>Issue a passport</Link>
39
+ </Button>
40
+ }
41
+ />
42
+ {passports.loading ? (
43
+ <Loading what="Loading the passports" />
44
+ ) : passports.error != null || passports.data == null ? (
45
+ <ErrorNotice error={passports.error ?? new Error('no answer')} title="Could not load the passports" />
46
+ ) : passports.data.length === 0 ? (
47
+ <p className="text-sm text-muted-foreground">No passports yet.</p>
48
+ ) : (
49
+ <Table>
50
+ <TableHeader>
51
+ <TableRow>
52
+ <TableHead>Identifier</TableHead>
53
+ <TableHead>Profile</TableHead>
54
+ <TableHead>Status</TableHead>
55
+ <TableHead className="text-right">States</TableHead>
56
+ <TableHead className="text-right">Proven</TableHead>
57
+ <TableHead />
58
+ </TableRow>
59
+ </TableHeader>
60
+ <TableBody>
61
+ {passports.data.map((passport) => {
62
+ const ident = parseIdentifier(passport.passportId)
63
+ return (
64
+ <TableRow key={passport.passportId}>
65
+ <TableCell>
66
+ {ident == null ? (
67
+ <span className="font-mono text-xs">{passport.passportId}</span>
68
+ ) : (
69
+ <>
70
+ <div className="font-medium">Serial {ident.serial}</div>
71
+ <div className="text-xs text-muted-foreground">GTIN {ident.gtin}</div>
72
+ </>
73
+ )}
74
+ </TableCell>
75
+ <TableCell>{passport.profile}</TableCell>
76
+ <TableCell>
77
+ <ToneBadge tone={statusTone(passport.status)}>{passport.status}</ToneBadge>
78
+ </TableCell>
79
+ <TableCell className="text-right">{passport.journal.states}</TableCell>
80
+ <TableCell className="text-right">{passport.journal.proven}</TableCell>
81
+ <TableCell className="text-right">
82
+ <Button asChild variant="outline" size="sm">
83
+ <Link to={`/passports/${passportRef(passport.passportId)}`}>Open</Link>
84
+ </Button>
85
+ </TableCell>
86
+ </TableRow>
87
+ )
88
+ })}
89
+ </TableBody>
90
+ </Table>
91
+ )}
92
+ </div>
93
+ )
94
+ }
@@ -0,0 +1,104 @@
1
+ import { useState, type FormEvent } from 'react'
2
+ import { Link } from 'react-router'
3
+ import { Button } from '@/components/ui/button'
4
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
5
+ import { Input } from '@/components/ui/input'
6
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
7
+ import { CopyButton, ErrorNotice, Loading, Mono, PageTitle } from '@/components/bits'
8
+ import { RequireAccount } from '@/components/layout'
9
+ import { api } from '@/lib/api'
10
+ import { formatTime, shortKey } from '@/lib/format'
11
+ import { useLoad } from '@/lib/use-load'
12
+
13
+ export function Brands() {
14
+ return (
15
+ <RequireAccount>
16
+ <BrandsPage />
17
+ </RequireAccount>
18
+ )
19
+ }
20
+
21
+ function BrandsPage() {
22
+ const brands = useLoad(() => api.brands(), [])
23
+ const [name, setName] = useState('')
24
+ const [busy, setBusy] = useState(false)
25
+ const [error, setError] = useState<unknown>()
26
+
27
+ async function create(event: FormEvent) {
28
+ event.preventDefault()
29
+ setBusy(true)
30
+ setError(undefined)
31
+ try {
32
+ await api.createBrand(name.trim())
33
+ setName('')
34
+ brands.reload()
35
+ } catch (cause) {
36
+ setError(cause)
37
+ } finally {
38
+ setBusy(false)
39
+ }
40
+ }
41
+
42
+ return (
43
+ <div className="space-y-10">
44
+ <PageTitle title="Brands" description="A brand issues passports and holds them until it hands them on. Its identity key is derived by the platform." />
45
+ {brands.loading ? (
46
+ <Loading what="Loading your brands" />
47
+ ) : brands.error != null || brands.data == null ? (
48
+ <ErrorNotice error={brands.error ?? new Error('no answer')} title="Could not load your brands" />
49
+ ) : brands.data.length === 0 ? (
50
+ <p className="text-sm text-muted-foreground">You are not a member of any brand yet. Create one below.</p>
51
+ ) : (
52
+ <Table>
53
+ <TableHeader>
54
+ <TableRow>
55
+ <TableHead>Name</TableHead>
56
+ <TableHead>Identity key</TableHead>
57
+ <TableHead>Created</TableHead>
58
+ <TableHead />
59
+ </TableRow>
60
+ </TableHeader>
61
+ <TableBody>
62
+ {brands.data.map((brand) => (
63
+ <TableRow key={brand.id}>
64
+ <TableCell>
65
+ <Link to={`/brands/${encodeURIComponent(brand.id)}`} className="font-medium underline-offset-4 hover:underline">
66
+ {brand.name}
67
+ </Link>
68
+ <div className="text-xs text-muted-foreground">{brand.id}</div>
69
+ </TableCell>
70
+ <TableCell>
71
+ <span className="flex items-center gap-1">
72
+ <Mono>{shortKey(brand.identityKey)}</Mono>
73
+ <CopyButton text={brand.identityKey} label="Copy the identity key" />
74
+ </span>
75
+ </TableCell>
76
+ <TableCell>{formatTime(brand.createdAt)}</TableCell>
77
+ <TableCell className="text-right">
78
+ <Button asChild variant="outline" size="sm">
79
+ <Link to={`/brands/${encodeURIComponent(brand.id)}`}>Passports</Link>
80
+ </Button>
81
+ </TableCell>
82
+ </TableRow>
83
+ ))}
84
+ </TableBody>
85
+ </Table>
86
+ )}
87
+ <Card className="max-w-md">
88
+ <CardHeader>
89
+ <CardTitle>Create a brand</CardTitle>
90
+ <CardDescription>You become its first member.</CardDescription>
91
+ </CardHeader>
92
+ <CardContent className="space-y-3">
93
+ <form onSubmit={create} className="flex gap-2">
94
+ <Input value={name} onChange={(e) => setName(e.target.value)} placeholder="Brand name" required aria-label="Brand name" />
95
+ <Button type="submit" disabled={busy || name.trim() === ''}>
96
+ {busy ? 'Working' : 'Create'}
97
+ </Button>
98
+ </form>
99
+ {error == null ? null : <ErrorNotice error={error} title="The brand was not created" />}
100
+ </CardContent>
101
+ </Card>
102
+ </div>
103
+ )
104
+ }
@@ -0,0 +1,51 @@
1
+ import { Link } from 'react-router'
2
+ import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
3
+ import { Button } from '@/components/ui/button'
4
+ import { ErrorNotice, Loading } from '@/components/bits'
5
+ import { useAccount, useHealth } from '@/lib/session'
6
+
7
+ export function Home() {
8
+ const { health, error, loading } = useHealth()
9
+ const account = useAccount()
10
+
11
+ return (
12
+ <div className="mx-auto max-w-2xl space-y-8">
13
+ <h1 className="text-3xl font-semibold tracking-tight">Digital Product Passports on BSV</h1>
14
+ <p className="text-base leading-relaxed text-muted-foreground">
15
+ Brands issue a passport for each product they make and keep it current through the product's life. Every state is a transaction on BSV, signed by the brand and countersigned by this platform, and anyone holding the identifier, or the QR code it
16
+ is printed as, can verify the whole history without asking the brand.
17
+ </p>
18
+ {loading ? <Loading /> : null}
19
+ {error == null ? null : <ErrorNotice error={error} title="The API is not answering" />}
20
+ {health?.devSession == null ? null : (
21
+ <Alert>
22
+ <AlertTitle>Development session</AlertTitle>
23
+ <AlertDescription>
24
+ <p>Sign-in is off: you are the developer, a member of Development brand. Configure MongoDB for sign-in.</p>
25
+ </AlertDescription>
26
+ </Alert>
27
+ )}
28
+ <div className="flex flex-wrap gap-3">
29
+ <Button asChild>
30
+ <Link to="/verify">Verify a passport</Link>
31
+ </Button>
32
+ {account.signedIn ? (
33
+ <Button asChild variant="outline">
34
+ <Link to="/brands">Your brands</Link>
35
+ </Button>
36
+ ) : null}
37
+ {!account.signedIn && account.canSignIn ? (
38
+ <Button asChild variant="outline">
39
+ <Link to="/sign-in">Sign in</Link>
40
+ </Button>
41
+ ) : null}
42
+ </div>
43
+ {health == null ? null : (
44
+ <p className="text-xs text-muted-foreground">
45
+ Network {health.network}. Identifiers under https://{health.identifiers.host} with GS1 prefix {health.identifiers.prefix}
46
+ {health.identifiers.demonstration ? ' (the demonstration prefix)' : ''}. Live publishing {health.livePublishing ? 'on' : 'off'}.
47
+ </p>
48
+ )}
49
+ </div>
50
+ )
51
+ }
@@ -0,0 +1,114 @@
1
+ import { useState } from 'react'
2
+ import { Link, useNavigate, useParams } from 'react-router'
3
+ import { Input } from '@/components/ui/input'
4
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
5
+ import { ErrorNotice, Field, Loading, PageTitle } from '@/components/bits'
6
+ import { RequireAccount } from '@/components/layout'
7
+ import { PassportForm, type PassportFormValues } from '@/components/passport-form'
8
+ import { api, passportRef, type Profile } from '@/lib/api'
9
+ import { useHealth } from '@/lib/session'
10
+ import { useLoad } from '@/lib/use-load'
11
+
12
+ export function NewPassport() {
13
+ return (
14
+ <RequireAccount>
15
+ <NewPassportPage />
16
+ </RequireAccount>
17
+ )
18
+ }
19
+
20
+ function NewPassportPage() {
21
+ const { brandId = '' } = useParams()
22
+ const navigate = useNavigate()
23
+ const { health } = useHealth()
24
+ const profiles = useLoad(() => api.profiles(), [])
25
+ const [profileId, setProfileId] = useState('')
26
+ const profile = useLoad<Profile | undefined>(() => (profileId === '' ? Promise.resolve(undefined) : api.profile(profileId)), [profileId])
27
+ const [itemReference, setItemReference] = useState('')
28
+ const [serial, setSerial] = useState('')
29
+ const [busy, setBusy] = useState(false)
30
+ const [error, setError] = useState<unknown>()
31
+
32
+ async function issue(values: PassportFormValues) {
33
+ setBusy(true)
34
+ setError(undefined)
35
+ try {
36
+ const view = await api.issuePassport(brandId, { profile: profileId, itemReference: itemReference.trim(), serial: serial.trim(), ...values })
37
+ navigate(`/passports/${passportRef(view.passportId)}`)
38
+ } catch (cause) {
39
+ setError(cause)
40
+ } finally {
41
+ setBusy(false)
42
+ }
43
+ }
44
+
45
+ const chosen = profiles.data?.find((p) => p.id === profileId)
46
+ const prefix = health?.identifiers.prefix ?? '952'
47
+ const digits = Math.max(0, 12 - prefix.length)
48
+
49
+ return (
50
+ <div className="mx-auto max-w-3xl space-y-8">
51
+ <PageTitle
52
+ title="Issue a passport"
53
+ description={
54
+ <span>
55
+ For brand {brandId}.{' '}
56
+ <Link to={`/brands/${encodeURIComponent(brandId)}`} className="underline underline-offset-4">
57
+ Back to the brand
58
+ </Link>
59
+ </span>
60
+ }
61
+ />
62
+ <div className="max-w-md space-y-2">
63
+ <Field label="Profile" htmlFor="profile" required help={chosen?.description}>
64
+ {profiles.loading ? (
65
+ <Loading what="Loading the profiles" />
66
+ ) : profiles.error != null || profiles.data == null ? (
67
+ <ErrorNotice error={profiles.error ?? new Error('no answer')} title="Could not load the profiles" />
68
+ ) : (
69
+ <Select value={profileId} onValueChange={setProfileId}>
70
+ <SelectTrigger id="profile" className="w-full">
71
+ <SelectValue placeholder="Choose a profile" />
72
+ </SelectTrigger>
73
+ <SelectContent>
74
+ {profiles.data.map((p) => (
75
+ <SelectItem key={p.id} value={p.id}>
76
+ {p.title} ({p.id})
77
+ </SelectItem>
78
+ ))}
79
+ </SelectContent>
80
+ </Select>
81
+ )}
82
+ </Field>
83
+ </div>
84
+ {profileId === '' ? null : profile.loading ? (
85
+ <Loading what="Loading the profile" />
86
+ ) : profile.error != null || profile.data == null ? (
87
+ <ErrorNotice error={profile.error ?? new Error('no answer')} title={`Could not load ${profileId}`} />
88
+ ) : (
89
+ <PassportForm
90
+ key={profileId}
91
+ profile={profile.data}
92
+ initial={{ payload: profile.data.sample }}
93
+ submitLabel="Issue the passport"
94
+ busy={busy}
95
+ error={error}
96
+ onSubmit={issue}
97
+ before={
98
+ <fieldset className="space-y-4">
99
+ <legend className="mb-3 text-base font-semibold">Identifier</legend>
100
+ <div className="grid gap-4 sm:grid-cols-2">
101
+ <Field label="Item reference" htmlFor="itemReference" required help={`The digits after the GS1 prefix, nine for prefix 952. This platform's prefix is ${prefix}, so ${digits} digits.`}>
102
+ <Input id="itemReference" value={itemReference} onChange={(e) => setItemReference(e.target.value)} required inputMode="numeric" pattern="[0-9]+" placeholder={'0'.repeat(digits)} />
103
+ </Field>
104
+ <Field label="Serial" htmlFor="serial" required help="The item's serial, 1 to 20 characters.">
105
+ <Input id="serial" value={serial} onChange={(e) => setSerial(e.target.value)} required maxLength={20} />
106
+ </Field>
107
+ </div>
108
+ </fieldset>
109
+ }
110
+ />
111
+ )}
112
+ </div>
113
+ )
114
+ }
@@ -0,0 +1,150 @@
1
+ import { useState } from 'react'
2
+ import { Link } from 'react-router'
3
+ import { Button } from '@/components/ui/button'
4
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
5
+ import { CopyButton, ErrorNotice, Loading, Mono, PageTitle, Section, ToneBadge, statusTone } from '@/components/bits'
6
+ import { RequireAccount } from '@/components/layout'
7
+ import { api, passportRef } from '@/lib/api'
8
+ import { formatTime, publicPathOf, shortTxid } from '@/lib/format'
9
+ import { useLoad } from '@/lib/use-load'
10
+
11
+ export function Operations() {
12
+ return (
13
+ <RequireAccount>
14
+ <OperationsPage />
15
+ </RequireAccount>
16
+ )
17
+ }
18
+
19
+ function OperationsPage() {
20
+ const ops = useLoad(() => api.operations(), [])
21
+ const [running, setRunning] = useState(false)
22
+ const [done, setDone] = useState<string[]>()
23
+ const [runError, setRunError] = useState<unknown>()
24
+
25
+ async function run() {
26
+ setRunning(true)
27
+ setRunError(undefined)
28
+ try {
29
+ const answer = await api.runOperations()
30
+ setDone(answer.done)
31
+ ops.reload()
32
+ } catch (cause) {
33
+ setRunError(cause)
34
+ } finally {
35
+ setRunning(false)
36
+ }
37
+ }
38
+
39
+ return (
40
+ <div className="space-y-10">
41
+ <PageTitle
42
+ title="Operations"
43
+ description="What the worker still owes: announcing a state again, fetching its proof once mined, and pushing that proof to the index. The worker runs on its own; Run now does one pass here."
44
+ action={
45
+ <Button onClick={run} disabled={running}>
46
+ {running ? 'Running' : 'Run now'}
47
+ </Button>
48
+ }
49
+ />
50
+ {runError == null ? null : <ErrorNotice error={runError} title="The run failed" />}
51
+ {done == null ? null : (
52
+ <div className="rounded-lg border p-4">
53
+ <p className="mb-2 text-sm font-medium">Last run</p>
54
+ {done.length === 0 ? (
55
+ <p className="text-sm text-muted-foreground">Nothing was owed.</p>
56
+ ) : (
57
+ <ul className="list-disc space-y-1 pl-5 font-mono text-xs">
58
+ {done.map((line, i) => (
59
+ <li key={i}>{line}</li>
60
+ ))}
61
+ </ul>
62
+ )}
63
+ </div>
64
+ )}
65
+ {ops.loading ? (
66
+ <Loading what="Loading the duties" />
67
+ ) : ops.error != null || ops.data == null ? (
68
+ <ErrorNotice error={ops.error ?? new Error('no answer')} title="Could not load the operations" />
69
+ ) : (
70
+ <>
71
+ <Section title="Duties">
72
+ {ops.data.duties.length === 0 ? (
73
+ <p className="text-sm text-muted-foreground">Nothing is owed.</p>
74
+ ) : (
75
+ <Table>
76
+ <TableHeader>
77
+ <TableRow>
78
+ <TableHead>Passport</TableHead>
79
+ <TableHead>Op</TableHead>
80
+ <TableHead>Duty</TableHead>
81
+ <TableHead>Since</TableHead>
82
+ <TableHead>Txid</TableHead>
83
+ </TableRow>
84
+ </TableHeader>
85
+ <TableBody>
86
+ {ops.data.duties.map((duty) => (
87
+ <TableRow key={`${duty.txid}-${duty.duty}`}>
88
+ <TableCell>
89
+ <Link to={`/passports/${passportRef(duty.passportId)}`} className="font-mono text-xs underline-offset-4 hover:underline">
90
+ {publicPathOf(duty.passportId) ?? duty.passportId}
91
+ </Link>
92
+ </TableCell>
93
+ <TableCell>
94
+ <ToneBadge tone="neutral">{duty.op}</ToneBadge>
95
+ </TableCell>
96
+ <TableCell>{duty.duty}</TableCell>
97
+ <TableCell>{formatTime(duty.since)}</TableCell>
98
+ <TableCell>
99
+ <span className="flex items-center gap-1">
100
+ <Mono>{shortTxid(duty.txid)}</Mono>
101
+ <CopyButton text={duty.txid} label="Copy the txid" />
102
+ </span>
103
+ </TableCell>
104
+ </TableRow>
105
+ ))}
106
+ </TableBody>
107
+ </Table>
108
+ )}
109
+ </Section>
110
+ <Section title="Passports">
111
+ {ops.data.passports.length === 0 ? (
112
+ <p className="text-sm text-muted-foreground">No passports in the journal.</p>
113
+ ) : (
114
+ <Table>
115
+ <TableHeader>
116
+ <TableRow>
117
+ <TableHead>Passport</TableHead>
118
+ <TableHead>Brand</TableHead>
119
+ <TableHead>Status</TableHead>
120
+ <TableHead className="text-right">States</TableHead>
121
+ <TableHead className="text-right">Proven</TableHead>
122
+ <TableHead className="text-right">Pending</TableHead>
123
+ </TableRow>
124
+ </TableHeader>
125
+ <TableBody>
126
+ {ops.data.passports.map((p) => (
127
+ <TableRow key={p.passportId}>
128
+ <TableCell>
129
+ <Link to={`/passports/${passportRef(p.passportId)}`} className="font-mono text-xs underline-offset-4 hover:underline">
130
+ {publicPathOf(p.passportId) ?? p.passportId}
131
+ </Link>
132
+ </TableCell>
133
+ <TableCell>{p.brandId}</TableCell>
134
+ <TableCell>
135
+ <ToneBadge tone={statusTone(p.status)}>{p.status}</ToneBadge>
136
+ </TableCell>
137
+ <TableCell className="text-right">{p.journal.states}</TableCell>
138
+ <TableCell className="text-right">{p.journal.proven}</TableCell>
139
+ <TableCell className="text-right">{p.journal.pending}</TableCell>
140
+ </TableRow>
141
+ ))}
142
+ </TableBody>
143
+ </Table>
144
+ )}
145
+ </Section>
146
+ </>
147
+ )}
148
+ </div>
149
+ )
150
+ }