fix(ui): убрать недостоверную шкалу срока сертификата
This commit is contained in:
1 parent
f99612f6aa
commit
bb74eae64c
3 files changed
+8
-38
No files matched your search
@@ -1,16 +1,9 @@
|
||||
"use client"
|
||||
|
||||
import type { CertificateDto } from "@mmapp/contracts/certificates"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function daysLeftBar(days: number, total = 365): number {
|
||||
if (days <= 0) return 0
|
||||
return Math.min(100, Math.round((days / total) * 100))
|
||||
}
|
||||
|
||||
function CertificateExpandedDetail({ cert }: { cert: CertificateDto }) {
|
||||
const pct = daysLeftBar(cert.daysLeft)
|
||||
|
||||
return (
|
||||
<div className="px-10 pb-4 grid grid-cols-2 sm:grid-cols-4 gap-4 text-xs border-t border-border/50 pt-3">
|
||||
<div>
|
||||
@@ -39,23 +32,8 @@ function CertificateExpandedDetail({ cert }: { cert: CertificateDto }) {
|
||||
{cert.trusted ? "Да (доверенный)" : "Нет (не доверенный)"}
|
||||
</p>
|
||||
</div>
|
||||
<div className="col-span-2 sm:col-span-4">
|
||||
<div className="h-1.5 bg-muted rounded-full overflow-hidden max-w-xs">
|
||||
<div
|
||||
className={cn(
|
||||
"h-full rounded-full",
|
||||
cert.daysLeft < 0 || cert.daysLeft <= 7
|
||||
? "bg-red-500"
|
||||
: cert.daysLeft <= 30
|
||||
? "bg-amber-500"
|
||||
: "bg-emerald-500",
|
||||
)}
|
||||
style={{ width: `${pct}%` }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export { CertificateExpandedDetail, daysLeftBar }
|
||||
export { CertificateExpandedDetail }
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
import { DataGridSortHeader } from "@/components/data-grids/shared/data-grid-sort-header"
|
||||
import {
|
||||
CertificateExpandedDetail,
|
||||
daysLeftBar,
|
||||
} from "@/components/data-grids/certificate-expanded-detail"
|
||||
import { EmptyState } from "@/components/empty-state"
|
||||
import {
|
||||
@@ -65,7 +64,6 @@ function daysLeftColor(days: number): string {
|
||||
}
|
||||
|
||||
function CertDaysCell({ cert }: { cert: CertificateDto }) {
|
||||
const pct = daysLeftBar(cert.daysLeft)
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center justify-between text-xs mb-1">
|
||||
@@ -74,19 +72,6 @@ function CertDaysCell({ cert }: { cert: CertificateDto }) {
|
||||
</span>
|
||||
<span className="text-muted-foreground text-[10px]">{cert.validUntil}</span>
|
||||
</div>
|
||||
<div className="h-1.5 bg-muted rounded-full overflow-hidden">
|
||||
<div
|
||||
className={cn(
|
||||
"h-full rounded-full",
|
||||
cert.daysLeft < 0 || cert.daysLeft <= 7
|
||||
? "bg-red-500"
|
||||
: cert.daysLeft <= 30
|
||||
? "bg-amber-500"
|
||||
: "bg-emerald-500",
|
||||
)}
|
||||
style={{ width: `${pct}%` }}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user