From 61a5448ff514f4db44af448b420ee26c1bf22b30 Mon Sep 17 00:00:00 2001 From: pluja Date: Fri, 23 May 2025 12:05:29 +0000 Subject: [PATCH] Release 2025-05-23-5vNZ --- web/scripts/faker.ts | 18 +++++++++++++++++- web/src/actions/admin/service.ts | 31 +++++++++++++++++++------------ 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/web/scripts/faker.ts b/web/scripts/faker.ts index 026784a..7fbc39d 100755 --- a/web/scripts/faker.ts +++ b/web/scripts/faker.ts @@ -859,6 +859,22 @@ const generateFakeServiceContactMethod = (serviceId: number) => { { value: `https://x.com/${faker.internet.username()}`, }, + { + value: `https://matrix.to/#/@${faker.internet.username()}:${faker.internet.domainName()}`, + }, + { + value: `https://instagram.com/${faker.internet.username()}`, + }, + { + value: `https://linkedin.com/in/${faker.helpers.slugify(faker.person.fullName())}`, + }, + { + label: faker.lorem.word({ length: 2 }), + value: `https://bitcointalk.org/index.php?topic=${faker.number.int({ min: 1, max: 1000000 }).toString()}.0`, + }, + { + value: `https://bitcointalk.org/index.php?topic=${faker.number.int({ min: 1, max: 1000000 }).toString()}.0`, + }, { value: faker.internet.url(), }, @@ -867,7 +883,7 @@ const generateFakeServiceContactMethod = (serviceId: number) => { value: faker.internet.url(), }, { - value: `https://www.linkedin.com/company/${faker.helpers.slugify(faker.company.name())}`, + value: `https://linkedin.com/company/${faker.helpers.slugify(faker.company.name())}`, }, ] as const satisfies Partial[] diff --git a/web/src/actions/admin/service.ts b/web/src/actions/admin/service.ts index e64e0db..2266f41 100644 --- a/web/src/actions/admin/service.ts +++ b/web/src/actions/admin/service.ts @@ -18,7 +18,7 @@ const serviceSchemaBase = z.object({ slug: z .string() .regex(/^[a-z0-9-]+$/, 'Allowed characters: lowercase letters, numbers, and hyphens') - .optional(), + .nullable(), name: z.string().min(1).max(20), description: z.string().min(1), serviceUrls: stringListOfUrlsSchemaRequired, @@ -28,12 +28,12 @@ const serviceSchemaBase = z.object({ attributes: z.array(z.coerce.number().int().positive()), categories: z.array(z.coerce.number().int().positive()).min(1), verificationStatus: z.nativeEnum(VerificationStatus), - verificationSummary: z.string().optional().nullable().default(null), - verificationProofMd: z.string().optional().nullable().default(null), + verificationSummary: z.string().nullable(), + verificationProofMd: z.string().nullable(), acceptedCurrencies: z.array(z.nativeEnum(Currency)), - referral: z.string().optional().nullable().default(null), + referral: z.string().nullable(), imageFile: imageFileSchema, - overallScore: zodCohercedNumber(z.number().int().min(0).max(10)).optional(), + overallScore: zodCohercedNumber(z.number().int().min(0).max(10)).nullable(), serviceVisibility: z.nativeEnum(ServiceVisibility), }) @@ -187,13 +187,17 @@ export const adminServiceActions = { accept: 'form', permissions: 'admin', input: z.object({ - label: z.string().min(1).max(50).optional(), + label: z.string().min(1).max(50).nullable(), value: z.string().url(), serviceId: z.number().int().positive(), }), handler: async (input) => { const contactMethod = await prisma.serviceContactMethod.create({ - data: input, + data: { + label: input.label, + value: input.value, + serviceId: input.serviceId, + }, }) return { contactMethod } }, @@ -203,16 +207,19 @@ export const adminServiceActions = { accept: 'form', permissions: 'admin', input: z.object({ - id: z.number().int().positive().optional(), - label: z.string().min(1).max(50).optional(), + id: z.number().int().positive(), + label: z.string().min(1).max(50).nullable(), value: z.string().url(), serviceId: z.number().int().positive(), }), handler: async (input) => { - const { id, ...data } = input const contactMethod = await prisma.serviceContactMethod.update({ - where: { id }, - data, + where: { id: input.id }, + data: { + label: input.label, + value: input.value, + serviceId: input.serviceId, + }, }) return { contactMethod } },