@contractspec/example.lifecycle-dashboard 1.44.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/.turbo/turbo-build$colon$bundle.log +25 -0
- package/.turbo/turbo-build.log +26 -0
- package/CHANGELOG.md +161 -0
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/docs/lifecycle-dashboard.docblock.d.ts +1 -0
- package/dist/docs/lifecycle-dashboard.docblock.js +20 -0
- package/dist/docs/lifecycle-dashboard.docblock.js.map +1 -0
- package/dist/example.d.ts +33 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +36 -0
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/snippets/page.d.ts +11 -0
- package/dist/snippets/page.d.ts.map +1 -0
- package/dist/snippets/page.js +63 -0
- package/dist/snippets/page.js.map +1 -0
- package/example.ts +1 -0
- package/package.json +59 -0
- package/src/docs/index.ts +1 -0
- package/src/docs/lifecycle-dashboard.docblock.ts +18 -0
- package/src/example.ts +24 -0
- package/src/index.ts +3 -0
- package/src/snippets/page.ts +58 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +6 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic snippet for a Next.js App Router page.
|
|
3
|
+
*
|
|
4
|
+
* We keep this as a string so `packages/examples/*` stays design-system-first and
|
|
5
|
+
* avoids raw HTML in runnable application code.
|
|
6
|
+
*/
|
|
7
|
+
export const lifecycleDashboardNextPageSnippet = `'use client';
|
|
8
|
+
|
|
9
|
+
import { useEffect, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
type StageCard = {
|
|
12
|
+
stage: number;
|
|
13
|
+
name: string;
|
|
14
|
+
confidence: number;
|
|
15
|
+
recommendation?: {
|
|
16
|
+
actions: { id: string; title: string; description: string }[];
|
|
17
|
+
};
|
|
18
|
+
libraries?: { id: string; description: string }[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default function LifecycleDashboardPage() {
|
|
22
|
+
const [card, setCard] = useState<StageCard | null>(null);
|
|
23
|
+
const [loading, setLoading] = useState(false);
|
|
24
|
+
const [error, setError] = useState<string>();
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
void runAssessment();
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
async function runAssessment() {
|
|
31
|
+
try {
|
|
32
|
+
setLoading(true);
|
|
33
|
+
setError(undefined);
|
|
34
|
+
const response = await fetch('/api/lifecycle/assessments', {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: { 'Content-Type': 'application/json' },
|
|
37
|
+
body: JSON.stringify({ tenantId: 'demo' }),
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok) throw new Error('Failed assessment');
|
|
40
|
+
const data = await response.json();
|
|
41
|
+
setCard({
|
|
42
|
+
stage: data.assessment.stage,
|
|
43
|
+
name: data.assessment.stageName ?? \`Stage \${data.assessment.stage}\`,
|
|
44
|
+
confidence: data.assessment.confidence,
|
|
45
|
+
recommendation: data.recommendation,
|
|
46
|
+
libraries: data.libraries,
|
|
47
|
+
});
|
|
48
|
+
} catch (err) {
|
|
49
|
+
setError(err instanceof Error ? err.message : 'Unknown error');
|
|
50
|
+
} finally {
|
|
51
|
+
setLoading(false);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Render using your app's design system components in real code.
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
`;
|