Skip to content

Commit

Permalink
fix(dashboard): api expire (#3613)
Browse files Browse the repository at this point in the history
* fix(dashboard): api expire

* fix: lint

---------

Co-authored-by: Siddharth <[email protected]>
  • Loading branch information
siddhart1o1 and Siddharth authored Nov 28, 2023
1 parent 8dd7aa9 commit e68d354
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
14 changes: 10 additions & 4 deletions apps/dashboard/app/api-keys/server-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ export const createApiKeyServerAction = async (
_prevState: ApiKeyResponse,
form: FormData,
): Promise<ApiKeyResponse> => {
let apiKeyExpiresInDays: number | null = null
const apiKeyName = form.get("apiKeyName")
const readOnly = form.get("apiScope") === "readOnly"
const apiKeyExpiresInDaysSelect = form.get("apiKeyExpiresInDaysSelect")

if (!apiKeyName || typeof apiKeyName !== "string") {
return {
Expand All @@ -62,10 +64,14 @@ export const createApiKeyServerAction = async (
}
}

const apiKeyExpiresInDaysFormData = form.get("apiKeyExpiresInDays")
const apiKeyExpiresInDays = apiKeyExpiresInDaysFormData
? parseInt(String(apiKeyExpiresInDaysFormData))
: null
if (apiKeyExpiresInDaysSelect === "custom") {
const customValue = form.get("apiKeyExpiresInDaysCustom")
apiKeyExpiresInDays = customValue ? parseInt(customValue as string, 10) : null
} else {
apiKeyExpiresInDays = apiKeyExpiresInDaysSelect
? parseInt(apiKeyExpiresInDaysSelect as string, 10)
: null
}

const session = await getServerSession(authOptions)
const token = session?.accessToken
Expand Down
9 changes: 4 additions & 5 deletions apps/dashboard/components/api-keys/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,10 @@ const ApiKeyCreate = () => {
}}
>
<Typography>Expires In</Typography>
<Input
name="apiKeyExpiresInDays"
id="apiKeyExpiresInDays"
sx={{ display: "none", padding: "0.6em" }}
/>
<Select
data-testid="create-api-expire-select"
name="apiKeyExpiresInDaysSelect"
id="apiKeyExpiresInDaysSelect"
sx={{
padding: "0.6em",
}}
Expand Down Expand Up @@ -241,6 +238,8 @@ const ApiKeyCreate = () => {
}}
>
<Input
name="apiKeyExpiresInDaysCustom"
id="apiKeyExpiresInDaysCustom"
sx={{
width: "100%",
padding: "0.6em",
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/services/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ export type TxDirection = typeof TxDirection[keyof typeof TxDirection];
export const TxNotificationType = {
IntraLedgerPayment: 'IntraLedgerPayment',
IntraLedgerReceipt: 'IntraLedgerReceipt',
LnInvoicePaid: 'LnInvoicePaid',
LigtningReceipt: 'LigtningReceipt',
OnchainPayment: 'OnchainPayment',
OnchainReceipt: 'OnchainReceipt',
OnchainReceiptPending: 'OnchainReceiptPending'
Expand Down

0 comments on commit e68d354

Please sign in to comment.