B2B-30: adds personal code to account, company admins invites members
This commit is contained in:
@@ -160,7 +160,7 @@ export const deleteAccountAction = adminAction(
|
||||
*/
|
||||
export const createUserAction = adminAction(
|
||||
enhanceAction(
|
||||
async ({ email, password, emailConfirm }) => {
|
||||
async ({ email, password, emailConfirm, personalCode }) => {
|
||||
const adminClient = getSupabaseServerAdminClient();
|
||||
const logger = await getLogger();
|
||||
|
||||
@@ -182,6 +182,16 @@ export const createUserAction = adminAction(
|
||||
`Super Admin has successfully created a new user`,
|
||||
);
|
||||
|
||||
const { error: accountError } = await adminClient
|
||||
.from('accounts')
|
||||
.update({ personal_code: personalCode })
|
||||
.eq('id', data.user.id);
|
||||
|
||||
if (accountError) {
|
||||
logger.error({ accountError }, 'Error inserting personal code to accounts');
|
||||
throw new Error(`Error saving personal code: ${accountError.message}`);
|
||||
}
|
||||
|
||||
revalidateAdmin();
|
||||
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CreateUserProfileSchema = z.object({
|
||||
personalCode: z.string().regex(/^[1-6]\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}\d$/, {
|
||||
message: 'Invalid Estonian personal code format',
|
||||
}),
|
||||
});
|
||||
|
||||
export type CreateUserProfileSchemaType = z.infer<typeof CreateUserProfileSchema>;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CreateUserSchema = z.object({
|
||||
personalCode: z.string().regex(/^[1-6]\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}\d$/, {
|
||||
message: 'Invalid Estonian personal code format',
|
||||
}),
|
||||
email: z.string().email({ message: 'Please enter a valid email address' }),
|
||||
password: z
|
||||
.string()
|
||||
|
||||
Reference in New Issue
Block a user