mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add default expires at and validation
This commit is contained in:
parent
07c71da88e
commit
c389a48209
2 changed files with 11 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ export interface FormInputProps {
|
|||
required?: boolean
|
||||
css?: any
|
||||
options?: string[]
|
||||
min?: any
|
||||
}
|
||||
|
||||
export const FormInput = styled('input', {
|
||||
|
|
@ -96,6 +97,7 @@ export function GeneralFormInput(props: FormInputProps): JSX.Element {
|
|||
},
|
||||
}}
|
||||
name={input.name}
|
||||
min={input.min}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ export default function ApiKeys(): JSX.Element {
|
|||
return rows
|
||||
}, [apiKeys])
|
||||
|
||||
// default expiry date is 1 year from now
|
||||
const defaultExpiresAt = new Date(Date.now() + 1000 * 60 * 60 * 24 * 365)
|
||||
.toISOString()
|
||||
.split('T')[0]
|
||||
|
||||
applyStoredTheme(false)
|
||||
|
||||
async function onDelete(id: string): Promise<void> {
|
||||
|
|
@ -121,15 +126,17 @@ export default function ApiKeys(): JSX.Element {
|
|||
required: true,
|
||||
},
|
||||
{
|
||||
label: 'Expired at',
|
||||
label: 'Expired on',
|
||||
name: 'expiredAt',
|
||||
required: true,
|
||||
onChange: setExpiresAt,
|
||||
type: 'date',
|
||||
min: new Date().toISOString().split('T')[0], // today
|
||||
value: defaultExpiresAt,
|
||||
},
|
||||
])
|
||||
setName('')
|
||||
setExpiresAt(new Date(Date.now() + 1000 * 60 * 60 * 24 * 365))
|
||||
setExpiresAt(new Date(defaultExpiresAt))
|
||||
setAddModelOpen(true)
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue