Skip to content

Commit

Permalink
🎨 formatted with biome
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredkiss3 committed Dec 22, 2023
1 parent 7d715d3 commit 0bac009
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 51 deletions.
64 changes: 33 additions & 31 deletions src/actions/user.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,40 @@ import {

import type { FormState } from "~/lib/types";

export const updateUserProfile = withAuth(async (
_previousState: FormState<UpdateUserProfileInfosInput> | AuthError,
formData: FormData,
{ session, currentUser }: AuthState
): Promise<FormState<UpdateUserProfileInfosInput>> => {
const result = updateUserProfileInfosInputValidator.safeParse(
Object.fromEntries(formData)
);
export const updateUserProfile = withAuth(
async (
_previousState: FormState<UpdateUserProfileInfosInput> | AuthError,
formData: FormData,
{ session, currentUser }: AuthState
): Promise<FormState<UpdateUserProfileInfosInput>> => {
const result = updateUserProfileInfosInputValidator.safeParse(
Object.fromEntries(formData)
);

if (!result.success) {
return {
type: "error" as const,
fieldErrors: result.error.flatten().fieldErrors,
formData: {
name: formData.get("name")?.toString() ?? null,
bio: formData.get("bio")?.toString() ?? null,
company: formData.get("company")?.toString() ?? null,
location: formData.get("company")?.toString() ?? null
}
};
}
if (!result.success) {
return {
type: "error" as const,
fieldErrors: result.error.flatten().fieldErrors,
formData: {
name: formData.get("name")?.toString() ?? null,
bio: formData.get("bio")?.toString() ?? null,
company: formData.get("company")?.toString() ?? null,
location: formData.get("company")?.toString() ?? null
}
};
}

await updateUserInfos(result.data, currentUser.id);
await updateUserInfos(result.data, currentUser.id);

await session.addFlash({
type: "success",
message: "Profile updated successfully"
});
await session.addFlash({
type: "success",
message: "Profile updated successfully"
});

revalidatePath(`/`);
return {
type: "success" as const,
message: "Success"
};
});
revalidatePath(`/`);
return {
type: "success" as const,
message: "Success"
};
}
);
4 changes: 2 additions & 2 deletions src/lib/server/session.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ export class Session {
expiry: options?.isBot
? new Date(Date.now() + 5 * 1000) // only five seconds for temporary session
: options?.init?.user
? new Date(Date.now() + LOGGED_IN_SESSION_TTL * 1000)
: new Date(Date.now() + LOGGED_OUT_SESSION_TTL * 1000),
? new Date(Date.now() + LOGGED_IN_SESSION_TTL * 1000)
: new Date(Date.now() + LOGGED_OUT_SESSION_TTL * 1000),
signature,
flashMessages: options?.init?.flashMessages,
additionnalData: options?.init?.additionnalData,
Expand Down
30 changes: 12 additions & 18 deletions src/lib/shared/utils.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,26 +275,20 @@ export function getExcerpt(str: string, maxChars: number): string {
}

const issueSearchFiltersSchema = z.object({
in: preprocess(
(arg) => {
if (Array.isArray(arg)) {
return new Set(arg);
}
return arg;
},
z.set(z.enum(IN_FILTERS)).catch(new Set(IN_FILTERS)).nullish()
),
in: preprocess((arg) => {
if (Array.isArray(arg)) {
return new Set(arg);
}
return arg;
}, z.set(z.enum(IN_FILTERS)).catch(new Set(IN_FILTERS)).nullish()),
is: z.enum(STATUS_FILTERS).default("open").nullish().catch(null),
reason: z.enum(REASON_FILTERS).nullish().catch(null),
no: preprocess(
(arg) => {
if (Array.isArray(arg)) {
return [...new Set(arg)];
}
return arg;
},
z.array(z.enum(NO_METADATA_FILTERS)).catch([]).default([]).nullish()
),
no: preprocess((arg) => {
if (Array.isArray(arg)) {
return [...new Set(arg)];
}
return arg;
}, z.array(z.enum(NO_METADATA_FILTERS)).catch([]).default([]).nullish()),
label: z.array(z.string()).catch([]).default([]).nullish(),
"-label": z.array(z.string()).catch([]).default([]).nullish(),
assignee: z.array(z.string()).catch([]).default([]).nullish(),
Expand Down

0 comments on commit 0bac009

Please sign in to comment.