fix coderabbit comments

This commit is contained in:
Carl-Gerhard Lindesvärd
2026-01-21 15:31:24 +01:00
parent 3fa1a5429e
commit f9b1ec5038
12 changed files with 44 additions and 15 deletions

View File

@@ -35,7 +35,7 @@ const setCookieFn = createServerFn({ method: 'POST' })
});
// Called in __root.tsx beforeLoad hook to get cookies from the server
// And recieved with useRouteContext in the client
// And received with useRouteContext in the client
export const getCookiesFn = createServerFn({ method: 'GET' }).handler(() =>
pick(VALID_COOKIES, getCookies()),
);

View File

@@ -102,7 +102,7 @@ export default function CreateInvite() {
<div>
<SheetTitle>Invite a user</SheetTitle>
<SheetDescription>
Invite users to your organization. They will recieve an email
Invite users to your organization. They will receive an email
will instructions.
</SheetDescription>
</div>

View File

@@ -20,6 +20,22 @@ const validator = z.object({
type IForm = z.infer<typeof validator>;
/**
* Build explicit boolean values for every key in emailCategories.
* Uses saved preferences when available, falling back to true (opted-in).
*/
function buildCategoryDefaults(
savedPreferences?: Record<string, boolean>,
): Record<string, boolean> {
return Object.keys(emailCategories).reduce(
(acc, category) => {
acc[category] = savedPreferences?.[category] ?? true;
return acc;
},
{} as Record<string, boolean>,
);
}
export const Route = createFileRoute(
'/_app/$organizationId/profile/_tabs/email-preferences',
)({
@@ -37,7 +53,7 @@ function Component() {
const { control, handleSubmit, formState, reset } = useForm<IForm>({
defaultValues: {
categories: preferencesQuery.data,
categories: buildCategoryDefaults(preferencesQuery.data),
},
});
@@ -55,7 +71,7 @@ function Component() {
trpc.email.getPreferences.queryOptions(),
);
reset({
categories: freshData,
categories: buildCategoryDefaults(freshData),
});
},
onError: handleError,
@@ -96,7 +112,7 @@ function Component() {
</div>
</div>
<Switch
checked={field.value ?? true}
checked={field.value}
onCheckedChange={field.onChange}
disabled={mutation.isPending}
/>