import { ChevronRight } from 'lucide-react';
import type { ComponentType, MouseEvent, ReactNode } from 'react';
import type { ProfileDashboardCardKey } from '../../../packages/shared/src/contracts/runtime';
import {
getHostRuntime,
openHostExternalUrl,
} from '../../services/host-bridge/hostBridge';
import {
ICP_RECORD_NUMBER,
ICP_RECORD_URL,
LEGAL_DOCUMENTS,
type LegalDocumentId,
} from '../common/legalDocuments';
import { PlatformNavigableListItem } from '../common/PlatformNavigableListItem';
type ProfileStatCardProps = {
cardKey: ProfileDashboardCardKey;
label: string;
value: string;
onClick?: ((cardKey: ProfileDashboardCardKey) => void) | null;
icon: ComponentType<{ className?: string }>;
imageSrc?: string;
};
export function ProfileStatCard({
cardKey,
label,
value,
onClick,
icon,
imageSrc,
}: ProfileStatCardProps) {
const Icon = icon;
return (
);
}
export function ProfileStatCardSkeleton() {
return (
);
}
type ProfileShortcutButtonProps = {
label: string;
subLabel?: ReactNode;
icon: ComponentType<{ className?: string }>;
onClick?: (() => void) | null;
imageSrc?: string;
};
export function ProfileShortcutButton({
label,
subLabel,
icon,
onClick,
imageSrc,
}: ProfileShortcutButtonProps) {
const Icon = icon;
return (
);
}
type ProfileSettingsRowProps = {
label: string;
icon: ComponentType<{ className?: string }>;
onClick: () => void;
};
export function ProfileSettingsRow({
label,
icon,
onClick,
}: ProfileSettingsRowProps) {
const Icon = icon;
return (
}
bodyClassName="flex min-w-0 items-center"
trailing={
}
>
{label}
);
}
type ProfileLegalSectionProps = {
onOpenDocument: (documentId: LegalDocumentId) => void;
};
export function ProfileLegalSection({
onOpenDocument,
}: ProfileLegalSectionProps) {
const openIcpRecord = (event: MouseEvent) => {
if (getHostRuntime().kind !== 'native_app') {
return;
}
event.preventDefault();
void openHostExternalUrl({ url: ICP_RECORD_URL }).then((opened) => {
if (!opened) {
window.open(ICP_RECORD_URL, '_blank', 'noreferrer');
}
});
};
return (
);
}