🗓 added last used in api key list

This commit is contained in:
Chirag Bhalotia 2023-06-24 12:10:54 +05:30
parent 880e816d83
commit 4527b564c1
No known key found for this signature in database
GPG Key ID: F7F1F1FBFFD40427
4 changed files with 11 additions and 5 deletions

View File

@ -2,6 +2,7 @@
import api from '@/api';
import Button from '@/components/ui/Button';
import { parseDate } from '@/lib/utils';
import Cookies from 'js-cookie';
import { useRouter } from 'next/navigation';
import React, { useState } from 'react';
@ -47,10 +48,13 @@ function ApiKeyList({ data }: ApiKeyListProps) {
</tr>
</thead>
<tbody className="divide-y p-2">
{apiKeys.map(({ key, keyID }) => (
{apiKeys.map(({ key, keyID, last_used }) => (
<tr className="bg-gray-900 rounded" key={keyID}>
<td className="whitespace-nowrap pl-4 text-sm font-medium text-white">
<p className="text-xl">{key}</p>
<p className="text-xs text-gray-400">
Last Used: {parseDate(last_used)}
</p>
</td>
<td className="relative whitespace-nowrap py-4 px-4 text-right text-sm font-medium icons flex center items-center gap-3">
<Button

View File

@ -1,7 +1,7 @@
import Button from '@/components/ui/Button';
import { ArrowUpRight, Trash } from 'lucide-react';
import React from 'react';
import { cn } from '@/lib/utils';
import { cn, parseDate } from '@/lib/utils';
import { UploadsListComponentProps } from '@/types/list';
export default function LinearList({
@ -10,9 +10,6 @@ export default function LinearList({
onDelete,
}: UploadsListComponentProps) {
// parse a date from gmt format to iso format
const parseDate = (date: string) => {
return new Date(date).toISOString().split('T')[0];
};
return (
<div className="flex flex-col w-full gap-2 ">

View File

@ -4,3 +4,7 @@ import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export const parseDate = (date: string) => {
return new Date(date).toISOString().split('T')[0];
};

View File

@ -1,4 +1,5 @@
interface IApiKey {
key: string;
keyID: string;
last_used: string;
}