kyd-shared-badge 0.3.134 → 0.3.136

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.134",
3
+ "version": "0.3.136",
4
4
  "private": false,
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -497,66 +497,92 @@ const SharedBadgeDisplay = ({ badgeData, chatProps, headless, selfCheck = false,
497
497
  </div>
498
498
  );
499
499
 
500
- const RiskSection = () => (
501
- <div className={`${wrapperMaxWidth} mx-auto`}>
502
- <div className={'rounded-xl shadow-xl p-6 sm:p-8 mt-6 border'} style={{ backgroundColor: 'var(--content-card-background)', borderColor: 'var(--icon-button-secondary)' }}>
503
- <Reveal headless={isHeadless} as={'h3'} offsetY={8} className={'text-2xl font-bold'} style={{ color: 'var(--text-main)' }}>KYD Risk</Reveal>
504
- <Reveal headless={isHeadless}>
505
- <div className="mt-4">
506
- <GraphInsights
507
- graphInsights={graphInsights}
508
- categories={genreMapping?.['Risk'] as string[]}
509
- genre={'Risk'}
510
- scoringSummary={scoringSummary}
511
- headless={isHeadless}
512
- />
513
- </div>
514
- </Reveal>
515
- <div className="grid grid-cols-1 lg:grid-cols-12 gap-8 w-full items-stretch py-8 kyd-avoid-break" style={{ borderColor: 'var(--icon-button-secondary)' }}>
516
- <Reveal headless={isHeadless} className="lg:col-span-8 h-full">
517
- <CategoryBars
518
- title={'KYD Risk - Category Insights'}
519
- categories={genreMapping?.['Risk'] as string[]}
520
- categoryScores={categoryScores}
521
- barColor={barColor}
522
- getCategoryTooltipCopy={getCategoryTooltipCopy}
523
- barHeight={16}
524
- categoryTargets={roleTargets}
525
- />
526
- </Reveal>
527
- <Reveal headless={isHeadless} className="lg:col-span-4 w-full ml-0 lg:ml-20 hidden lg:flex flex-col items-start justify-start" delayMs={80}>
528
- <div className={'text-sm font-semibold mb-3'} style={{ color: 'var(--text-main)' }}>Top Contributing Factors</div>
529
- <TopContributingFactors categories={genreMapping?.['Risk'] as string[] || []} categoryTopByGraph={categoryTopByGraph as any} />
530
- </Reveal>
531
- </div>
532
- {badgeData.optOutScreening ? (
533
- <Reveal headless={isHeadless} className={'p-4 rounded-lg border mt-6'} style={{ backgroundColor: 'var(--icon-button-secondary)', borderColor: 'var(--icon-button-secondary)' }}>
534
- <div className="flex items-start">
535
- <span className="h-5 w-5 mr-3 mt-0.5 flex-shrink-0" style={{ color: yellow }}>
536
- <FiAlertTriangle size={20} />
537
- </span>
538
- <div>
539
- <h4 className={'font-bold'} style={{ color: 'var(--text-main)' }}>User Opted Out of Screening</h4>
540
- <p className={'text-sm mt-1'} style={{ color: 'var(--text-secondary)' }}>
541
- The user chose not to participate in the automated sanctions and risk screening process. The risk score reflects this decision and is for informational purposes only.
542
- </p>
543
- </div>
500
+ const RiskSection = () => {
501
+ const adjustedCategoryScores = (() => {
502
+ if (!badgeData.optOutScreening) return categoryScores;
503
+ try {
504
+ const copy = { ...categoryScores } as Record<string, any>;
505
+ const key = Object.keys(copy).find(k => /sanctions?.*criminal|sanction|criminal/i.test(k));
506
+ if (key) {
507
+ const prev = copy[key] || {};
508
+ const business = { ...(prev.business || {}), percent_progress_signed: 0, percent_progress: 0 };
509
+ const combined = { ...(prev.combined || {}), percent_progress_signed: 0, percent_progress: 0 };
510
+ copy[key] = { ...prev, business, combined };
511
+ }
512
+ return copy;
513
+ } catch {
514
+ return categoryScores;
515
+ }
516
+ })();
517
+
518
+ const getRiskTooltipCopy = (category: string) => {
519
+ if (badgeData.optOutScreening && /sanction|criminal/i.test(category)) {
520
+ return 'User opted out of screening; score shown as 0.';
521
+ }
522
+ return getCategoryTooltipCopy(category);
523
+ };
524
+
525
+ return (
526
+ <div className={`${wrapperMaxWidth} mx-auto`}>
527
+ <div className={'rounded-xl shadow-xl p-6 sm:p-8 mt-6 border'} style={{ backgroundColor: 'var(--content-card-background)', borderColor: 'var(--icon-button-secondary)' }}>
528
+ <Reveal headless={isHeadless} as={'h3'} offsetY={8} className={'text-2xl font-bold'} style={{ color: 'var(--text-main)' }}>KYD Risk</Reveal>
529
+ <Reveal headless={isHeadless}>
530
+ <div className="mt-4">
531
+ <GraphInsights
532
+ graphInsights={graphInsights}
533
+ categories={genreMapping?.['Risk'] as string[]}
534
+ genre={'Risk'}
535
+ scoringSummary={scoringSummary}
536
+ headless={isHeadless}
537
+ />
544
538
  </div>
545
539
  </Reveal>
546
- ) : (
547
-
548
- <>
549
- <Reveal headless={isHeadless} className={'mb-0 mt-6'}>
550
- <SanctionsMatches ss={assessmentResult?.screening_sources} />
540
+ <div className="grid grid-cols-1 lg:grid-cols-12 gap-8 w-full items-stretch py-8 kyd-avoid-break" style={{ borderColor: 'var(--icon-button-secondary)' }}>
541
+ <Reveal headless={isHeadless} className="lg:col-span-8 h-full">
542
+ <CategoryBars
543
+ title={'KYD Risk - Category Insights'}
544
+ categories={genreMapping?.['Risk'] as string[]}
545
+ categoryScores={adjustedCategoryScores}
546
+ barColor={barColor}
547
+ getCategoryTooltipCopy={getRiskTooltipCopy}
548
+ barHeight={16}
549
+ categoryTargets={roleTargets}
550
+ />
551
551
  </Reveal>
552
- <Reveal headless={isHeadless}>
553
- <IpRiskAnalysisDisplay ipRiskAnalysis={screening_sources?.ip_risk_analysis} />
552
+ <Reveal headless={isHeadless} className="lg:col-span-4 w-full ml-0 lg:ml-20 hidden lg:flex flex-col items-start justify-start" delayMs={80}>
553
+ <div className={'text-sm font-semibold mb-3'} style={{ color: 'var(--text-main)' }}>Top Contributing Factors</div>
554
+ <TopContributingFactors categories={genreMapping?.['Risk'] as string[] || []} categoryTopByGraph={categoryTopByGraph as any} />
554
555
  </Reveal>
555
- </>
556
- )}
556
+ </div>
557
+ {badgeData.optOutScreening ? (
558
+ <Reveal headless={isHeadless} className={'p-4 rounded-lg border mt-6'} style={{ backgroundColor: 'var(--icon-button-secondary)', borderColor: 'var(--icon-button-secondary)' }}>
559
+ <div className="flex items-start">
560
+ <span className="h-5 w-5 mr-3 mt-0.5 flex-shrink-0" style={{ color: yellow }}>
561
+ <FiAlertTriangle size={20} />
562
+ </span>
563
+ <div>
564
+ <h4 className={'font-bold'} style={{ color: 'var(--text-main)' }}>User Opted Out of Screening</h4>
565
+ <p className={'text-sm mt-1'} style={{ color: 'var(--text-secondary)' }}>
566
+ The user chose not to participate in the automated sanctions and risk screening process. The risk score reflects this decision and is for informational purposes only.
567
+ </p>
568
+ </div>
569
+ </div>
570
+ </Reveal>
571
+ ) : (
572
+
573
+ <>
574
+ <Reveal headless={isHeadless} className={'mb-0 mt-6'}>
575
+ <SanctionsMatches ss={assessmentResult?.screening_sources} />
576
+ </Reveal>
577
+ <Reveal headless={isHeadless}>
578
+ <IpRiskAnalysisDisplay ipRiskAnalysis={screening_sources?.ip_risk_analysis} />
579
+ </Reveal>
580
+ </>
581
+ )}
582
+ </div>
557
583
  </div>
558
- </div>
559
- );
584
+ );
585
+ };
560
586
 
561
587
  // const AiSection = () => (
562
588
  // <div className={`${wrapperMaxWidth} mx-auto`}>