Skip to content

Commit

Permalink
fix: frontend build
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitFicus committed Nov 18, 2024
1 parent 1fac2ff commit 1c8cc16
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions izanami-frontend/src/components/TokenForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type AllRightsPesonnalTokenFormType = {
allRights: true;
};

const DEFAULT_RIGHTS_VALUE: TokenTenantRightsArray = [[null, []]] as const;
const DEFAULT_RIGHTS_VALUE: () => TokenTenantRightsArray = () => [[null, []]];

export function tokenRightsToArray(
rights: TokenTenantRights
Expand All @@ -65,7 +65,7 @@ export function TokenForm(props: {
const methods = useForm<PesonnalTokenFormType>({
defaultValues: props.defaultValue ?? {
expiresAt: addYears(new Date(), 1),
rights: DEFAULT_RIGHTS_VALUE,
rights: DEFAULT_RIGHTS_VALUE(),
allRights: false,
},
});
Expand Down Expand Up @@ -131,7 +131,7 @@ export function TokenForm(props: {
if (v?.target?.checked) {
unregister("rights");
} else {
setValue("rights", DEFAULT_RIGHTS_VALUE);
setValue("rights", DEFAULT_RIGHTS_VALUE());
}
onChange(v);
}}
Expand Down
1 change: 1 addition & 0 deletions izanami-frontend/src/pages/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Loader } from "../components/Loader";
import queryClient from "../queryClient";
import { TokensTable } from "../components/TokensTable";
import { TokenForm, tokenRightsToObject } from "../components/TokenForm";
import { TokenTenantRight } from "../utils/types";

export function Profile() {
const ctx = React.useContext(IzanamiContext);
Expand Down
5 changes: 3 additions & 2 deletions izanami-frontend/src/utils/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function createPersonnalAccessToken(
allRights: boolean,
rights: { [tenant: string]: TokenTenantRight[] }
) {
const hasExpiration = expiration && !isNaN(expiration);
const hasExpiration = expiration && !isNaN(expiration?.getTime());
return handleFetchJsonResponse(
fetch(`/api/admin/users/${user}/tokens`, {
method: "POST",
Expand All @@ -167,7 +167,8 @@ export function createPersonnalAccessToken(
}

export function updatePersonnalAccessToken(token: PersonnalAccessToken) {
const hasExpiration = "expiresAt" in token && !isNaN(token.expiresAt);
const hasExpiration =
"expiresAt" in token && !isNaN(token.expiresAt?.getTime());
return handleFetchJsonResponse(
fetch(`/api/admin/users/${token.username}/tokens/${token.id}`, {
method: "PUT",
Expand Down
1 change: 1 addition & 0 deletions izanami-frontend/tests/screenshots/export-import-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export async function generate() {
await screenshot("import-form");
await page.getByLabel("Exported file (ndjson)").setInputFiles(filepath);
await page.getByRole("button", { name: "Import" }).click();
await page.getByRole("button", { name: "Close", exact: true }).click();
await page.getByLabel("Exported file (ndjson)").waitFor({
state: "hidden",
});
Expand Down

0 comments on commit 1c8cc16

Please sign in to comment.