Files
supabase/apps/studio/components/interfaces/Account/AccessTokens/NewTokenBanner.tsx
bb886317c7 feat(studio): Add expiration date and last used to personal access tokens (#37908)
* feat(studio): Add expiration date and last used to personal access tokens

* Nit polish

* ref: Mark expired tokens as such

* chore: run prettier

* Clean up

* Nit

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: kemal <hello@kemal.earth>
2025-08-20 07:53:51 +02:00

49 lines
1.3 KiB
TypeScript

import { X } from 'lucide-react'
import { toast } from 'sonner'
import { NewAccessToken } from 'data/access-tokens/access-tokens-create-mutation'
import { Button } from 'ui'
import { Admonition } from 'ui-patterns'
import { Input } from 'ui-patterns/DataInputs/Input'
interface NewTokenBannerProps {
token: NewAccessToken
onClose: () => void
}
export const NewTokenBanner = ({ token, onClose }: NewTokenBannerProps) => {
return (
<Admonition
type="default"
className="relative mb-6"
title="Successfully generated a new token!"
description={
<div className="w-full space-y-2">
<p className="text-sm">
Do copy this access token and store it in a secure place - you will not be able to see
it again.
</p>
<div className="max-w-xl">
<Input
copy
readOnly
size="small"
className="max-w-xl input-mono"
value={token.token}
onChange={() => {}}
onCopy={() => toast.success('Token copied to clipboard')}
/>
</div>
</div>
}
>
<Button
type="text"
icon={<X />}
className="w-7 h-7 absolute top-3 right-3"
onClick={onClose}
/>
</Admonition>
)
}