1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-03-24 03:55:06 +00:00

feat: add option to renew API key (#1214)

This commit is contained in:
Elias Schneider
2026-01-09 12:08:58 +01:00
committed by GitHub
parent 0a94f0fd64
commit 811e8772b6
16 changed files with 321 additions and 41 deletions

View File

@@ -31,19 +31,6 @@
return new CalendarDate(d.getFullYear(), d.getMonth() + 1, d.getDate());
}
$effect(() => {
if (calendarDisplayDate) {
const newExternalDate = calendarDisplayDate.toDate(getLocalTimeZone());
if (!value || value.getTime() !== newExternalDate.getTime()) {
value = newExternalDate;
}
} else {
if (value !== undefined) {
value = undefined;
}
}
});
$effect(() => {
if (value) {
const newInternalCalendarDate = dateToCalendarDate(value);
@@ -59,6 +46,17 @@
function handleCalendarInteraction(newDateValue?: DateValue) {
open = false;
calendarDisplayDate = newDateValue as CalendarDate | undefined;
if (calendarDisplayDate) {
const newExternalDate = calendarDisplayDate.toDate(getLocalTimeZone());
if (!value || value.getTime() !== newExternalDate.getTime()) {
value = newExternalDate;
}
} else {
if (value !== undefined) {
value = undefined;
}
}
}
const df = new DateFormatter(getLocale(), {
@@ -89,8 +87,7 @@
<Popover.Content class="w-auto p-0" align="start">
<Calendar
type="single"
bind:value={calendarDisplayDate}
onValueChange={handleCalendarInteraction}
bind:value={() => calendarDisplayDate, (newValue) => handleCalendarInteraction(newValue)}
initialFocus
/>
</Popover.Content>

View File

@@ -13,6 +13,13 @@ export default class ApiKeyService extends APIService {
return res.data as ApiKeyResponse;
};
renew = async (id: string, expiresAt: Date): Promise<ApiKeyResponse> => {
const res = await this.api.post(`/api-keys/${id}/renew`, {
expiresAt
});
return res.data as ApiKeyResponse;
};
revoke = async (id: string): Promise<void> => {
await this.api.delete(`/api-keys/${id}`);
};