Skip to content

Commit

Permalink
feature: Added ending time field on certificates page
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed May 3, 2024
1 parent 68c10d0 commit e632b17
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/pages/settings/advanced/certificates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,37 @@ const AdvancedCertificateSettingsPage: NextPageWithLayout = () => {
title: "Port",
},
{
accessorKey: "updated_at",
accessorKey: "valid_to",
header: ({ column }) => (
<DataTableColumnHeader
column={column}
title={t("advanced.certificates.updated_at")}
/>
<DataTableColumnHeader column={column} title="Bitiş Süresi" />
),
title: t("advanced.certificates.updated_at"),
title: "Bitiş Süresi",
accessorFn: (row) =>
new Date(row.updated_at).toLocaleDateString(i18n.language, {
new Date(row.valid_to).toLocaleDateString(i18n.language, {
day: "2-digit",
month: "long",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
}),
cell: ({ row, getValue }) => (
<>
{/* Add icons for validity time is near 1 month, is not valid and valid states */}
<div className="flex items-center">
{new Date(row.original.valid_to).getTime() - new Date().getTime() <
0 ? (
<div className="mr-2 size-3 rounded-full bg-red-500"></div>
) : new Date(row.original.valid_to).getTime() -
new Date().getTime() <
2592000000 ? (
<div className="mr-2 size-3 rounded-full bg-yellow-500"></div>
) : (
<div className="mr-2 size-3 rounded-full bg-green-500"></div>
)}
{getValue()}
</div>
</>
),
sortingFn: compareNumericString,
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/types/certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export interface ICertificate {
origin: string
created_at: string
updated_at: string
valid_to: string
valid_from: string
}

export interface ICertificateDetails {
Expand Down

0 comments on commit e632b17

Please sign in to comment.