style: format code
This commit is contained in:
parent
4cf5ce26ff
commit
29f2a01ac6
5 changed files with 28 additions and 18 deletions
|
@ -65,7 +65,10 @@ export const PATCH = auth(async function PATCH(req) {
|
|||
{ status: 400 },
|
||||
);
|
||||
|
||||
if (dbUser.accounts.length === 0 || dbUser.accounts[0].provider !== 'credentials')
|
||||
if (
|
||||
dbUser.accounts.length === 0 ||
|
||||
dbUser.accounts[0].provider !== 'credentials'
|
||||
)
|
||||
return returnZodTypeCheckedResponse(
|
||||
ErrorResponseSchema,
|
||||
{
|
||||
|
|
|
@ -157,4 +157,4 @@ export const DELETE = auth(async function DELETE(req) {
|
|||
},
|
||||
{ status: 200 },
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,10 +22,12 @@ export const updateUserServerSchema = zod.object({
|
|||
timezone: timezoneSchema.optional(),
|
||||
});
|
||||
|
||||
export const updateUserPasswordServerSchema = zod.object({
|
||||
current_password: zod.string().min(1, 'Current password is required'),
|
||||
new_password: passwordSchema,
|
||||
confirm_new_password: passwordSchema,
|
||||
}).refine((data) => data.new_password === data.confirm_new_password, {
|
||||
message: 'New password and confirm new password must match',
|
||||
});
|
||||
export const updateUserPasswordServerSchema = zod
|
||||
.object({
|
||||
current_password: zod.string().min(1, 'Current password is required'),
|
||||
new_password: passwordSchema,
|
||||
confirm_new_password: passwordSchema,
|
||||
})
|
||||
.refine((data) => data.new_password === data.confirm_new_password, {
|
||||
message: 'New password and confirm new password must match',
|
||||
});
|
||||
|
|
|
@ -113,11 +113,9 @@ export const passwordSchema = zod
|
|||
// Timezone Validation
|
||||
//
|
||||
// ----------------------------------------
|
||||
export const timezoneSchema = zod
|
||||
.enum(allTimeZones)
|
||||
.openapi('Timezone', {
|
||||
description: 'Valid timezone from the list of supported timezones',
|
||||
});
|
||||
export const timezoneSchema = zod.enum(allTimeZones).openapi('Timezone', {
|
||||
description: 'Valid timezone from the list of supported timezones',
|
||||
});
|
||||
|
||||
// ----------------------------------------
|
||||
//
|
||||
|
@ -132,7 +130,10 @@ export const FullUserSchema = zod
|
|||
last_name: zod.string().nullish(),
|
||||
email: zod.email(),
|
||||
image: zod.url().nullish(),
|
||||
timezone: zod.string().refine((i) => (allTimeZones as string[]).includes(i)).nullish(),
|
||||
timezone: zod
|
||||
.string()
|
||||
.refine((i) => (allTimeZones as string[]).includes(i))
|
||||
.nullish(),
|
||||
created_at: zod.date(),
|
||||
updated_at: zod.date(),
|
||||
})
|
||||
|
|
|
@ -3708,6 +3708,10 @@ type TimeZoneIds = (typeof timezoneData)['zones'][number]['id'];
|
|||
type TimeZoneAlias = (typeof timezoneData)['zones'][number]['aliases'][number];
|
||||
export type TimeZones = TimeZoneIds | TimeZoneAlias;
|
||||
|
||||
export const timeZoneIds = timezoneData.zones.map((zone) => zone.id) as TimeZoneIds[];
|
||||
export const timeZoneAliases = timezoneData.zones.flatMap((zone) => zone.aliases) as TimeZoneAlias[];
|
||||
export const allTimeZones = [...timeZoneIds, ...timeZoneAliases] as const;
|
||||
export const timeZoneIds = timezoneData.zones.map(
|
||||
(zone) => zone.id,
|
||||
) as TimeZoneIds[];
|
||||
export const timeZoneAliases = timezoneData.zones.flatMap(
|
||||
(zone) => zone.aliases,
|
||||
) as TimeZoneAlias[];
|
||||
export const allTimeZones = [...timeZoneIds, ...timeZoneAliases] as const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue