5a50d77515
Adds sharing (residence share codes, join, user management, .casera file export/import), subscription status with feature comparison, notification preferences with bell icon, profile settings (edit info, change password, theme picker, delete account), onboarding wizard with create/join paths, enhanced dashboard with stats cards, Recharts completion chart, recent activity feed, and task report PDF download. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { Badge } from "@/components/ui/badge";
|
|
import { differenceInDays } from "date-fns";
|
|
|
|
interface WarrantyStatusProps {
|
|
expiry_date?: string;
|
|
}
|
|
|
|
export function WarrantyStatus({ expiry_date }: WarrantyStatusProps) {
|
|
if (!expiry_date) {
|
|
return <Badge variant="secondary">No expiry</Badge>;
|
|
}
|
|
|
|
const today = new Date();
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
const expiry = new Date(expiry_date);
|
|
expiry.setHours(0, 0, 0, 0);
|
|
|
|
const daysRemaining = differenceInDays(expiry, today);
|
|
|
|
if (daysRemaining < 0) {
|
|
return (
|
|
<Badge variant="destructive">
|
|
Expired {Math.abs(daysRemaining)} {Math.abs(daysRemaining) === 1 ? "day" : "days"} ago
|
|
</Badge>
|
|
);
|
|
}
|
|
|
|
if (daysRemaining <= 30) {
|
|
return (
|
|
<Badge className="bg-yellow-100 text-yellow-800 border-yellow-300 dark:bg-yellow-900/30 dark:text-yellow-400 dark:border-yellow-700">
|
|
Expiring soon ({daysRemaining} {daysRemaining === 1 ? "day" : "days"})
|
|
</Badge>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Badge className="bg-green-100 text-green-800 border-green-300 dark:bg-green-900/30 dark:text-green-400 dark:border-green-700">
|
|
Active ({daysRemaining} {daysRemaining === 1 ? "day" : "days"} left)
|
|
</Badge>
|
|
);
|
|
}
|