prettier fix

This commit is contained in:
Danel Kungla
2025-09-19 17:22:36 +03:00
parent efa94b3322
commit 0c2cfe6d18
509 changed files with 17988 additions and 9920 deletions

View File

@@ -48,7 +48,7 @@ export function AdminCreateUserDialog(props: React.PropsWithChildren) {
email: '',
password: '',
emailConfirm: false,
personalCode: ''
personalCode: '',
},
mode: 'onBlur',
});
@@ -163,7 +163,7 @@ export function AdminCreateUserDialog(props: React.PropsWithChildren) {
<FormField
name={'emailConfirm'}
render={({ field }) => (
<FormItem className="flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4">
<FormItem className="flex flex-row items-start space-y-0 space-x-3 rounded-md border p-4">
<FormControl>
<Checkbox
checked={field.value}

View File

@@ -148,12 +148,17 @@ export const deleteAccountAction = adminAction(
}
const medusa = getAdminSdk();
const { customer_groups } = await medusa.admin.customerGroup.list();
const customerGroup = customer_groups.find(({ name }) => name === customerGroupName);
const customerGroup = customer_groups.find(
({ name }) => name === customerGroupName,
);
if (customerGroup) {
try {
await medusa.admin.customerGroup.delete(customerGroup.id);
} catch (e) {
logger.error({ accountId }, `Error deleting Medusa customer group for company ${customerGroupName}`);
logger.error(
{ accountId },
`Error deleting Medusa customer group for company ${customerGroupName}`,
);
throw e;
}
}
@@ -288,22 +293,29 @@ export const createCompanyAccountAction = enhanceAction(
logger.info(ctx, `Creating Medusa customer group`);
const medusa = getAdminSdk();
const { customer_groups: existingCustomerGroups } = await medusa.admin.customerGroup.list();
const isExisting = existingCustomerGroups.find((group) => group.name === name);
const { customer_groups: existingCustomerGroups } =
await medusa.admin.customerGroup.list();
const isExisting = existingCustomerGroups.find(
(group) => group.name === name,
);
if (isExisting) {
logger.info(ctx, `Customer group already exists`);
} else {
logger.info(ctx, `Creating Medusa customer group`);
const { data: account } = await client
.schema('medreport').from('accounts')
.schema('medreport')
.from('accounts')
.select('medusa_account_id')
.eq('personal_code', ownerPersonalCode)
.single().throwOnError();
.single()
.throwOnError();
const medusaAccountId = account.medusa_account_id;
if (!medusaAccountId) {
logger.error(ctx, `User has no Medusa account ID`);
} else {
const { customer_group: { id: customerGroupId } } = await medusa.admin.customerGroup.create({ name });
const {
customer_group: { id: customerGroupId },
} = await medusa.admin.customerGroup.create({ name });
const { customers } = await medusa.admin.customer.list({
id: medusaAccountId,
});
@@ -316,7 +328,6 @@ export const createCompanyAccountAction = enhanceAction(
});
}
}
}
redirect(`/admin/accounts/${data.id}`);

View File

@@ -1,10 +1,13 @@
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',
}),
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>;
export type CreateUserProfileSchemaType = z.infer<
typeof CreateUserProfileSchema
>;

View File

@@ -1,9 +1,11 @@
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',
}),
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()

View File

@@ -44,7 +44,8 @@ class AdminAccountsService {
.from('accounts')
.select('*')
.eq('id', accountId)
.single().throwOnError();
.single()
.throwOnError();
return data;
}

View File

@@ -1,8 +1,9 @@
import Medusa from "@medusajs/js-sdk"
import Medusa from '@medusajs/js-sdk';
export const getAdminSdk = () => {
const medusaBackendUrl = process.env.MEDUSA_BACKEND_PUBLIC_URL!;
const medusaPublishableApiKey = process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY!;
const medusaPublishableApiKey =
process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY!;
const key = process.env.MEDUSA_SECRET_API_KEY!;
if (!medusaBackendUrl || !medusaPublishableApiKey) {
@@ -13,4 +14,4 @@ export const getAdminSdk = () => {
debug: process.env.NODE_ENV === 'development',
apiKey: key,
});
}
};

View File

@@ -4,7 +4,5 @@
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
},
"include": ["*.ts", "src"],
"exclude": [
"node_modules"
]
"exclude": ["node_modules"]
}