veza/apps/web/src/components/marketplace/modals/LicenceDetailsModal.tsx

136 lines
4.9 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { Button } from '../../ui/button';
import { X, ShieldCheck, Check, XCircle } from 'lucide-react';
import { ProductLicense } from '../../../types';
interface LicenceDetailsModalProps {
license: ProductLicense;
onClose: () => void;
onAddToCart: () => void;
}
function getLicenseDisplay(license: ProductLicense) {
const name = license.license_type
? license.license_type.charAt(0).toUpperCase() + license.license_type.slice(1)
: license.name;
const price = license.price_cents != null ? license.price_cents / 100 : license.price;
const features = license.terms_text
? license.terms_text.split(/\n/).filter(Boolean)
: (license.features ?? []);
return { name, price, features };
}
export const LicenceDetailsModal: React.FC<LicenceDetailsModalProps> = ({
license,
onClose,
onAddToCart,
}) => {
const { name, price, features } = getLicenseDisplay(license);
return (
<div className="fixed inset-0 z-[var(--sumi-z-modal)] flex items-center justify-center p-4">
<div
className="absolute inset-0 bg-background/90 backdrop-blur-sm"
onClick={onClose}
></div>
fix: stabilize builds, tests, and lint across all stacks Complete stabilization pass bringing all 3 stacks to green: Frontend (apps/web/): - Fix TypeScript nullability in useSeason.ts, useTimeOfDay.ts hooks - Disable no-undef in ESLint config (TypeScript handles it; JSX misidentified) - Rename 306 story imports from @storybook/react to @storybook/react-vite - Fix conditional hook call in useMediaQuery.ts useIsTablet - Move useQuery to top of LoginPage.tsx component - Remove useless try/catch in GearFormModal.tsx - Fix stale closure in ResetPasswordPage.tsx handleChange - Make Storybook decorators (withRouter, withQueryClient, withToast, withAudio) no-ops since global StorybookDecorator already provides these — prevents nested Router / duplicate provider crashes in vitest-browser - Fix nested MemoryRouter in 3 page stories (TrackDetail, PlaylistDetail, UserProfile) - Update i18n initialization in test setup (await init before changeLanguage) - Update ~30 test assertions from English to French to match i18n translations - Update test assertions to match SUMI V3 design changes (shadow vs border) - Fix remaining story type errors (PlayerError, PlaylistBatchActions, TrackFilters, VirtualizedChatMessages) Backend (veza-backend-api/): - Fix response_test.go RespondWithAppError signature (2 args, not 3) - Fix TestErrorContractAuthEndpoints expected error codes (ErrCodeUnauthorized vs ErrCodeInvalidCredentials) - Fix TestTrackHandler_GetTrackLikes_Success missing auth middleware setup - Fix TestPlaybackAnalyticsService_GetTrackStats k-anonymity threshold (needs 5 unique users, not 1) - Replace NOW() PostgreSQL function with time.Now() parameter in marketplace service for SQLite test compatibility - Add missing AutoMigrate entries in marketplace_test.go (ProductImage, ProductPreview, ProductLicense, ProductReview) Results: - Frontend TypeCheck: 617 errors -> 0 errors - Frontend ESLint: 349 errors -> 0 errors - Frontend Vitest: 196 failing tests -> 1 skipped (3396/3397 passing) - Backend go vet: 1 error -> 0 errors - Backend tests: 5 failing -> all 13 packages passing - Rust: 150/150 tests passing (unchanged) - Storybook audit: 0 errors across 1244 stories Triage report: docs/TRIAGE_REPORT.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 14:48:07 +00:00
<div className="relative w-full max-w-lg bg-muted rounded-xl shadow-2xl animate-scaleIn overflow-hidden flex flex-col max-h-layout-modal-sm">
<div className="p-4 border-b border-border bg-card flex justify-between items-center">
<h3 className="font-bold text-foreground flex items-center gap-2">
<ShieldCheck className="w-5 h-5 text-muted-foreground" /> License Agreement
</h3>
<button onClick={onClose}>
<X className="w-5 h-5 text-muted-foreground hover:text-foreground" />
</button>
</div>
<div className="p-6 flex-1 overflow-y-auto">
<div className="flex justify-between items-end mb-6">
<div>
<h2 className="text-2xl font-bold text-foreground">
{name} License
</h2>
<p className="text-muted-foreground text-sm">
Review usage rights and restrictions.
</p>
</div>
<div className="text-3xl font-mono font-bold text-muted-foreground">
{price.toFixed(2)}
</div>
</div>
<div className="space-y-6">
<div>
<h4 className="text-sm font-bold text-foreground uppercase tracking-wider mb-3 border-b border-border pb-1">
What You Get
</h4>
<ul className="space-y-2">
{features.map((feat, i) => (
<li
key={i}
className="flex items-start gap-4 text-sm text-foreground"
>
<div className="mt-0.5 bg-success/10 p-0.5 rounded-full">
<Check className="w-3 h-3 text-success" />
</div>
{feat}
</li>
))}
</ul>
</div>
<div>
<h4 className="text-sm font-bold text-foreground uppercase tracking-wider mb-3 border-b border-border pb-1">
Restrictions
</h4>
<ul className="space-y-2">
<li className="flex items-start gap-4 text-sm text-muted-foreground">
<div className="mt-0.5 bg-destructive/10 p-0.5 rounded-full">
<XCircle className="w-3 h-3 text-destructive" />
</div>
Do not resell or redistribute as a sample pack.
</li>
<li className="flex items-start gap-4 text-sm text-muted-foreground">
<div className="mt-0.5 bg-destructive/10 p-0.5 rounded-full">
<XCircle className="w-3 h-3 text-destructive" />
</div>
Content ID registration is prohibited.
</li>
</ul>
</div>
<p className="text-xs text-muted-foreground italic">
This is a simplified summary. Please read the full{' '}
<button
onClick={(e) => {
e.preventDefault();
fix: stabilize builds, tests, and lint across all stacks Complete stabilization pass bringing all 3 stacks to green: Frontend (apps/web/): - Fix TypeScript nullability in useSeason.ts, useTimeOfDay.ts hooks - Disable no-undef in ESLint config (TypeScript handles it; JSX misidentified) - Rename 306 story imports from @storybook/react to @storybook/react-vite - Fix conditional hook call in useMediaQuery.ts useIsTablet - Move useQuery to top of LoginPage.tsx component - Remove useless try/catch in GearFormModal.tsx - Fix stale closure in ResetPasswordPage.tsx handleChange - Make Storybook decorators (withRouter, withQueryClient, withToast, withAudio) no-ops since global StorybookDecorator already provides these — prevents nested Router / duplicate provider crashes in vitest-browser - Fix nested MemoryRouter in 3 page stories (TrackDetail, PlaylistDetail, UserProfile) - Update i18n initialization in test setup (await init before changeLanguage) - Update ~30 test assertions from English to French to match i18n translations - Update test assertions to match SUMI V3 design changes (shadow vs border) - Fix remaining story type errors (PlayerError, PlaylistBatchActions, TrackFilters, VirtualizedChatMessages) Backend (veza-backend-api/): - Fix response_test.go RespondWithAppError signature (2 args, not 3) - Fix TestErrorContractAuthEndpoints expected error codes (ErrCodeUnauthorized vs ErrCodeInvalidCredentials) - Fix TestTrackHandler_GetTrackLikes_Success missing auth middleware setup - Fix TestPlaybackAnalyticsService_GetTrackStats k-anonymity threshold (needs 5 unique users, not 1) - Replace NOW() PostgreSQL function with time.Now() parameter in marketplace service for SQLite test compatibility - Add missing AutoMigrate entries in marketplace_test.go (ProductImage, ProductPreview, ProductLicense, ProductReview) Results: - Frontend TypeCheck: 617 errors -> 0 errors - Frontend ESLint: 349 errors -> 0 errors - Frontend Vitest: 196 failing tests -> 1 skipped (3396/3397 passing) - Backend go vet: 1 error -> 0 errors - Backend tests: 5 failing -> all 13 packages passing - Rust: 150/150 tests passing (unchanged) - Storybook audit: 0 errors across 1244 stories Triage report: docs/TRIAGE_REPORT.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 14:48:07 +00:00
alert("Legal contract preview unavailable in this demo.");
}}
className="text-primary hover:underline bg-transparent border-none p-0 inline cursor-pointer"
>
legal contract
</button>{' '}
before purchasing.
</p>
</div>
</div>
<div className="p-4 border-t border-border bg-card flex justify-end gap-4">
<Button variant="ghost" onClick={onClose}>
Close
</Button>
<Button
variant="primary"
onClick={() => {
onAddToCart();
onClose();
}}
>
Accept and Purchase
</Button>
</div>
</div>
</div>
);
};