kyd-shared-badge 0.3.31 → 0.3.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kyd-shared-badge",
3
- "version": "0.3.31",
3
+ "version": "0.3.33",
4
4
  "private": false,
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -263,7 +263,7 @@ const SharedBadgeDisplay = ({ badgeData, chatProps, headless }: { badgeData: Pub
263
263
 
264
264
  {/* Enterprise Use Cases (directly under the three summary cards) */}
265
265
  {assessmentResult?.enterprise_use_cases?.items && assessmentResult.enterprise_use_cases.items.length > 0 && (
266
- <UseCases useCases={assessmentResult.enterprise_use_cases} headless={isHeadless} />
266
+ <UseCases useCases={assessmentResult.enterprise_use_cases} headless={isHeadless} badgeId={badgeId} />
267
267
  )}
268
268
 
269
269
  {/* Technical Scores */}
@@ -2,22 +2,34 @@
2
2
 
3
3
  import Reveal from './Reveal';
4
4
  import { EnterpriseUseCases, UseCaseItem } from '../types';
5
+ import Image from 'next/image';
5
6
 
6
- export default function UseCases({ useCases, headless }: { useCases?: EnterpriseUseCases | null; headless?: boolean }) {
7
+ export default function UseCases({ useCases, headless, badgeId }: { useCases?: EnterpriseUseCases | null; headless?: boolean; badgeId?: string }) {
7
8
  if (!useCases || !Array.isArray(useCases.items) || useCases.items.length === 0) return null;
8
9
 
9
10
  const items: UseCaseItem[] = useCases.items.slice(0, 4);
10
11
  const note = (useCases.note || '').trim();
11
12
 
12
- // Fallback: derive a stable pseudo-random index (1-9) if backend hasn't set one
13
- const fallbackIndex = (uc: UseCaseItem, idx: number) => {
14
- if (typeof uc.image_index === 'number' && uc.image_index >= 1 && uc.image_index <= 9) return uc.image_index;
15
- const seed = `${uc.title}|${uc.demonstrated_capability}|${idx}`;
13
+ // Generate unique indices (1-9) for each use case, ensuring no repeats
14
+ const usedIndices = new Set<number>();
15
+ const getUniqueIndex = (idx: number) => {
16
+ const seed = `${badgeId || ''}|${idx}`;
16
17
  let hash = 0;
17
18
  for (let i = 0; i < seed.length; i++) {
18
19
  hash = (hash * 31 + seed.charCodeAt(i)) >>> 0;
19
20
  }
20
- return (hash % 9) + 1;
21
+ let baseIndex = (hash % 9) + 1;
22
+
23
+ // If base index is already used, find next available
24
+ let finalIndex = baseIndex;
25
+ let attempts = 0;
26
+ while (usedIndices.has(finalIndex) && attempts < 9) {
27
+ finalIndex = ((finalIndex) % 9) + 1;
28
+ attempts++;
29
+ }
30
+
31
+ usedIndices.add(finalIndex);
32
+ return finalIndex;
21
33
  };
22
34
 
23
35
  return (
@@ -26,15 +38,14 @@ export default function UseCases({ useCases, headless }: { useCases?: Enterprise
26
38
  <h3 className={'text-2xl font-semibold mb-3'} style={{ color: 'var(--text-main)' }}>Potential Use Cases</h3>
27
39
  <div className={'grid grid-cols-1 md:grid-cols-2 gap-4'}>
28
40
  {items.map((uc, idx) => {
29
- const imgIndex = fallbackIndex(uc, idx);
41
+ const imgIndex = getUniqueIndex(idx);
30
42
  const imgSrc = `/badge/puzzle${imgIndex}.svg`;
31
43
  return (
32
44
  <div key={idx} className={'rounded-md p-5 border'} style={{ backgroundColor: 'var(--content-card-background)', borderColor: 'var(--icon-button-secondary)' }}>
33
- <div className={'flex items-start gap-3'}>
34
- <img src={imgSrc} alt={''} width={36} height={36} style={{ flexShrink: 0 }} />
45
+ <div className={'flex items-center gap-3 pb-2'}>
46
+ <Image src={imgSrc} alt={''} width={36} height={36} style={{ flexShrink: 0 }} />
35
47
  <div className={'font-semibold'} style={{ color: 'var(--text-main)' }}>{uc.title}</div>
36
48
  </div>
37
- <div className={'font-semibold'} style={{ color: 'var(--text-main)' }}>{uc.title}</div>
38
49
  {uc.potential_impact ? (
39
50
  <div className={'text-sm mt-2'} style={{ color: 'var(--text-secondary)' }}>
40
51
  <span className={'font-medium'} style={{ color: 'var(--text-main)' }}>Potential Impact: </span>
package/src/types.ts CHANGED
@@ -181,8 +181,6 @@ export interface UseCaseItem {
181
181
  potential_impact: string;
182
182
  demonstrated_capability: string;
183
183
  justification: string;
184
- // Optional deterministic image index (1-9) assigned by backend
185
- image_index?: number;
186
184
  }
187
185
 
188
186
  export interface EnterpriseUseCases {