Skip to content

Commit

Permalink
fix: interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth committed Nov 8, 2023
1 parent 171c5ac commit 7f31d4f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
16 changes: 4 additions & 12 deletions apps/dashboard/components/api-keys/api-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@ import React from "react"
import { Card, Divider, Typography, Box } from "@mui/joy"

import RevokeKey from "./revoke"
import { formatDate } from "./utils"

interface ApiKey {
id: string
name: string
createdAt: string
expiresAt: string
lastUsedAt?: string | null
createdAt: number
expiresAt: number
lastUsedAt?: number | null | undefined
expired: boolean
revoked: boolean
}

const formatDate = (timestamp: string): string => {
const options: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "long",
day: "2-digit",
}
return new Date(parseInt(timestamp) * 1000).toLocaleDateString(undefined, options)
}

interface ApiKeysCardProps {
activeKeys: ApiKey[]
expiredKeys: ApiKey[]
Expand Down
16 changes: 4 additions & 12 deletions apps/dashboard/components/api-keys/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import Typography from "@mui/joy/Typography"
import Divider from "@mui/joy/Divider"

import RevokeKey from "./revoke"
import { formatDate } from "./utils"

interface ApiKey {
id: string
name: string
createdAt: string
expiresAt: string
lastUsedAt?: string | null
createdAt: number
expiresAt: number
lastUsedAt?: number | null
}

interface ApiKeysListProps {
Expand All @@ -19,15 +20,6 @@ interface ApiKeysListProps {
revokedKeys: ApiKey[]
}

const formatDate = (timestamp: string): string => {
const options: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "long",
day: "2-digit",
}
return new Date(parseInt(timestamp) * 1000).toLocaleDateString(undefined, options)
}

const ApiKeysList: React.FC<ApiKeysListProps> = ({
activeKeys,
expiredKeys,
Expand Down
8 changes: 8 additions & 0 deletions apps/dashboard/components/api-keys/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const formatDate = (timestamp: number): string => {
const options: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "long",
day: "2-digit",
}
return new Date(timestamp * 1000).toLocaleDateString(undefined, options)
}

0 comments on commit 7f31d4f

Please sign in to comment.