Compare commits

...

16 Commits

Author SHA1 Message Date
pluja
9285d952a5 Release 202507281850 2025-07-28 18:50:07 +00:00
pluja
fd5c7ab475 Release 202507240432 2025-07-24 04:32:40 +00:00
pluja
9a78a9b377 Release 202507231133 2025-07-23 11:33:11 +00:00
pluja
9e0193fc3c Release 202507092007 2025-07-09 20:07:42 +00:00
pluja
a68523fc73 Release 202507090857 2025-07-09 08:57:55 +00:00
pluja
a465849a76 Release 202507080951 2025-07-08 09:51:46 +00:00
pluja
25f6dba3eb Release 202507080939 2025-07-08 09:39:11 +00:00
pluja
7e7046e7d2 Release 202507080931 2025-07-08 09:31:10 +00:00
pluja
a5d1fb9a5d Release 202507061906 2025-07-06 19:06:17 +00:00
pluja
28b84a7d9b Release 202507061859 2025-07-06 18:59:23 +00:00
pluja
7a294cb0a1 Release 202507061803 2025-07-06 18:03:45 +00:00
pluja
349c26a4df Release 202507031546 2025-07-03 15:46:21 +00:00
pluja
86b1afb2c7 Release 202507031255 2025-07-03 12:55:03 +00:00
pluja
99bc1f4e0f Release 202507031129 2025-07-03 11:29:46 +00:00
pluja
3166349dfb Release 202507031117 2025-07-03 11:17:39 +00:00
pluja
5a54352d95 Release 202507031107 2025-07-03 11:07:41 +00:00
46 changed files with 1933 additions and 1161 deletions

View File

@@ -7,7 +7,8 @@
"golang.go", "golang.go",
"bradlc.vscode-tailwindcss", "bradlc.vscode-tailwindcss",
"craigrbroughton.htmx-attributes", "craigrbroughton.htmx-attributes",
"nefrob.vscode-just-syntax" "nefrob.vscode-just-syntax",
"prisma.prisma"
], ],
"unwantedRecommendations": [] "unwantedRecommendations": []
} }

View File

@@ -1 +1 @@
23 24

View File

@@ -14,6 +14,8 @@ import { postgresListener } from './src/lib/postgresListenerIntegration'
import { getServerEnvVariable } from './src/lib/serverEnvVariables' import { getServerEnvVariable } from './src/lib/serverEnvVariables'
const SITE_URL = getServerEnvVariable('SITE_URL') const SITE_URL = getServerEnvVariable('SITE_URL')
const ONION_ADDRESS = getServerEnvVariable('ONION_ADDRESS')
const I2P_ADDRESS = getServerEnvVariable('I2P_ADDRESS')
export default defineConfig({ export default defineConfig({
site: SITE_URL, site: SITE_URL,
@@ -95,6 +97,19 @@ export default defineConfig({
server: { server: {
open: false, open: false,
allowedHosts: [new URL(SITE_URL).hostname], allowedHosts: [new URL(SITE_URL).hostname],
headers: {
'Onion-Location': ONION_ADDRESS,
'X-I2P-Location': I2P_ADDRESS,
'X-Frame-Options': 'DENY',
// Astro is working on this feature, when it's stable use it instead of this.
// https://astro.build/blog/astro-590/#experimental-content-security-policy-support
'Content-Security-Policy':
SITE_URL === 'http://localhost:4321'
? "frame-ancestors 'none'; upgrade-insecure-requests"
: "default-src 'self'; img-src 'self' *; frame-ancestors 'none'; upgrade-insecure-requests",
'Strict-Transport-Security':
SITE_URL === 'http://localhost:4321' ? undefined : 'max-age=31536000; includeSubdomains; preload;',
},
}, },
image: { image: {
domains: [new URL(SITE_URL).hostname], domains: [new URL(SITE_URL).hostname],

661
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -27,23 +27,26 @@
"@astrojs/check": "0.9.4", "@astrojs/check": "0.9.4",
"@astrojs/db": "0.15.0", "@astrojs/db": "0.15.0",
"@astrojs/mdx": "4.3.0", "@astrojs/mdx": "4.3.0",
"@astrojs/node": "9.2.2", "@astrojs/node": "9.3.0",
"@astrojs/rss": "4.0.12", "@astrojs/rss": "4.0.12",
"@astrojs/sitemap": "3.4.1", "@astrojs/sitemap": "3.4.1",
"@fontsource-variable/space-grotesk": "5.2.8", "@fontsource-variable/space-grotesk": "5.2.8",
"@fontsource/inter": "5.2.6", "@fontsource/inter": "5.2.6",
"@fontsource/space-grotesk": "5.2.8", "@fontsource/space-grotesk": "5.2.8",
"@prisma/client": "6.10.1", "@prisma/client": "6.11.1",
"@tailwindcss/vite": "4.1.11", "@tailwindcss/vite": "4.1.11",
"@types/mime-types": "3.0.1", "@types/mime-types": "3.0.1",
"@types/pg": "8.15.4", "@types/pg": "8.15.4",
"@vercel/og": "0.6.8", "@vercel/og": "0.7.2",
"astro": "5.10.1", "astro": "5.9.0",
"astro-loading-indicator": "0.7.0", "astro-loading-indicator": "0.7.0",
"astro-remote": "0.3.4", "astro-remote": "0.3.4",
"astro-seo-schema": "5.0.0", "astro-seo-schema": "5.0.0",
"canvas": "3.1.2", "canvas": "3.1.2",
"clsx": "2.1.1", "clsx": "2.1.1",
"countries-list": "3.1.1",
"country-flag-icons": "1.5.19",
"he": "1.2.0",
"htmx.org": "2.0.6", "htmx.org": "2.0.6",
"javascript-time-ago": "2.5.11", "javascript-time-ago": "2.5.11",
"libphonenumber-js": "1.12.9", "libphonenumber-js": "1.12.9",
@@ -53,7 +56,7 @@
"pg": "8.16.3", "pg": "8.16.3",
"qrcode": "1.5.4", "qrcode": "1.5.4",
"react": "19.1.0", "react": "19.1.0",
"redis": "5.5.6", "redis": "5.6.0",
"schema-dts": "1.1.5", "schema-dts": "1.1.5",
"seedrandom": "3.0.5", "seedrandom": "3.0.5",
"sharp": "0.34.2", "sharp": "0.34.2",
@@ -66,42 +69,43 @@
"web-push": "3.6.7" "web-push": "3.6.7"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "9.30.0", "@eslint/js": "9.30.1",
"@faker-js/faker": "9.8.0", "@faker-js/faker": "9.9.0",
"@iconify-json/material-symbols": "1.2.28", "@iconify-json/material-symbols": "1.2.29",
"@iconify-json/mdi": "1.2.3", "@iconify-json/mdi": "1.2.3",
"@iconify-json/ri": "1.2.5", "@iconify-json/ri": "1.2.5",
"@stylistic/eslint-plugin": "5.1.0", "@stylistic/eslint-plugin": "5.1.0",
"@tailwindcss/forms": "0.5.10", "@tailwindcss/forms": "0.5.10",
"@tailwindcss/typography": "0.5.16", "@tailwindcss/typography": "0.5.16",
"@types/eslint__js": "9.14.0", "@types/eslint__js": "9.14.0",
"@types/he": "1.2.3",
"@types/lodash-es": "4.17.12", "@types/lodash-es": "4.17.12",
"@types/qrcode": "1.5.5", "@types/qrcode": "1.5.5",
"@types/react": "19.1.8", "@types/react": "19.1.8",
"@types/seedrandom": "3.0.8", "@types/seedrandom": "3.0.8",
"@types/web-push": "3.6.4", "@types/web-push": "3.6.4",
"@typescript-eslint/parser": "8.35.1", "@typescript-eslint/parser": "8.36.0",
"@vite-pwa/assets-generator": "1.0.0", "@vite-pwa/assets-generator": "1.0.0",
"@vite-pwa/astro": "1.1.0", "@vite-pwa/astro": "1.1.0",
"astro-icon": "1.1.5", "astro-icon": "1.1.5",
"date-fns": "4.1.0", "date-fns": "4.1.0",
"esbuild": "0.25.5", "esbuild": "0.25.6",
"eslint": "9.30.0", "eslint": "9.30.1",
"eslint-import-resolver-typescript": "4.4.4", "eslint-import-resolver-typescript": "4.4.4",
"eslint-plugin-astro": "1.3.1", "eslint-plugin-astro": "1.3.1",
"eslint-plugin-import": "2.32.0", "eslint-plugin-import": "2.32.0",
"eslint-plugin-jsx-a11y": "6.10.2", "eslint-plugin-jsx-a11y": "6.10.2",
"globals": "16.2.0", "globals": "16.3.0",
"prettier": "3.6.2", "prettier": "3.6.2",
"prettier-plugin-astro": "0.14.1", "prettier-plugin-astro": "0.14.1",
"prettier-plugin-tailwindcss": "0.6.13", "prettier-plugin-tailwindcss": "0.6.13",
"prisma": "6.10.1", "prisma": "6.11.1",
"prisma-json-types-generator": "3.5.0", "prisma-json-types-generator": "3.5.1",
"tailwind-htmx": "0.1.2", "tailwind-htmx": "0.1.2",
"ts-essentials": "10.1.1", "ts-essentials": "10.1.1",
"ts-toolbelt": "9.6.0", "ts-toolbelt": "9.6.0",
"tsx": "4.20.3", "tsx": "4.20.3",
"typescript-eslint": "8.35.1", "typescript-eslint": "8.36.0",
"vite-plugin-devtools-json": "0.2.1", "vite-plugin-devtools-json": "0.2.1",
"workbox-core": "7.3.0", "workbox-core": "7.3.0",
"workbox-precaching": "7.3.0" "workbox-precaching": "7.3.0"

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Service" ADD COLUMN "strictCommentingEnabled" BOOLEAN NOT NULL DEFAULT false;

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Service" ADD COLUMN "commentSectionMessage" TEXT;

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Service" ADD COLUMN "registrationCountryCode" VARCHAR(2);

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Service" ADD COLUMN "registeredCompanyName" TEXT;

View File

@@ -345,60 +345,64 @@ model ServiceSuggestionMessage {
} }
model Service { model Service {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
name String name String
slug String @unique slug String @unique
previousSlugs String[] @default([]) previousSlugs String[] @default([])
description String description String
categories Category[] @relation("ServiceToCategory") categories Category[] @relation("ServiceToCategory")
kycLevel Int @default(4) kycLevel Int @default(4)
kycLevelClarification KycLevelClarification @default(NONE) kycLevelClarification KycLevelClarification @default(NONE)
/// Date only, no time. /// Date only, no time.
operatingSince DateTime? @db.Date operatingSince DateTime? @db.Date
overallScore Int @default(0) overallScore Int @default(0)
privacyScore Int @default(0) privacyScore Int @default(0)
trustScore Int @default(0) trustScore Int @default(0)
/// Computed via trigger. Do not update through prisma. /// Computed via trigger. Do not update through prisma.
averageUserRating Float? averageUserRating Float?
serviceVisibility ServiceVisibility @default(PUBLIC) serviceVisibility ServiceVisibility @default(PUBLIC)
serviceInfoBanner ServiceInfoBanner @default(NONE) serviceInfoBanner ServiceInfoBanner @default(NONE)
serviceInfoBannerNotes String? serviceInfoBannerNotes String?
verificationStatus VerificationStatus @default(COMMUNITY_CONTRIBUTED) verificationStatus VerificationStatus @default(COMMUNITY_CONTRIBUTED)
verificationSummary String? verificationSummary String?
verificationRequests ServiceVerificationRequest[] verificationRequests ServiceVerificationRequest[]
verificationProofMd String? verificationProofMd String?
/// [UserSentiment] /// [UserSentiment]
userSentiment Json? userSentiment Json?
userSentimentAt DateTime? userSentimentAt DateTime?
referral String? referral String?
acceptedCurrencies Currency[] @default([]) acceptedCurrencies Currency[] @default([])
serviceUrls String[] serviceUrls String[]
tosUrls String[] @default([]) tosUrls String[] @default([])
onionUrls String[] @default([]) onionUrls String[] @default([])
i2pUrls String[] @default([]) i2pUrls String[] @default([])
imageUrl String? imageUrl String?
/// ISO 3166-1 alpha-2 country code where the service company is registered
registrationCountryCode String? @db.VarChar(2)
/// Official name of the registered company
registeredCompanyName String?
/// [TosReview] /// [TosReview]
tosReview Json? tosReview Json?
tosReviewAt DateTime? tosReviewAt DateTime?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt updatedAt DateTime @default(now()) @updatedAt
/// Computed via trigger when the visibility is PUBLIC or (ARCHIVED and listedAt was null). Do not update through prisma. /// Computed via trigger when the visibility is PUBLIC or (ARCHIVED and listedAt was null). Do not update through prisma.
listedAt DateTime? listedAt DateTime?
/// Computed via trigger when the verification status is APPROVED. Do not update through prisma. /// Computed via trigger when the verification status is APPROVED. Do not update through prisma.
approvedAt DateTime? approvedAt DateTime?
/// Computed via trigger when the verification status is VERIFICATION_SUCCESS. Do not update through prisma. /// Computed via trigger when the verification status is VERIFICATION_SUCCESS. Do not update through prisma.
verifiedAt DateTime? verifiedAt DateTime?
/// Computed via trigger when the verification status is VERIFICATION_FAILED. Do not update through prisma. /// Computed via trigger when the verification status is VERIFICATION_FAILED. Do not update through prisma.
spamAt DateTime? spamAt DateTime?
/// Computed via trigger. Do not update through prisma. /// Computed via trigger. Do not update through prisma.
isRecentlyApproved Boolean @default(false) isRecentlyApproved Boolean @default(false)
comments Comment[] comments Comment[]
events Event[] events Event[]
contactMethods ServiceContactMethod[] @relation("ServiceToContactMethod") contactMethods ServiceContactMethod[] @relation("ServiceToContactMethod")
attributes ServiceAttribute[] attributes ServiceAttribute[]
verificationSteps VerificationStep[] verificationSteps VerificationStep[]
suggestions ServiceSuggestion[] suggestions ServiceSuggestion[]
internalNotes InternalServiceNote[] @relation("ServiceRecievedNotes") internalNotes InternalServiceNote[] @relation("ServiceRecievedNotes")
onEventCreatedForServices NotificationPreferences[] @relation("onEventCreatedForServices") onEventCreatedForServices NotificationPreferences[] @relation("onEventCreatedForServices")
onRootCommentCreatedForServices NotificationPreferences[] @relation("onRootCommentCreatedForServices") onRootCommentCreatedForServices NotificationPreferences[] @relation("onRootCommentCreatedForServices")
@@ -406,6 +410,9 @@ model Service {
Notification Notification[] Notification Notification[]
affiliatedUsers ServiceUser[] @relation("ServiceUsers") affiliatedUsers ServiceUser[] @relation("ServiceUsers")
strictCommentingEnabled Boolean @default(false)
commentSectionMessage String?
@@index([listedAt]) @@index([listedAt])
@@index([approvedAt]) @@index([approvedAt])
@@index([verifiedAt]) @@index([verifiedAt])

View File

@@ -28,6 +28,7 @@ import { generateUsername } from 'unique-username-generator'
import { kycLevels } from '../src/constants/kycLevels' import { kycLevels } from '../src/constants/kycLevels'
import { undefinedIfEmpty } from '../src/lib/arrays' import { undefinedIfEmpty } from '../src/lib/arrays'
import { transformCase } from '../src/lib/strings' import { transformCase } from '../src/lib/strings'
import { countries } from '../src/constants/countries'
// Exit if not in development mode // Exit if not in development mode
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
@@ -697,6 +698,12 @@ const generateFakeService = (users: User[]) => {
{ count: { min: 0, max: 2 } } { count: { min: 0, max: 2 } }
), ),
imageUrl: `https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=random&format=svg`, imageUrl: `https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=random&format=svg`,
registrationCountryCode: faker.helpers.maybe(() => faker.helpers.arrayElement(countries).code, {
probability: 0.7,
}),
registeredCompanyName: faker.helpers.maybe(() => faker.company.name(), {
probability: 0.6,
}),
listedAt: listedAt:
serviceVisibility === 'PUBLIC' || serviceVisibility === 'ARCHIVED' serviceVisibility === 'PUBLIC' || serviceVisibility === 'ARCHIVED'
? faker.date.recent({ days: 30 }) ? faker.date.recent({ days: 30 })
@@ -720,6 +727,8 @@ const generateFakeService = (users: User[]) => {
}), }),
{ probability: 0.33 } { probability: 0.33 }
), ),
strictCommentingEnabled: faker.datatype.boolean(0.33333),
commentSectionMessage: faker.helpers.maybe(() => faker.lorem.paragraph(), { probability: 0.3 }),
} as const satisfies Prisma.ServiceCreateInput } as const satisfies Prisma.ServiceCreateInput
} }

View File

@@ -283,7 +283,7 @@ BEGIN
-- and ensure it wasn't already APPROVED. -- and ensure it wasn't already APPROVED.
IF OLD.status IS DISTINCT FROM 'APPROVED' AND NEW.status = 'APPROVED' THEN IF OLD.status IS DISTINCT FROM 'APPROVED' AND NEW.status = 'APPROVED' THEN
-- Fetch service details for the description -- Fetch service details for the description
SELECT name, visibility INTO service_name, service_visibility FROM "Service" WHERE id = NEW."serviceId"; SELECT name, "serviceVisibility" INTO service_name, service_visibility FROM "Service" WHERE id = NEW."serviceId";
-- Only award karma if the service is public -- Only award karma if the service is public
IF service_visibility = 'PUBLIC' THEN IF service_visibility = 'PUBLIC' THEN

View File

@@ -96,6 +96,7 @@ DECLARE
recently_approved_factor INT := 0; recently_approved_factor INT := 0;
tos_penalty_factor INT := 0; tos_penalty_factor INT := 0;
operating_since_factor INT := 0; operating_since_factor INT := 0;
legally_registered_factor INT := 0;
BEGIN BEGIN
-- Get verification status factor -- Get verification status factor
SELECT SELECT
@@ -160,9 +161,17 @@ BEGIN
INTO operating_since_factor INTO operating_since_factor
FROM "Service" FROM "Service"
WHERE id = service_id; WHERE id = service_id;
-- Check for legal registration (country code or company name)
IF EXISTS (
SELECT 1 FROM "Service"
WHERE id = service_id AND ("registrationCountryCode" IS NOT NULL OR "registeredCompanyName" IS NOT NULL)
) THEN
legally_registered_factor := 2;
END IF;
-- Calculate final trust score (base 100) -- Calculate final trust score (base 100)
trust_score := 50 + verification_factor + attributes_score + recently_approved_factor + tos_penalty_factor + operating_since_factor; trust_score := 50 + verification_factor + attributes_score + recently_approved_factor + tos_penalty_factor + operating_since_factor + legally_registered_factor;
-- Ensure the score is in reasonable bounds (0-100) -- Ensure the score is in reasonable bounds (0-100)
trust_score := GREATEST(0, LEAST(100, trust_score)); trust_score := GREATEST(0, LEAST(100, trust_score));

View File

@@ -4,12 +4,14 @@ import { ActionError } from 'astro:actions'
import { uniq } from 'lodash-es' import { uniq } from 'lodash-es'
import slugify from 'slugify' import slugify from 'slugify'
import { countriesZodEnumById } from '../../constants/countries'
import { defineProtectedAction } from '../../lib/defineProtectedAction' import { defineProtectedAction } from '../../lib/defineProtectedAction'
import { saveFileLocally, deleteFileLocally } from '../../lib/fileStorage' import { saveFileLocally, deleteFileLocally } from '../../lib/fileStorage'
import { prisma } from '../../lib/prisma' import { prisma } from '../../lib/prisma'
import { separateServiceUrlsByType } from '../../lib/urls' import { separateServiceUrlsByType } from '../../lib/urls'
import { import {
imageFileSchema, imageFileSchema,
stringListOfContactMethodsSchema,
stringListOfUrlsSchemaRequired, stringListOfUrlsSchemaRequired,
zodCohercedNumber, zodCohercedNumber,
zodContactMethod, zodContactMethod,
@@ -44,6 +46,7 @@ const serviceSchemaBase = z.object({
description: z.string().min(1), description: z.string().min(1),
allServiceUrls: stringListOfUrlsSchemaRequired, allServiceUrls: stringListOfUrlsSchemaRequired,
tosUrls: stringListOfUrlsSchemaRequired, tosUrls: stringListOfUrlsSchemaRequired,
contactMethods: stringListOfContactMethodsSchema,
kycLevel: z.coerce.number().int().min(0).max(4), kycLevel: z.coerce.number().int().min(0).max(4),
kycLevelClarification: z.nativeEnum(KycLevelClarification).optional().nullable().default(null), kycLevelClarification: z.nativeEnum(KycLevelClarification).optional().nullable().default(null),
attributes: z.array(z.coerce.number().int().positive()), attributes: z.array(z.coerce.number().int().positive()),
@@ -51,7 +54,7 @@ const serviceSchemaBase = z.object({
verificationStatus: z.nativeEnum(VerificationStatus), verificationStatus: z.nativeEnum(VerificationStatus),
verificationSummary: z.string().optional().nullable().default(null), verificationSummary: z.string().optional().nullable().default(null),
verificationProofMd: z.string().optional().nullable().default(null), verificationProofMd: z.string().optional().nullable().default(null),
acceptedCurrencies: z.array(z.nativeEnum(Currency)), acceptedCurrencies: z.array(z.nativeEnum(Currency)).min(1),
referral: z referral: z
.string() .string()
.regex(/^(\?\w+=.|\/.+)/, 'Referral must be a valid URL parameter or path, not a full URL') .regex(/^(\?\w+=.|\/.+)/, 'Referral must be a valid URL parameter or path, not a full URL')
@@ -59,10 +62,19 @@ const serviceSchemaBase = z.object({
.nullable() .nullable()
.default(null), .default(null),
operatingSince: z.coerce.date().optional().nullable(), operatingSince: z.coerce.date().optional().nullable(),
registrationCountryCode: z
.union([countriesZodEnumById, z.literal('')])
.optional()
.nullable()
.refine((val) => val === null || val === undefined || val === '' || val.length === 2, {
message: 'Country code must be a valid 2-character code or empty',
}),
registeredCompanyName: z.string().trim().max(100).optional().nullable(),
imageFile: imageFileSchema, imageFile: imageFileSchema,
overallScore: zodCohercedNumber(z.number().int().min(0).max(10)).optional(),
serviceVisibility: z.nativeEnum(ServiceVisibility), serviceVisibility: z.nativeEnum(ServiceVisibility),
internalNote: z.string().optional(), internalNote: z.string().optional(),
strictCommentingEnabled: z.boolean().optional().default(false),
commentSectionMessage: z.string().trim().min(3).max(1000).optional().nullable().default(null),
}) })
// Define schema for the create action input // Define schema for the create action input
@@ -127,11 +139,12 @@ export const adminServiceActions = {
verificationSummary: input.verificationSummary, verificationSummary: input.verificationSummary,
verificationProofMd: input.verificationProofMd, verificationProofMd: input.verificationProofMd,
acceptedCurrencies: input.acceptedCurrencies, acceptedCurrencies: input.acceptedCurrencies,
strictCommentingEnabled: input.strictCommentingEnabled,
commentSectionMessage: input.commentSectionMessage,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
referral: input.referral || null, referral: input.referral || null,
serviceVisibility: input.serviceVisibility, serviceVisibility: input.serviceVisibility,
slug: input.slug, slug: input.slug,
overallScore: input.overallScore,
categories: { categories: {
connect: input.categories.map((id) => ({ id })), connect: input.categories.map((id) => ({ id })),
}, },
@@ -142,6 +155,11 @@ export const adminServiceActions = {
}, },
})), })),
}, },
contactMethods: {
create: input.contactMethods.map((value) => ({
value,
})),
},
imageUrl, imageUrl,
internalNotes: input.internalNote internalNotes: input.internalNote
? { ? {
@@ -152,6 +170,8 @@ export const adminServiceActions = {
} }
: undefined, : undefined,
operatingSince: input.operatingSince, operatingSince: input.operatingSince,
registrationCountryCode: input.registrationCountryCode ?? null,
registeredCompanyName: input.registeredCompanyName,
}, },
select: { select: {
id: true, id: true,
@@ -247,11 +267,12 @@ export const adminServiceActions = {
verificationSummary: input.verificationSummary, verificationSummary: input.verificationSummary,
verificationProofMd: input.verificationProofMd, verificationProofMd: input.verificationProofMd,
acceptedCurrencies: input.acceptedCurrencies, acceptedCurrencies: input.acceptedCurrencies,
strictCommentingEnabled: input.strictCommentingEnabled,
commentSectionMessage: input.commentSectionMessage,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
referral: input.referral || null, referral: input.referral || null,
serviceVisibility: input.serviceVisibility, serviceVisibility: input.serviceVisibility,
slug: input.slug, slug: input.slug,
overallScore: input.overallScore,
previousSlugs: previousSlugs:
existingService.slug !== input.slug existingService.slug !== input.slug
? { ? {
@@ -277,6 +298,8 @@ export const adminServiceActions = {
})), })),
}, },
operatingSince: input.operatingSince, operatingSince: input.operatingSince,
registrationCountryCode: input.registrationCountryCode ?? null,
registeredCompanyName: input.registeredCompanyName,
}, },
}) })
@@ -337,7 +360,6 @@ export const adminServiceActions = {
await prisma.serviceContactMethod.delete({ await prisma.serviceContactMethod.delete({
where: { id: input.id }, where: { id: input.id },
}) })
return { success: true }
}, },
}), }),
}, },
@@ -463,7 +485,6 @@ export const adminServiceActions = {
input: evidenceImageDeleteSchema, input: evidenceImageDeleteSchema,
handler: async (input) => { handler: async (input) => {
await deleteFileLocally(input.fileUrl) await deleteFileLocally(input.fileUrl)
return { success: true }
}, },
}), }),
}, },

View File

@@ -17,6 +17,7 @@ import type { CommentStatus, Prisma } from '@prisma/client'
const COMMENT_RATE_LIMIT_WINDOW_MINUTES = 2 const COMMENT_RATE_LIMIT_WINDOW_MINUTES = 2
const MAX_COMMENTS_PER_WINDOW = 1 const MAX_COMMENTS_PER_WINDOW = 1
const MAX_COMMENTS_PER_WINDOW_VERIFIED_USER = 10 const MAX_COMMENTS_PER_WINDOW_VERIFIED_USER = 10
export const COMMENT_ORDER_ID_MAX_LENGTH = 600
export const commentActions = { export const commentActions = {
vote: defineProtectedAction({ vote: defineProtectedAction({
@@ -103,7 +104,7 @@ export const commentActions = {
issueFundsBlocked: z.coerce.boolean().optional(), issueFundsBlocked: z.coerce.boolean().optional(),
issueScam: z.coerce.boolean().optional(), issueScam: z.coerce.boolean().optional(),
issueDetails: z.string().max(120).optional(), issueDetails: z.string().max(120).optional(),
orderId: z.string().max(100).optional(), orderId: z.string().max(COMMENT_ORDER_ID_MAX_LENGTH).optional(),
}) })
.superRefine((data, ctx) => { .superRefine((data, ctx) => {
if (data.rating && data.parentId) { if (data.rating && data.parentId) {

View File

@@ -3,6 +3,7 @@ import { z } from 'astro/zod'
import { ActionError } from 'astro:actions' import { ActionError } from 'astro:actions'
import { formatDistanceStrict } from 'date-fns' import { formatDistanceStrict } from 'date-fns'
import { countriesZodEnumById } from '../constants/countries'
import { captchaFormSchemaProperties, captchaFormSchemaSuperRefine } from '../lib/captchaValidation' import { captchaFormSchemaProperties, captchaFormSchemaSuperRefine } from '../lib/captchaValidation'
import { defineProtectedAction } from '../lib/defineProtectedAction' import { defineProtectedAction } from '../lib/defineProtectedAction'
import { saveFileLocally } from '../lib/fileStorage' import { saveFileLocally } from '../lib/fileStorage'
@@ -184,6 +185,14 @@ export const serviceSuggestionActions = {
}), }),
}), }),
operatingSince: z.coerce.date().optional(), operatingSince: z.coerce.date().optional(),
registrationCountryCode: z
.union([countriesZodEnumById, z.literal('')])
.optional()
.nullable()
.refine((val) => val === null || val === undefined || val === '' || val.length === 2, {
message: 'Country code must be a valid 2-character code or empty',
}),
registeredCompanyName: z.string().trim().max(100).optional(),
/** @deprecated Honey pot field, do not use */ /** @deprecated Honey pot field, do not use */
message: z.unknown().optional(), message: z.unknown().optional(),
skipDuplicateCheck: z skipDuplicateCheck: z
@@ -282,6 +291,8 @@ export const serviceSuggestionActions = {
slug: input.slug, slug: input.slug,
description: input.description, description: input.description,
operatingSince: input.operatingSince, operatingSince: input.operatingSince,
registrationCountryCode: input.registrationCountryCode ?? null,
registeredCompanyName: input.registeredCompanyName,
serviceUrls, serviceUrls,
tosUrls: input.tosUrls, tosUrls: input.tosUrls,
onionUrls, onionUrls,

View File

@@ -43,6 +43,7 @@ const Tag = announcement.link ? 'a' : 'div'
'group xs:px-6 2xs:px-4 relative isolate z-50 flex items-center justify-center gap-x-2 overflow-hidden border-b border-zinc-800 bg-black px-2 py-2 focus-visible:outline-none sm:gap-x-6 sm:px-3.5', 'group xs:px-6 2xs:px-4 relative isolate z-50 flex items-center justify-center gap-x-2 overflow-hidden border-b border-zinc-800 bg-black px-2 py-2 focus-visible:outline-none sm:gap-x-6 sm:px-3.5',
className className
)} )}
aria-label="Announcement banner"
{...props} {...props}
> >
<div <div
@@ -85,7 +86,7 @@ const Tag = announcement.link ? 'a' : 'div'
</div> </div>
{ {
!!announcement.linkText && ( !!announcement.link && !!announcement.linkText && (
<div class="text-day-300 group-focus-visible:outline-primary transition-background 2xs:px-4 relative inline-flex h-full shrink-0 cursor-pointer items-center justify-center gap-1.5 overflow-hidden rounded-full border border-white/20 bg-black/10 p-[1px] px-1 py-1 text-sm font-medium shadow-sm backdrop-blur-3xl transition-colors group-hover:bg-white/5 group-focus-visible:ring-2 group-focus-visible:ring-blue-500 group-focus-visible:ring-offset-2 group-focus-visible:ring-offset-black/80 sm:min-w-[120px]"> <div class="text-day-300 group-focus-visible:outline-primary transition-background 2xs:px-4 relative inline-flex h-full shrink-0 cursor-pointer items-center justify-center gap-1.5 overflow-hidden rounded-full border border-white/20 bg-black/10 p-[1px] px-1 py-1 text-sm font-medium shadow-sm backdrop-blur-3xl transition-colors group-hover:bg-white/5 group-focus-visible:ring-2 group-focus-visible:ring-blue-500 group-focus-visible:ring-offset-2 group-focus-visible:ring-offset-black/80 sm:min-w-[120px]">
<span class="2xs:inline-block hidden">{announcement.linkText}</span> <span class="2xs:inline-block hidden">{announcement.linkText}</span>
<Icon <Icon

View File

@@ -1,6 +1,7 @@
--- ---
import LoadingIndicator from 'astro-loading-indicator/component' import LoadingIndicator from 'astro-loading-indicator/component'
import { Schema } from 'astro-seo-schema' import { Schema } from 'astro-seo-schema'
import { ONION_ADDRESS } from 'astro:env/server'
import { ClientRouter } from 'astro:transitions' import { ClientRouter } from 'astro:transitions'
import { pwaAssetsHead } from 'virtual:pwa-assets/head' import { pwaAssetsHead } from 'virtual:pwa-assets/head'
import { pwaInfo } from 'virtual:pwa-info' import { pwaInfo } from 'virtual:pwa-info'
@@ -78,30 +79,32 @@ const fullTitle = `${pageTitle} | KYCnot.me ${modeName}`
const ogImageUrl = makeOgImageUrl(ogImage, Astro.url) const ogImageUrl = makeOgImageUrl(ogImage, Astro.url)
--- ---
<!-- Primary Meta Tags --> {/* Primary Meta Tags */}
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<meta name="description" content={description} /> <meta name="description" content={description} />
<title>{fullTitle}</title> <title>{fullTitle}</title>
<!-- {canonicalUrl && <link rel="canonical" href={canonicalUrl} />} --> {/* canonicalUrl && <link rel="canonical" href={canonicalUrl} /> */}
<meta http-equiv="onion-location" content={ONION_ADDRESS} />
<!-- Open Graph / Facebook --> {/* Open Graph / Facebook */}
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:url" content={Astro.url} /> <meta property="og:url" content={Astro.url} />
<meta property="og:title" content={fullTitle} /> <meta property="og:title" content={fullTitle} />
<meta property="og:description" content={description} /> <meta property="og:description" content={description} />
{!!ogImageUrl && <meta property="og:image" content={ogImageUrl} />} {!!ogImageUrl && <meta property="og:image" content={ogImageUrl} />}
<!-- Twitter --> {/* Twitter */}
<meta property="twitter:card" content="summary_large_image" /> <meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={Astro.url} /> <meta property="twitter:url" content={Astro.url} />
<meta property="twitter:title" content={fullTitle} /> <meta property="twitter:title" content={fullTitle} />
<meta property="twitter:description" content={description} /> <meta property="twitter:description" content={description} />
{!!ogImageUrl && <meta property="twitter:image" content={ogImageUrl} />} {!!ogImageUrl && <meta property="twitter:image" content={ogImageUrl} />}
<!-- Other --> {/* Other */}
<link rel="sitemap" href="/sitemap-index.xml" /> <link rel="sitemap" href="/sitemap-index.xml" />
<link rel="sitemap" href="/sitemaps/search.xml" />
<!-- PWA --> {/* PWA */}
{pwaAssetsHead.themeColor && <meta name="theme-color" content={pwaAssetsHead.themeColor.content} />} {pwaAssetsHead.themeColor && <meta name="theme-color" content={pwaAssetsHead.themeColor.content} />}
{pwaAssetsHead.links.filter((link) => link.rel !== 'icon').map((link) => <link {...link} />)} {pwaAssetsHead.links.filter((link) => link.rel !== 'icon').map((link) => <link {...link} />)}
{pwaInfo && <Fragment set:html={pwaInfo.webManifest.linkTag} />} {pwaInfo && <Fragment set:html={pwaInfo.webManifest.linkTag} />}
@@ -115,10 +118,10 @@ const ogImageUrl = makeOgImageUrl(ogImage, Astro.url)
<TailwindJsPluggin /> <TailwindJsPluggin />
{htmx && <HtmxScript />} {htmx && <HtmxScript />}
<!-- JSON-LD Schemas --> {/* JSON-LD Schemas */}
{schemas?.map((item) => <Schema item={item} />)} {schemas?.map((item) => <Schema item={item} />)}
<!-- Breadcrumbs --> {/* Breadcrumbs */}
{ {
breadcrumbLists.map((breadcrumbList) => ( breadcrumbLists.map((breadcrumbList) => (
<Schema <Schema

View File

@@ -33,6 +33,7 @@ type Props = HTMLAttributes<'div'> & {
highlightedCommentId: number | null highlightedCommentId: number | null
serviceSlug: string serviceSlug: string
itemReviewedId: string itemReviewedId: string
strictCommentingEnabled?: boolean
} }
const { const {
@@ -42,6 +43,7 @@ const {
highlightedCommentId = null, highlightedCommentId = null,
serviceSlug, serviceSlug,
itemReviewedId, itemReviewedId,
strictCommentingEnabled,
class: className, class: className,
...htmlProps ...htmlProps
} = Astro.props } = Astro.props
@@ -492,6 +494,7 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
serviceId={comment.serviceId} serviceId={comment.serviceId}
parentId={comment.id} parentId={comment.id}
commentId={comment.id} commentId={comment.id}
strictCommentingEnabled={strictCommentingEnabled}
class="mt-2 hidden peer-checked/collapse:hidden peer-checked/reply:block" class="mt-2 hidden peer-checked/collapse:hidden peer-checked/reply:block"
/> />
</> </>

View File

@@ -1,7 +1,9 @@
--- ---
import { Icon } from 'astro-icon/components' import { Icon } from 'astro-icon/components'
import { Markdown } from 'astro-remote'
import { actions } from 'astro:actions' import { actions } from 'astro:actions'
import { COMMENT_ORDER_ID_MAX_LENGTH } from '../actions/comment'
import { cn } from '../lib/cn' import { cn } from '../lib/cn'
import { makeLoginUrl } from '../lib/redirectUrls' import { makeLoginUrl } from '../lib/redirectUrls'
@@ -20,6 +22,8 @@ type Props = Omit<HTMLAttributes<'form'>, 'action' | 'enctype' | 'method'> & {
serviceId: number serviceId: number
parentId?: number parentId?: number
commentId?: number commentId?: number
strictCommentingEnabled?: boolean
commentSectionMessage?: string | null
activeRatingComment?: Prisma.CommentGetPayload<{ activeRatingComment?: Prisma.CommentGetPayload<{
select: { select: {
id: true id: true
@@ -28,7 +32,16 @@ type Props = Omit<HTMLAttributes<'form'>, 'action' | 'enctype' | 'method'> & {
}> | null }> | null
} }
const { serviceId, parentId, commentId, activeRatingComment, class: className, ...htmlProps } = Astro.props const {
serviceId,
parentId,
commentId,
activeRatingComment,
strictCommentingEnabled,
commentSectionMessage,
class: className,
...htmlProps
} = Astro.props
const MIN_COMMENT_LENGTH = parentId ? 10 : 30 const MIN_COMMENT_LENGTH = parentId ? 10 : 30
@@ -88,69 +101,83 @@ const userCommentsDisabled = user ? user.karmaUnlocks.commentsDisabled : false
</div> </div>
{!parentId ? ( {!parentId ? (
<div class="[&:has(input[name='rating'][value='']:checked)_[data-show-if-rating]]:hidden"> <>
<div class="flex flex-wrap gap-4"> <div class="[&:has(input[name='rating'][value='']:checked)_[data-show-if-rating]]:hidden">
<InputRating name="rating" label="Rating" /> <div class="flex flex-wrap gap-4">
<InputRating name="rating" label="Rating" />
<InputWrapper label="I experienced..." name="tags"> <InputWrapper label="I experienced..." name="tags">
<label class="flex cursor-pointer items-center gap-2"> <label class="flex cursor-pointer items-center gap-2">
<input type="checkbox" name="issueKycRequested" class="text-red-400" /> <input type="checkbox" name="issueKycRequested" class="text-red-400" />
<span class="flex items-center gap-1 text-xs text-red-400"> <span class="flex items-center gap-1 text-xs text-red-400">
<Icon name="ri:user-forbid-fill" class="size-3" /> <Icon name="ri:user-forbid-fill" class="size-3" />
KYC Issue KYC Issue
</span> </span>
</label> </label>
<label class="flex cursor-pointer items-center gap-2"> <label class="flex cursor-pointer items-center gap-2">
<input type="checkbox" name="issueFundsBlocked" class="text-orange-400" /> <input type="checkbox" name="issueFundsBlocked" class="text-orange-400" />
<span class="flex items-center gap-1 text-xs text-orange-400"> <span class="flex items-center gap-1 text-xs text-orange-400">
<Icon name="ri:wallet-3-fill" class="size-3" /> <Icon name="ri:wallet-3-fill" class="size-3" />
Funds Blocked Funds Blocked
</span> </span>
</label> </label>
</InputWrapper> </InputWrapper>
<InputText <InputText
label="Order ID" label="Order ID"
name="orderId" name="orderId"
inputProps={{ inputProps={{
maxlength: 100, maxlength: COMMENT_ORDER_ID_MAX_LENGTH,
placeholder: 'Order ID / URL / Proof', placeholder: 'Order ID / URL / Proof',
class: 'bg-night-800', class: 'bg-night-800',
}} required: strictCommentingEnabled,
descriptionLabel="Only visible to admins, to verify your comment" }}
class="grow" descriptionLabel="Only visible to admins, to verify your comment"
/> class="grow"
</div> />
</div>
<div class="mt-4 flex items-start justify-end gap-2"> <div class="mt-4 flex flex-wrap items-start justify-end gap-x-4 gap-y-2">
{!!activeRatingComment?.rating && ( {!!activeRatingComment?.rating && (
<div <div
class="rounded-sm bg-yellow-500/10 px-2 py-1.5 text-xs text-yellow-400" class="mt-1 rounded-sm bg-yellow-500/10 px-2 py-1.5 text-xs text-yellow-400"
data-show-if-rating data-show-if-rating
>
<Icon name="ri:information-line" class="mr-1 inline size-3.5" />
<a
href={`${Astro.url.origin}${Astro.url.pathname}#comment-${activeRatingComment.id}`}
class="inline-flex items-center gap-1 underline"
target="_blank"
rel="noopener noreferrer"
> >
Your previous rating <Icon name="ri:information-line" class="mr-1 inline size-3.5" />
<Icon name="ri:external-link-line" class="inline size-2.5 align-[-0.1em]" /> <a
</a> href={`${Astro.url.origin}${Astro.url.pathname}#comment-${activeRatingComment.id}`}
of class="inline-flex items-center gap-1 underline"
{[ target="_blank"
activeRatingComment.rating.toLocaleString(), rel="noopener noreferrer"
<Icon name="ri:star-fill" class="inline size-3 align-[-0.1em]" />, >
]} Your previous rating
won't count for the total. <Icon name="ri:external-link-line" class="inline size-2.5 align-[-0.1em]" />
</div> </a>
)} of
{[
activeRatingComment.rating.toLocaleString(),
<Icon name="ri:star-fill" class="inline size-3 align-[-0.1em]" />,
]}
won't count for the total.
</div>
)}
<Button type="submit" label="Send" icon="ri:send-plane-2-line" /> <div class="flex flex-wrap items-start justify-end gap-x-4 gap-y-2">
{!!commentSectionMessage && (
<div class="flex items-start gap-1 pt-1.5">
<Icon name="ri:information-line" class="mt-1.25 inline size-3.5" />
<div class="prose prose-invert prose-sm text-day-200 max-w-none grow">
<Markdown content={commentSectionMessage} />
</div>
</div>
)}
<Button type="submit" label="Send" icon="ri:send-plane-2-line" />
</div>
</div>
</div> </div>
</div> </>
) : ( ) : (
<div class="flex items-center justify-end gap-2"> <div class="flex items-center justify-end gap-2">
<Button type="submit" label="Reply" icon="ri:reply-line" /> <Button type="submit" label="Reply" icon="ri:reply-line" />

View File

@@ -35,6 +35,8 @@ type Props = {
name: true name: true
description: true description: true
createdAt: true createdAt: true
strictCommentingEnabled: true
commentSectionMessage: true
} }
}> }>
} }
@@ -173,7 +175,13 @@ function makeReplySchema(comment: CommentWithRepliesPopulated): Comment {
comment: comments.map(makeReplySchema), comment: comments.map(makeReplySchema),
} as WithContext<DiscussionForumPosting>} } as WithContext<DiscussionForumPosting>}
/> />
<CommentReply serviceId={service.id} activeRatingComment={activeRatingComment} class="xs:mb-4 mb-2" /> <CommentReply
serviceId={service.id}
activeRatingComment={activeRatingComment}
strictCommentingEnabled={service.strictCommentingEnabled}
commentSectionMessage={service.commentSectionMessage}
class="xs:mb-4 mb-2"
/>
<div class="mb-6 flex flex-wrap items-center justify-between gap-2"> <div class="mb-6 flex flex-wrap items-center justify-between gap-2">
<div class="flex items-center"> <div class="flex items-center">
@@ -258,6 +266,7 @@ function makeReplySchema(comment: CommentWithRepliesPopulated): Comment {
showPending={params.showPending} showPending={params.showPending}
serviceSlug={service.slug} serviceSlug={service.slug}
itemReviewedId={itemReviewedId} itemReviewedId={itemReviewedId}
strictCommentingEnabled={service.strictCommentingEnabled}
/> />
)) ))
) : ( ) : (

View File

@@ -37,6 +37,7 @@ const splashText = showSplashText ? sample(splashTexts) : null
} }
)} )}
transition:name="header-container" transition:name="header-container"
aria-label="Header"
> >
<nav class={cn('container mx-auto flex h-full w-full items-stretch justify-between px-4', classNames?.nav)}> <nav class={cn('container mx-auto flex h-full w-full items-stretch justify-between px-4', classNames?.nav)}>
<div class="@container -ml-4 flex max-w-[192px] grow-99999 items-center"> <div class="@container -ml-4 flex max-w-[192px] grow-99999 items-center">

View File

@@ -7,6 +7,8 @@ import type { ComponentProps } from 'astro/types'
type Props = Pick<ComponentProps<typeof InputWrapper>, 'error' | 'name' | 'required'> & { type Props = Pick<ComponentProps<typeof InputWrapper>, 'error' | 'name' | 'required'> & {
disabled?: boolean disabled?: boolean
checked?: boolean
descriptionInline?: string
id?: string id?: string
} & ( } & (
| { | {
@@ -19,13 +21,11 @@ type Props = Pick<ComponentProps<typeof InputWrapper>, 'error' | 'name' | 'requi
} }
) )
const { disabled, name, required, error, id, label } = Astro.props const { disabled, name, required, error, id, label, checked, descriptionInline } = Astro.props
const hasError = !!error && error.length > 0 const hasError = !!error && error.length > 0
--- ---
{}
<div> <div>
<label <label
class={cn( class={cn(
@@ -41,9 +41,11 @@ const hasError = !!error && error.length > 0
name={name} name={name}
required={required} required={required}
disabled={disabled} disabled={disabled}
checked={checked}
class={cn(disabled && 'opacity-50')} class={cn(disabled && 'opacity-50')}
/> />
<span class="text-sm leading-none text-pretty">{label ?? <slot />}</span> <span class="text-sm leading-none text-pretty">{label ?? <slot />}</span>
{descriptionInline && <p class="text-day-400 text-xs">{descriptionInline}</p>}
</label> </label>
{ {

View File

@@ -9,6 +9,7 @@ import defaultOGImage from '../assets/ogimage.png'
import { makeOverallScoreInfo } from '../lib/overallScore' import { makeOverallScoreInfo } from '../lib/overallScore'
import { urlWithParams } from '../lib/urls' import { urlWithParams } from '../lib/urls'
import type { VerificationStatus } from '@prisma/client'
import type { APIContext } from 'astro' import type { APIContext } from 'astro'
import type { Prettify } from 'ts-essentials' import type { Prettify } from 'ts-essentials'
@@ -107,6 +108,7 @@ export const ogImageTemplates = {
categories, categories,
score, score,
imageUrl, imageUrl,
verificationStatus,
}: { }: {
title: string title: string
description: string description: string
@@ -116,6 +118,7 @@ export const ogImageTemplates = {
}[] }[]
score: number score: number
imageUrl: string | null imageUrl: string | null
verificationStatus: VerificationStatus | null
}, },
context context
) => { ) => {
@@ -272,6 +275,37 @@ export const ogImageTemplates = {
> >
<path d="M1 0a1 1 0 0 0-1 1v26a1 1 0 0 0 1 1h74a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1Zm4 4h2a1 1 0 0 1 1 1v6a1 1 0 0 0 1 1h6a1 1 0 0 1 1 1v3h3a1 1 0 0 1 1 1v3h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-3h-3a1 1 0 0 1-1-1v-3H9a1 1 0 0 0-1 1v6a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Zm12 0h3a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zm12.82 0h2.37a1 1 0 0 1 .85.46L38 12.27l4.97-7.8A1 1 0 0 1 43.8 4h2.37a1 1 0 0 1 .85 1.54l-6.87 10.8a1 1 0 0 0-.16.53V23a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-6.13a1 1 0 0 0-.15-.53l-6.87-10.8A1 1 0 0 1 29.82 4ZM57 4h14a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H56v12h15a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H57a1 1 0 0 1-1-1v-3h-3a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h3V5a1 1 0 0 1 1-1zm24 0a1 1 0 0 0-1 1v18a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V7.6l9.18 15.9c.18.3.5.5.86.5H99a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v15.4L86.83 4.5a1 1 0 0 0-.87-.5Zm29 0a1 1 0 0 0-1 1v3h12V5a1 1 0 0 0-1-1zm11 4v12h3a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1zm0 12h-12v3a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1zm-12 0V8h-3a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1zm21-16a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V8h4v15a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V8h4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1zm27 0a1 1 0 0 0-1 1v18a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V11.4l5.53 12.02a1 1 0 0 0 .91.58h3.12a1 1 0 0 0 .91-.58L176 11.4V23a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1h-3.36a1 1 0 0 0-.9.58L168 19.21l-6.73-14.63a1 1 0 0 0-.9-.58Zm32 0a1 1 0 0 0-1 1v3h15a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1zm-1 4h-3a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-14a1 1 0 0 1-1-1v-3h7a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-7zm-38 12a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1z" /> <path d="M1 0a1 1 0 0 0-1 1v26a1 1 0 0 0 1 1h74a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1Zm4 4h2a1 1 0 0 1 1 1v6a1 1 0 0 0 1 1h6a1 1 0 0 1 1 1v3h3a1 1 0 0 1 1 1v3h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-3h-3a1 1 0 0 1-1-1v-3H9a1 1 0 0 0-1 1v6a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Zm12 0h3a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zm12.82 0h2.37a1 1 0 0 1 .85.46L38 12.27l4.97-7.8A1 1 0 0 1 43.8 4h2.37a1 1 0 0 1 .85 1.54l-6.87 10.8a1 1 0 0 0-.16.53V23a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-6.13a1 1 0 0 0-.15-.53l-6.87-10.8A1 1 0 0 1 29.82 4ZM57 4h14a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H56v12h15a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H57a1 1 0 0 1-1-1v-3h-3a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h3V5a1 1 0 0 1 1-1zm24 0a1 1 0 0 0-1 1v18a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V7.6l9.18 15.9c.18.3.5.5.86.5H99a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v15.4L86.83 4.5a1 1 0 0 0-.87-.5Zm29 0a1 1 0 0 0-1 1v3h12V5a1 1 0 0 0-1-1zm11 4v12h3a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1zm0 12h-12v3a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1zm-12 0V8h-3a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1zm21-16a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V8h4v15a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V8h4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1zm27 0a1 1 0 0 0-1 1v18a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V11.4l5.53 12.02a1 1 0 0 0 .91.58h3.12a1 1 0 0 0 .91-.58L176 11.4V23a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1h-3.36a1 1 0 0 0-.9.58L168 19.21l-6.73-14.63a1 1 0 0 0-.9-.58Zm32 0a1 1 0 0 0-1 1v3h15a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1zm-1 4h-3a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-14a1 1 0 0 1-1-1v-3h7a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-7zm-38 12a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1z" />
</svg> </svg>
{verificationStatus === 'VERIFICATION_FAILED' && (
<div
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<div
style={{
transform: 'rotate(-20deg)',
fontSize: 200,
fontWeight: 'bold',
color: 'red',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
boxShadow: '0 0 15px 30px rgba(0, 0, 0, 0.5)',
border: '15px solid red',
borderRadius: 15,
padding: '10px 50px',
textAlign: 'center',
}}
>
SCAM
</div>
</div>
)}
</div> </div>
), ),
defaultOptions defaultOptions

View File

@@ -13,7 +13,7 @@ import Tooltip from './Tooltip.astro'
import type { Prisma } from '@prisma/client' import type { Prisma } from '@prisma/client'
import type { HTMLAttributes } from 'astro/types' import type { HTMLAttributes } from 'astro/types'
type Props = HTMLAttributes<'a'> & { type Props = HTMLAttributes<'article'> & {
inlineIcons?: boolean inlineIcons?: boolean
withoutLink?: boolean withoutLink?: boolean
service: Prisma.ServiceGetPayload<{ service: Prisma.ServiceGetPayload<{
@@ -57,7 +57,7 @@ const {
}, },
class: className, class: className,
withoutLink = false, withoutLink = false,
...aProps ...htmlProps
} = Astro.props } = Astro.props
const statusIcon = { const statusIcon = {
@@ -70,127 +70,129 @@ const Element = withoutLink ? 'div' : 'a'
const overallScoreInfo = makeOverallScoreInfo(overallScore) const overallScoreInfo = makeOverallScoreInfo(overallScore)
--- ---
<Element <article {...htmlProps}>
href={Element === 'a' ? `/service/${slug}` : undefined} <Element
{...aProps} href={Element === 'a' ? `/service/${slug}` : undefined}
class={cn( aria-label={Element === 'a' ? name : undefined}
'border-night-600 group/card bg-night-800 flex flex-col gap-(--gap) rounded-xl border p-(--gap) [--gap:calc(var(--spacing)*3)]', class={cn(
(serviceVisibility === 'ARCHIVED' || verificationStatus === 'VERIFICATION_FAILED') && 'border-night-600 group/card bg-night-800 flex flex-col gap-(--gap) rounded-xl border p-(--gap) [--gap:calc(var(--spacing)*3)]',
'opacity-75 transition-opacity hover:opacity-100 focus-visible:opacity-100', (serviceVisibility === 'ARCHIVED' || verificationStatus === 'VERIFICATION_FAILED') &&
className 'opacity-75 transition-opacity hover:opacity-100 focus-visible:opacity-100',
)} className
> )}
<!-- Header with Icon and Title --> >
<div class="flex items-center gap-(--gap)"> <!-- Header with Icon and Title -->
<MyPicture <div class="flex items-center gap-(--gap)">
src={imageUrl} <MyPicture
fallback="service" src={imageUrl}
alt={name || 'Service logo'} fallback="service"
class={cn( alt="Logo"
'size-12 shrink-0 rounded-sm object-contain text-white', class={cn(
(serviceVisibility === 'ARCHIVED' || verificationStatus === 'VERIFICATION_FAILED') && 'size-12 shrink-0 rounded-sm object-contain text-white',
'grayscale-67 transition-all group-hover/card:grayscale-0 group-focus-visible/card:grayscale-0' (serviceVisibility === 'ARCHIVED' || verificationStatus === 'VERIFICATION_FAILED') &&
)} 'grayscale-67 transition-all group-hover/card:grayscale-0 group-focus-visible/card:grayscale-0'
width={48} )}
height={48} width={48}
/> height={48}
/>
<div class="flex min-w-0 flex-1 flex-col justify-center self-stretch"> <div class="flex min-w-0 flex-1 flex-col justify-center self-stretch">
<h3 class="font-title text-lg leading-none font-medium tracking-wide text-white"> <h1 class="font-title text-lg leading-none font-medium tracking-wide text-white">
{name}{ {name}{
statusIcon && ( statusIcon && (
<Tooltip <Tooltip
text={statusIcon.label} text={statusIcon.label}
position="right" position="right"
class="-my-2 shrink-0 whitespace-nowrap" class="-my-2 shrink-0 whitespace-nowrap"
enabled={verificationStatus !== 'VERIFICATION_FAILED'} enabled={verificationStatus !== 'VERIFICATION_FAILED'}
> >
{[ {[
<Icon
is:inline={inlineIcons}
name={statusIcon.icon}
class={cn(
'inline-block size-6 shrink-0 rounded-lg p-1 align-[-0.37em]',
verificationStatus === 'VERIFICATION_FAILED' && 'pr-0',
statusIcon.classNames.icon
)}
/>,
verificationStatus === 'VERIFICATION_FAILED' && (
<span class="text-sm font-bold text-red-500">SCAM</span>
),
]}
</Tooltip>
)
}{
serviceVisibility === 'ARCHIVED' && (
<Tooltip
text={serviceVisibilitiesById.ARCHIVED.label}
position="right"
class="-my-2 shrink-0 whitespace-nowrap"
>
<Icon <Icon
is:inline={inlineIcons} is:inline={inlineIcons}
name={statusIcon.icon} name={serviceVisibilitiesById.ARCHIVED.icon}
class={cn( class={cn(
'inline-block size-6 shrink-0 rounded-lg p-1 align-[-0.37em]', 'inline-block size-6 shrink-0 rounded-lg p-1 align-[-0.37em]',
verificationStatus === 'VERIFICATION_FAILED' && 'pr-0', serviceVisibilitiesById.ARCHIVED.iconClass
statusIcon.classNames.icon
)} )}
/>, />
verificationStatus === 'VERIFICATION_FAILED' && ( </Tooltip>
<span class="text-sm font-bold text-red-500">SCAM</span> )
), }
]} </h1>
</Tooltip> <div class="max-h-2 flex-1" aria-hidden="true"></div>
) <div class="flex items-center gap-4 overflow-hidden mask-r-from-[calc(100%-var(--spacing)*4)]">
}{ {
serviceVisibility === 'ARCHIVED' && ( categories.map((category) => (
<Tooltip <span class="text-day-300 inline-flex shrink-0 items-center gap-1 text-sm leading-none">
text={serviceVisibilitiesById.ARCHIVED.label} <Icon name={category.icon} class="size-4" is:inline={inlineIcons} />
position="right" <span>{category.name}</span>
class="-my-2 shrink-0 whitespace-nowrap" </span>
> ))
<Icon }
is:inline={inlineIcons} </div>
name={serviceVisibilitiesById.ARCHIVED.icon} </div>
class={cn( </div>
'inline-block size-6 shrink-0 rounded-lg p-1 align-[-0.37em]',
serviceVisibilitiesById.ARCHIVED.iconClass <div class="flex-1">
)} <p class="text-day-400 line-clamp-3 text-sm leading-tight">
/> {description}
</Tooltip> </p>
) </div>
}
</h3> <div class="flex items-center justify-start">
<div class="max-h-2 flex-1"></div> <Tooltip
<div class="flex items-center gap-4 overflow-hidden mask-r-from-[calc(100%-var(--spacing)*4)]"> class={cn(
'inline-flex size-6 items-center justify-center rounded-sm text-lg font-bold',
overallScoreInfo.classNameBg
)}
text={`${Math.round(privacyScore).toLocaleString()}% Privacy | ${Math.round(trustScore).toLocaleString()}% Trust`}
>
{overallScoreInfo.formattedScore}
</Tooltip>
<span class="text-day-300 ml-3 text-sm font-bold whitespace-nowrap">
KYC &nbsp;{kycLevel.toLocaleString()}
</span>
<div class="-m-1 ml-auto flex">
{ {
categories.map((category) => ( currencies.map((currency) => {
<span class="text-day-300 inline-flex shrink-0 items-center gap-1 text-sm leading-none"> const isAccepted = acceptedCurrencies.includes(currency.id)
<Icon name={category.icon} class="size-4" is:inline={inlineIcons} />
<span>{category.name}</span> return (
</span> <Tooltip text={currency.name}>
)) <Icon
is:inline={inlineIcons}
name={currency.icon}
class={cn('text-day-600 box-content size-4 p-1', { 'text-white': isAccepted })}
/>
</Tooltip>
)
})
} }
</div> </div>
</div> </div>
</div> </Element>
</article>
<div class="flex-1">
<p class="text-day-400 line-clamp-3 text-sm leading-tight">
{description}
</p>
</div>
<div class="flex items-center justify-start">
<Tooltip
class={cn(
'inline-flex size-6 items-center justify-center rounded-sm text-lg font-bold',
overallScoreInfo.classNameBg
)}
text={`${Math.round(privacyScore).toLocaleString()}% Privacy | ${Math.round(trustScore).toLocaleString()}% Trust`}
>
{overallScoreInfo.formattedScore}
</Tooltip>
<span class="text-day-300 ml-3 text-sm font-bold whitespace-nowrap">
KYC &nbsp;{kycLevel.toLocaleString()}
</span>
<div class="-m-1 ml-auto flex">
{
currencies.map((currency) => {
const isAccepted = acceptedCurrencies.includes(currency.id)
return (
<Tooltip text={currency.name}>
<Icon
is:inline={inlineIcons}
name={currency.icon}
class={cn('text-day-600 box-content size-4 p-1', { 'text-white': isAccepted })}
/>
</Tooltip>
)
})
}
</div>
</div>
</Element>

View File

@@ -39,6 +39,7 @@ const makeUrlWithoutFilter = (filter: string, value?: string) => {
'bg-night-800 hover:bg-night-900 border-night-400 flex h-8 shrink-0 items-center gap-2 rounded-full border px-3 text-sm text-white', 'bg-night-800 hover:bg-night-900 border-night-400 flex h-8 shrink-0 items-center gap-2 rounded-full border px-3 text-sm text-white',
className className
)} )}
aria-label={`Remove filter: ${text}`}
> >
{icon && <Icon name={icon} class={cn('size-4', iconClass)} is:inline={inlineIcons} />} {icon && <Icon name={icon} class={cn('size-4', iconClass)} is:inline={inlineIcons} />}
{text} {text}

View File

@@ -10,7 +10,8 @@ import { transformCase } from '../lib/strings'
import ServiceFiltersPill from './ServiceFiltersPill.astro' import ServiceFiltersPill from './ServiceFiltersPill.astro'
import type { AttributeOption, ServicesFiltersObject, ServicesFiltersOptions } from '../pages/index.astro' import type { ServicesFiltersOptions } from '../lib/searchFiltersOptions'
import type { AttributeOption, ServicesFiltersObject } from '../pages/index.astro'
import type { Prisma } from '@prisma/client' import type { Prisma } from '@prisma/client'
import type { HTMLAttributes } from 'astro/types' import type { HTMLAttributes } from 'astro/types'
@@ -31,6 +32,7 @@ type Props = HTMLAttributes<'div'> & {
} }
}>[] }>[]
attributeOptions: AttributeOption[] attributeOptions: AttributeOption[]
inlineIcons?: boolean
} }
const { const {
@@ -40,6 +42,7 @@ const {
categories, categories,
attributes, attributes,
attributeOptions, attributeOptions,
inlineIcons = true,
...divProps ...divProps
} = Astro.props } = Astro.props
--- ---
@@ -49,11 +52,17 @@ const {
'not-pointer-coarse:no-scrollbar -ml-4 flex shrink grow items-center gap-2 overflow-x-auto mask-r-from-[calc(100%-var(--spacing)*16)] pr-12 pl-4', 'not-pointer-coarse:no-scrollbar -ml-4 flex shrink grow items-center gap-2 overflow-x-auto mask-r-from-[calc(100%-var(--spacing)*16)] pr-12 pl-4',
className className
)} )}
aria-label="Applied filters"
{...divProps} {...divProps}
> >
{ {
filters.q && ( filters.q && (
<ServiceFiltersPill text={`"${filters.q}"`} searchParamName="q" searchParamValue={filters.q} /> <ServiceFiltersPill
text={`"${filters.q}"`}
searchParamName="q"
searchParamValue={filters.q}
inlineIcons={inlineIcons}
/>
) )
} }
@@ -68,6 +77,7 @@ const {
icon={category.icon} icon={category.icon}
searchParamName="categories" searchParamName="categories"
searchParamValue={categorySlug} searchParamValue={categorySlug}
inlineIcons={inlineIcons}
/> />
) )
}) })
@@ -82,6 +92,7 @@ const {
searchParamName="currencies" searchParamName="currencies"
searchParamValue={currency.slug} searchParamValue={currency.slug}
icon={currency.icon} icon={currency.icon}
inlineIcons={inlineIcons}
/> />
) )
}) })
@@ -96,6 +107,7 @@ const {
icon={networkOption.icon} icon={networkOption.icon}
searchParamName="networks" searchParamName="networks"
searchParamValue={network} searchParamValue={network}
inlineIcons={inlineIcons}
/> />
) )
}) })
@@ -106,6 +118,7 @@ const {
text={`KYC Lvl ≤ ${filters['max-kyc'].toLocaleString()}`} text={`KYC Lvl ≤ ${filters['max-kyc'].toLocaleString()}`}
icon="ri:shield-keyhole-line" icon="ri:shield-keyhole-line"
searchParamName="max-kyc" searchParamName="max-kyc"
inlineIcons={inlineIcons}
/> />
) )
} }
@@ -115,6 +128,7 @@ const {
text={`Rating ≥ ${filters['user-rating'].toLocaleString()}★`} text={`Rating ≥ ${filters['user-rating'].toLocaleString()}★`}
icon="ri:star-fill" icon="ri:star-fill"
searchParamName="user-rating" searchParamName="user-rating"
inlineIcons={inlineIcons}
/> />
) )
} }
@@ -124,6 +138,7 @@ const {
text={`Score ≥ ${filters['min-score'].toLocaleString()}`} text={`Score ≥ ${filters['min-score'].toLocaleString()}`}
icon="ri:medal-line" icon="ri:medal-line"
searchParamName="min-score" searchParamName="min-score"
inlineIcons={inlineIcons}
/> />
) )
} }
@@ -134,6 +149,7 @@ const {
icon="ri:filter-3-line" icon="ri:filter-3-line"
searchParamName="attribute-mode" searchParamName="attribute-mode"
searchParamValue="and" searchParamValue="and"
inlineIcons={inlineIcons}
/> />
) )
} }
@@ -151,6 +167,7 @@ const {
text={`${prefix}: ${attribute.title}`} text={`${prefix}: ${attribute.title}`}
searchParamName={`attr-${attributeId}`} searchParamName={`attr-${attributeId}`}
searchParamValue={attributeValue} searchParamValue={attributeValue}
inlineIcons={inlineIcons}
/> />
) )
}) })
@@ -175,6 +192,7 @@ const {
iconClass={verificationStatusInfo.classNames.icon} iconClass={verificationStatusInfo.classNames.icon}
searchParamName="verification" searchParamName="verification"
searchParamValue={verificationStatusInfo.slug} searchParamValue={verificationStatusInfo.slug}
inlineIcons={inlineIcons}
/> />
) )
}) })

View File

@@ -7,13 +7,21 @@ import { cn } from '../lib/cn'
import type { HTMLAttributes } from 'astro/types' import type { HTMLAttributes } from 'astro/types'
type Props = Omit<HTMLAttributes<'a'>, 'href' | 'rel' | 'target'> & { type Props = Omit<HTMLAttributes<'a' | 'span'>, 'href' | 'rel' | 'target'> & {
url: string url: string
referral: string | null referral: string | null
enableMinWidth?: boolean enableMinWidth?: boolean
isScam?: boolean
} }
const { url: baseUrl, referral, class: className, enableMinWidth = false, ...htmlProps } = Astro.props const {
url: baseUrl,
referral,
class: className,
enableMinWidth = false,
isScam = false,
...htmlProps
} = Astro.props
function makeLink(url: string, referral: string | null) { function makeLink(url: string, referral: string | null) {
const hostname = new URL(url).hostname const hostname = new URL(url).hostname
@@ -124,28 +132,39 @@ const link = makeLink(baseUrl, referral)
if (!z.string().url().safeParse(link.url).success) { if (!z.string().url().safeParse(link.url).success) {
console.error(`Invalid service URL with referral: ${link.url}`) console.error(`Invalid service URL with referral: ${link.url}`)
} }
const Tag = isScam ? 'span' : 'a'
--- ---
<a <Tag
href={link.url} href={isScam ? undefined : link.url}
target="_blank" target={isScam ? undefined : '_blank'}
rel="noopener noreferrer" rel={isScam ? undefined : 'noopener noreferrer'}
class={cn( class={cn(
'2xs:text-sm 2xs:h-8 2xs:gap-2 focus-visible:ring-offset-night-700 inline-flex h-6 items-center gap-1 rounded-full bg-white text-xs whitespace-nowrap text-black focus-visible:ring-4 focus-visible:ring-orange-500 focus-visible:ring-offset-2 focus-visible:outline-none', '2xs:text-sm 2xs:h-8 2xs:gap-2 focus-visible:ring-offset-night-700 inline-flex h-6 items-center gap-1 rounded-full bg-white text-xs whitespace-nowrap text-black focus-visible:ring-4 focus-visible:ring-orange-500 focus-visible:ring-offset-2 focus-visible:outline-none',
isScam && 'bg-day-800 cursor-not-allowed text-red-300',
className className
)} )}
title={link.url}
{...htmlProps} {...htmlProps}
> >
<Icon name={link.icon} class="2xs:ml-2 2xs:size-5 2xs:-mr-0.5 -mr-0.25 ml-1 size-4" /> <Icon
name={isScam ? 'ri:alert-line' : link.icon}
class={cn('2xs:ml-2 2xs:size-5 2xs:-mr-0.5 -mr-0.25 ml-1 size-4', isScam && 'text-red-400')}
/>
<span class={cn('font-title font-bold', { 'min-w-[29ch]': enableMinWidth })}> <span class={cn('font-title font-bold', { 'min-w-[29ch]': enableMinWidth })}>
{ {
link.textBits.map((textBit) => ( link.textBits.map((textBit) => (
<span class={cn(textBit.style === 'irrelevant' && 'text-zinc-500')}>{textBit.text}</span> <span class={cn(textBit.style === 'irrelevant' && 'opacity-60')}>{textBit.text}</span>
)) ))
} }
</span> </span>
<Icon {
name="ri:arrow-right-line" !isScam && (
class="2xs:size-6 mr-1 size-4 rounded-full bg-orange-500 p-0.5 text-white" <Icon
/> name="ri:arrow-right-line"
</a> class="2xs:size-6 mr-1 size-4 rounded-full bg-orange-500 p-0.5 text-white"
/>
)
}
</Tag>

View File

@@ -1,15 +1,15 @@
--- ---
import { Icon } from 'astro-icon/components' import { Icon } from 'astro-icon/components'
import { kycLevels } from '../constants/kycLevels'
import { cn } from '../lib/cn' import { cn } from '../lib/cn'
import { makeOverallScoreInfo } from '../lib/overallScore' import { makeOverallScoreInfo } from '../lib/overallScore'
import { type ServicesFiltersObject, type ServicesFiltersOptions } from '../pages/index.astro' import { type ServicesFiltersObject } from '../pages/index.astro'
import Button from './Button.astro' import Button from './Button.astro'
import PillsRadioGroup from './PillsRadioGroup.astro' import PillsRadioGroup from './PillsRadioGroup.astro'
import Tooltip from './Tooltip.astro' import Tooltip from './Tooltip.astro'
import type { ServicesFiltersOptions } from '../lib/searchFiltersOptions'
import type { HTMLAttributes } from 'astro/types' import type { HTMLAttributes } from 'astro/types'
export type Props = HTMLAttributes<'form'> & { export type Props = HTMLAttributes<'form'> & {
@@ -111,7 +111,7 @@ const {
<legend class="font-title mb-3 leading-none text-green-500">Type</legend> <legend class="font-title mb-3 leading-none text-green-500">Type</legend>
<ul class="[&:not(:has(~_.peer:checked))]:[&>li:not([data-show-always])]:hidden"> <ul class="[&:not(:has(~_.peer:checked))]:[&>li:not([data-show-always])]:hidden">
{ {
options.categories?.map((category) => ( options.categories.map((category) => (
<li data-show-always={category.showAlways ? '' : undefined}> <li data-show-always={category.showAlways ? '' : undefined}>
<label class="flex cursor-pointer items-center gap-2 text-sm text-white"> <label class="flex cursor-pointer items-center gap-2 text-sm text-white">
<input <input
@@ -252,7 +252,7 @@ const {
</div> </div>
<div class="text-day-400 mt-1 flex justify-between px-1 text-xs"> <div class="text-day-400 mt-1 flex justify-between px-1 text-xs">
{ {
kycLevels.map((level) => ( options.kycLevels.map((level) => (
<span class="flex w-0 items-center justify-center text-center whitespace-nowrap"> <span class="flex w-0 items-center justify-center text-center whitespace-nowrap">
{level.value} {level.value}
<Icon name={level.icon} class="ms-1 size-3 shrink-0" /> <Icon name={level.icon} class="ms-1 size-3 shrink-0" />
@@ -334,7 +334,7 @@ const {
<li data-show-always={attribute.showAlways ? '' : undefined} class="cursor-pointer"> <li data-show-always={attribute.showAlways ? '' : undefined} class="cursor-pointer">
<fieldset class="relative flex max-w-full min-w-0 cursor-pointer items-center text-sm text-white"> <fieldset class="relative flex max-w-full min-w-0 cursor-pointer items-center text-sm text-white">
<legend class="sr-only"> <legend class="sr-only">
{attribute.title} ({attribute._count?.services}) {attribute.title} ({attribute._count.services})
</legend> </legend>
<input <input
type="radio" type="radio"
@@ -414,10 +414,13 @@ const {
class={cn('mr-2 size-3 shrink-0 opacity-80', attribute.typeInfo.classNames.icon)} class={cn('mr-2 size-3 shrink-0 opacity-80', attribute.typeInfo.classNames.icon)}
aria-hidden="true" aria-hidden="true"
/> />
<span class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap"> <span
class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap"
title={attribute.title}
>
{attribute.title} {attribute.title}
</span> </span>
<span class="text-day-500 ml-2 font-normal">{attribute._count?.services}</span> <span class="text-day-500 ml-2 font-normal">{attribute._count.services}</span>
</label> </label>
<label <label
for={emptyId} for={emptyId}
@@ -429,10 +432,13 @@ const {
class={cn('mr-2 size-3 shrink-0 opacity-100', attribute.typeInfo.classNames.icon)} class={cn('mr-2 size-3 shrink-0 opacity-100', attribute.typeInfo.classNames.icon)}
aria-hidden="true" aria-hidden="true"
/> />
<span class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap"> <span
class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap"
title={attribute.title}
>
{attribute.title} {attribute.title}
</span> </span>
<span class="text-day-500 ml-2 font-normal">{attribute._count?.services}</span> <span class="text-day-500 ml-2 font-normal">{attribute._count.services}</span>
</label> </label>
</fieldset> </fieldset>
</li> </li>

View File

@@ -3,7 +3,6 @@ import { Icon } from 'astro-icon/components'
import { uniq, orderBy } from 'lodash-es' import { uniq, orderBy } from 'lodash-es'
import { getCurrencyInfo } from '../constants/currencies' import { getCurrencyInfo } from '../constants/currencies'
import { getKycLevelInfo } from '../constants/kycLevels'
import { verificationStatusesByValue, getVerificationStatusInfo } from '../constants/verificationStatus' import { verificationStatusesByValue, getVerificationStatusInfo } from '../constants/verificationStatus'
import { areEqualArraysWithoutOrder } from '../lib/arrays' import { areEqualArraysWithoutOrder } from '../lib/arrays'
import { cn } from '../lib/cn' import { cn } from '../lib/cn'
@@ -15,7 +14,8 @@ import Button from './Button.astro'
import ServiceCard from './ServiceCard.astro' import ServiceCard from './ServiceCard.astro'
import ServiceFiltersPillsRow from './ServiceFiltersPillsRow.astro' import ServiceFiltersPillsRow from './ServiceFiltersPillsRow.astro'
import type { AttributeOption, ServicesFiltersObject, ServicesFiltersOptions } from '../pages/index.astro' import type { ServicesFiltersOptions } from '../lib/searchFiltersOptions'
import type { AttributeOption, ServicesFiltersObject } from '../pages/index.astro'
import type { Prisma } from '@prisma/client' import type { Prisma } from '@prisma/client'
import type { ComponentProps, HTMLAttributes } from 'astro/types' import type { ComponentProps, HTMLAttributes } from 'astro/types'
@@ -82,6 +82,7 @@ const urlIfIncludingCommunity = urlWithParams(Astro.url, {
]), ]),
}) })
// NOTE: If you make changes to this function, remember to update the sitemap: src/pages/sitemaps/search.xml.ts
const searchTitle = (() => { const searchTitle = (() => {
if (filters.q) { if (filters.q) {
return `Search results for “${filters.q}”` return `Search results for “${filters.q}”`
@@ -158,8 +159,7 @@ const searchTitle = (() => {
} }
if (filters['max-kyc'] === 0) { if (filters['max-kyc'] === 0) {
const kycLevelInfo = getKycLevelInfo(String(filters['max-kyc'])) kycLevel = 'without KYC'
kycLevel = `with ${kycLevelInfo.name}`
prefix = '' prefix = ''
} else if (filters['max-kyc'] <= 3) { } else if (filters['max-kyc'] <= 3) {
kycLevel = `with KYC level ${filters['max-kyc']} or better` kycLevel = `with KYC level ${filters['max-kyc']} or better`
@@ -190,6 +190,7 @@ const searchTitle = (() => {
categories={categories} categories={categories}
attributes={attributes} attributes={attributes}
attributeOptions={attributeOptions} attributeOptions={attributeOptions}
inlineIcons={inlineIcons}
/> />
</div> </div>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
@@ -201,6 +202,7 @@ const searchTitle = (() => {
name="ri:loader-4-line" name="ri:loader-4-line"
id="search-indicator" id="search-indicator"
class="htmx-request:opacity-100 xs:-mx-1.5 -mx-1 inline-block size-4 animate-spin text-white opacity-0 transition-opacity duration-500 sm:-mx-3" class="htmx-request:opacity-100 xs:-mx-1.5 -mx-1 inline-block size-4 animate-spin text-white opacity-0 transition-opacity duration-500 sm:-mx-3"
aria-hidden="true"
is:inline={inlineIcons} is:inline={inlineIcons}
/> />
@@ -346,11 +348,9 @@ const searchTitle = (() => {
</div> </div>
) : ( ) : (
<> <>
<div class="mt-6 grid grid-cols-1 gap-4 sm:gap-6 md:grid-cols-[repeat(auto-fill,minmax(calc(var(--spacing)*80),1fr))]"> <ol class="mt-6 grid grid-cols-1 gap-4 sm:gap-6 md:grid-cols-[repeat(auto-fill,minmax(calc(var(--spacing)*80),1fr))]">
{services.map((service, i) => ( {services.map((service, i) => (
<ServiceCard <li
inlineIcons={inlineIcons}
service={service}
data-hx-search-results-card data-hx-search-results-card
{...(i === services.length - 1 && currentPage < totalPages {...(i === services.length - 1 && currentPage < totalPages
? { ? {
@@ -361,9 +361,11 @@ const searchTitle = (() => {
'hx-indicator': '#infinite-scroll-indicator', 'hx-indicator': '#infinite-scroll-indicator',
} }
: {})} : {})}
/> >
<ServiceCard inlineIcons={inlineIcons} service={service} />
</li>
))} ))}
</div> </ol>
<div class="no-js:hidden mt-8 flex justify-center" id="infinite-scroll-indicator"> <div class="no-js:hidden mt-8 flex justify-center" id="infinite-scroll-indicator">
<div class="htmx-request:opacity-100 flex items-center gap-2 opacity-0 transition-opacity duration-500"> <div class="htmx-request:opacity-100 flex items-center gap-2 opacity-0 transition-opacity duration-500">

View File

@@ -33,6 +33,7 @@ const {
enabled && ( enabled && (
<span <span
tabindex="-1" tabindex="-1"
aria-hidden="true"
class={cn( class={cn(
'pointer-events-none hidden select-none group-hover/tooltip:flex', 'pointer-events-none hidden select-none group-hover/tooltip:flex',
'ease-out-cubic scale-75 opacity-0 transition-all transition-discrete duration-100 group-hover/tooltip:scale-100 group-hover/tooltip:opacity-100 starting:group-hover/tooltip:scale-75 starting:group-hover/tooltip:opacity-0', 'ease-out-cubic scale-75 opacity-0 transition-all transition-discrete duration-100 group-hover/tooltip:scale-100 group-hover/tooltip:opacity-100 starting:group-hover/tooltip:scale-75 starting:group-hover/tooltip:opacity-0',

View File

@@ -0,0 +1,76 @@
import { countries as countriesData, type TCountryCode } from 'countries-list'
import { countries as flagCountries } from 'country-flag-icons'
import getUnicodeFlagIcon from 'country-flag-icons/unicode'
import { makeHelpersForOptions } from '../lib/makeHelpersForOptions'
type CountryInfo<T extends string | null | undefined = string> = {
code: T
name: string
flag: string
slug: string
order: number
}
// Convert countries-list data to our format, ensuring we only use countries that have flags
const countriesArray = Object.entries(countriesData)
.filter(([code]) => flagCountries.includes(code as TCountryCode))
.map(([code, data]) => ({
code: code as TCountryCode,
name: data.name,
flag: getUnicodeFlagIcon(code) || '🏳️',
slug: code.toLowerCase(),
order: data.name.charCodeAt(0), // Sort alphabetically by first letter
}))
// Pre-sort the array alphabetically by name for performance
.sort((a, b) => a.name.localeCompare(b.name))
// Create a map for efficient lookups
const countriesMap = new Map(countriesArray.map((country) => [country.code, country]))
export const {
dataArray: countries,
dataObject: countriesById,
getFn: getCountryInfo,
getFnSlug: getCountryInfoBySlug,
zodEnumBySlug: countriesZodEnumBySlug,
zodEnumById: countriesZodEnumById,
keyToSlug: countryCodeToSlug,
slugToKey: countrySlugToCode,
} = makeHelpersForOptions(
'code',
(code): CountryInfo<typeof code> => {
// For null, undefined, or empty string, return a default "No Country" object
if (!code) {
return {
code,
name: 'No Country',
flag: '🏳️',
slug: '',
order: 999,
} as CountryInfo<typeof code>
}
// Try to find the country in our pre-built map
const country = countriesMap.get(code as TCountryCode)
// If found, return it; otherwise, return a default "Unknown Country" object
if (country) {
return country as CountryInfo
} else {
return {
code,
name: 'Unknown Country',
flag: '🏳️',
slug: code.toLowerCase(),
order: 999,
} as CountryInfo
}
},
countriesArray
)
// Helper function to validate country code
export const isValidCountryCode = (code: string): code is TCountryCode => {
return code in countriesData && flagCountries.includes(code as TCountryCode)
}

View File

@@ -0,0 +1,33 @@
import { makeHelpersForOptions } from '../lib/makeHelpersForOptions'
import { transformCase } from '../lib/strings'
type ReadStatusInfo<T extends string | null | undefined = string> = {
id: T
label: string
readValue: boolean
}
export const {
dataArray: readStatuses,
getFn: getReadStatus,
zodEnumById: readStatusZodEnum,
} = makeHelpersForOptions(
'id',
(id): ReadStatusInfo<typeof id> => ({
id,
label: id ? transformCase(id, 'title') : String(id),
readValue: false,
}),
[
{
id: 'unread',
label: 'Unread',
readValue: false,
},
{
id: 'read',
label: 'Read',
readValue: true,
},
] as const satisfies ReadStatusInfo[]
)

View File

@@ -58,9 +58,13 @@ const ogImageTemplateData = {
class="prose prose-invert prose-headings:text-green-400 prose-h1:text-[2.5rem] prose-h1:font-bold prose-h1:my-8 prose-h1:drop-shadow-[0_0_10px_rgba(0,255,0,0.3)] prose-h2:text-green-500 prose-h2:text-[1.8rem] prose-h2:font-semibold prose-h2:my-6 prose-h2:border-b prose-h2:border-green-900 prose-h2:pb-1 prose-h3:text-green-600 prose-h3:text-[1.4rem] prose-h3:font-semibold prose-h3:my-4 prose-h4:text-green-700 prose-h4:text-[1.2rem] prose-h4:font-semibold prose-h4:my-3 prose-strong:font-semibold prose-strong:drop-shadow-[0_0_5px_rgba(0,255,0,0.2)] prose-p:text-gray-300 prose-p:my-4 prose-p:leading-relaxed prose-a:text-green-400 prose-a:no-underline prose-a:transition-all prose-a:border-b prose-a:border-green-900 prose-a:hover:text-green-400 prose-a:hover:drop-shadow-[0_0_8px_rgba(0,255,0,0.4)] prose-a:hover:border-green-400 prose-ul:text-gray-300 prose-ol:text-gray-300 prose-li:my-2 prose-li:leading-relaxed mx-auto" class="prose prose-invert prose-headings:text-green-400 prose-h1:text-[2.5rem] prose-h1:font-bold prose-h1:my-8 prose-h1:drop-shadow-[0_0_10px_rgba(0,255,0,0.3)] prose-h2:text-green-500 prose-h2:text-[1.8rem] prose-h2:font-semibold prose-h2:my-6 prose-h2:border-b prose-h2:border-green-900 prose-h2:pb-1 prose-h3:text-green-600 prose-h3:text-[1.4rem] prose-h3:font-semibold prose-h3:my-4 prose-h4:text-green-700 prose-h4:text-[1.2rem] prose-h4:font-semibold prose-h4:my-3 prose-strong:font-semibold prose-strong:drop-shadow-[0_0_5px_rgba(0,255,0,0.2)] prose-p:text-gray-300 prose-p:my-4 prose-p:leading-relaxed prose-a:text-green-400 prose-a:no-underline prose-a:transition-all prose-a:border-b prose-a:border-green-900 prose-a:hover:text-green-400 prose-a:hover:drop-shadow-[0_0_8px_rgba(0,255,0,0.4)] prose-a:hover:border-green-400 prose-ul:text-gray-300 prose-ol:text-gray-300 prose-li:my-2 prose-li:leading-relaxed mx-auto"
> >
<h1 class="mb-0!">{frontmatter.title}</h1> <h1 class="mb-0!">{frontmatter.title}</h1>
<p class="mt-2! opacity-70"> {
Updated {frontmatter.updatedAt && <TimeFormatted date={new Date(frontmatter.updatedAt)} />} !!frontmatter.updatedAt && (
</p> <p class="mt-2! opacity-70">
Updated <TimeFormatted date={new Date(frontmatter.updatedAt)} />
</p>
)
}
<slot /> <slot />
</div> </div>

View File

@@ -1,8 +1,10 @@
import { differenceInMonths, differenceInYears } from 'date-fns' import { differenceInMonths, differenceInYears } from 'date-fns'
import he from 'he'
import { orderBy } from 'lodash-es' import { orderBy } from 'lodash-es'
import { getAttributeCategoryInfo } from '../constants/attributeCategories' import { getAttributeCategoryInfo } from '../constants/attributeCategories'
import { getAttributeTypeInfo } from '../constants/attributeTypes' import { getAttributeTypeInfo } from '../constants/attributeTypes'
import { getCountryInfo } from '../constants/countries'
import { kycLevelClarifications } from '../constants/kycLevelClarifications' import { kycLevelClarifications } from '../constants/kycLevelClarifications'
import { kycLevels } from '../constants/kycLevels' import { kycLevels } from '../constants/kycLevels'
import { serviceVisibilitiesById } from '../constants/serviceVisibility' import { serviceVisibilitiesById } from '../constants/serviceVisibility'
@@ -47,6 +49,8 @@ type NonDbAttributeFull = NonDbAttribute & {
kycLevel: true kycLevel: true
kycLevelClarification: true kycLevelClarification: true
operatingSince: true operatingSince: true
registrationCountryCode: true
registeredCompanyName: true
} }
}> }>
) => Partial<Pick<NonDbAttribute, 'description' | 'title'>> & { ) => Partial<Pick<NonDbAttribute, 'description' | 'title'>> & {
@@ -306,6 +310,42 @@ export const nonDbAttributes: NonDbAttributeFull[] = [
} }
}, },
}, },
{
slug: 'legally-registered',
title: 'Legally registered',
type: 'INFO',
category: 'TRUST',
description: 'This service is legally registered as a company.',
privacyPoints: 0,
trustPoints: 2,
links: [],
customize: (service) => {
const countryCode = service.registrationCountryCode
const companyName = service.registeredCompanyName
if (!countryCode && !companyName) {
return { show: false }
}
const countryInfo = countryCode ? getCountryInfo(countryCode) : null
const flagTitle = countryInfo ? `${countryInfo.flag} Legally registered` : 'Legally registered'
let description = 'Legally registered.'
if (companyName && countryCode && countryInfo) {
description = `Legally registered as **${he.escape(companyName)}** in **${countryInfo.name}**.`
} else if (companyName) {
description = `Legally registered as **${he.escape(companyName)}**.`
} else if (countryCode && countryInfo) {
description = `Legally registered in **${countryInfo.name}**.`
}
return {
show: true,
title: flagTitle,
description,
}
},
},
] ]
export function sortAttributes< export function sortAttributes<

View File

@@ -0,0 +1,187 @@
import { orderBy, groupBy } from 'lodash-es'
import { getAttributeCategoryInfo } from '../constants/attributeCategories'
import { getAttributeTypeInfo } from '../constants/attributeTypes'
import { currencies } from '../constants/currencies'
import { kycLevels } from '../constants/kycLevels'
import { networks } from '../constants/networks'
import { verificationStatuses } from '../constants/verificationStatus'
import type { Prisma } from '@prisma/client'
const MIN_CATEGORIES_TO_SHOW = 8
const MIN_ATTRIBUTES_TO_SHOW = 8
export const sortOptions = [
{
value: 'score-desc',
label: 'Score (High → Low)',
orderBy: {
key: 'overallScore',
direction: 'desc',
},
},
{
value: 'score-asc',
label: 'Score (Low → High)',
orderBy: {
key: 'overallScore',
direction: 'asc',
},
},
{
value: 'name-asc',
label: 'Name (A → Z)',
orderBy: {
key: 'name',
direction: 'asc',
},
},
{
value: 'name-desc',
label: 'Name (Z → A)',
orderBy: {
key: 'name',
direction: 'desc',
},
},
{
value: 'recent',
label: 'Date listed (New → Old)',
orderBy: {
key: 'listedAt',
direction: 'desc',
},
},
{
value: 'oldest',
label: 'Date listed (Old → New)',
orderBy: {
key: 'listedAt',
direction: 'asc',
},
},
] as const satisfies {
value: string
label: string
orderBy: {
key: keyof Prisma.ServiceSelect
direction: 'asc' | 'desc'
}
}[]
export const defaultSortOption = sortOptions[0]
export const modeOptions = [
{
value: 'or',
label: 'OR',
},
{
value: 'and',
label: 'AND',
},
] as const satisfies {
value: string
label: string
}[]
export function makeSearchFiltersOptions({
filters,
categories,
attributes,
}: {
filters: {
categories: string[]
attr: Record<number, '' | 'no' | 'yes'> | undefined
} | null
categories: Prisma.CategoryGetPayload<{
select: {
name: true
namePluralLong: true
slug: true
icon: true
_count: {
select: {
services: {
where: {
serviceVisibility: { in: ['PUBLIC', 'ARCHIVED'] }
}
}
}
}
}
}>[]
attributes: Prisma.AttributeGetPayload<{
select: {
id: true
slug: true
title: true
category: true
type: true
_count: {
select: {
services: true
}
}
}
}>[]
}) {
const attributesByCategory = orderBy(
Object.entries(
groupBy(
attributes.map((attr) => {
return {
typeInfo: getAttributeTypeInfo(attr.type),
...attr,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
value: filters?.attr?.[attr.id] || undefined,
}
}),
'category'
)
).map(([category, attributes]) => ({
category,
categoryInfo: getAttributeCategoryInfo(category),
attributes: orderBy(
attributes,
['value', 'type', '_count.services', 'title'],
['asc', 'asc', 'desc', 'asc']
).map((attr, i) => ({
...attr,
showAlways: i < MIN_ATTRIBUTES_TO_SHOW || attr.value !== undefined,
})),
})),
['category'],
['asc']
)
const categoriesSorted = orderBy(
categories.map((category) => {
const checked = filters?.categories.includes(category.slug) ?? false
return {
...category,
checked,
}
}),
['checked', '_count.services', 'name'],
['desc', 'desc', 'asc']
).map((category, i) => ({
...category,
showAlways: i < MIN_CATEGORIES_TO_SHOW || category.checked,
}))
return {
currencies,
categories: categoriesSorted,
sort: sortOptions,
modeOptions,
network: networks,
verification: verificationStatuses,
attributesByCategory,
kycLevels,
} as const
}
export type ServicesFiltersOptions = ReturnType<typeof makeSearchFiltersOptions>

View File

@@ -5,6 +5,7 @@ import { Icon } from 'astro-icon/components'
import BadgeSmall from '../../components/BadgeSmall.astro' import BadgeSmall from '../../components/BadgeSmall.astro'
import CommentModeration from '../../components/CommentModeration.astro' import CommentModeration from '../../components/CommentModeration.astro'
import MyPicture from '../../components/MyPicture.astro' import MyPicture from '../../components/MyPicture.astro'
import Pagination from '../../components/Pagination.astro'
import TimeFormatted from '../../components/TimeFormatted.astro' import TimeFormatted from '../../components/TimeFormatted.astro'
import UserBadge from '../../components/UserBadge.astro' import UserBadge from '../../components/UserBadge.astro'
import { import {
@@ -27,7 +28,7 @@ if (!user || (!user.admin && !user.moderator)) {
const { data: params } = zodParseQueryParamsStoringErrors( const { data: params } = zodParseQueryParamsStoringErrors(
{ {
status: commentStatusFiltersZodEnum.default('all'), status: commentStatusFiltersZodEnum.default('all'),
page: z.number().int().positive().default(1), page: z.coerce.number().int().positive().default(1),
}, },
Astro Astro
) )
@@ -241,29 +242,5 @@ const totalPages = Math.ceil(totalComments / PAGE_SIZE)
</div> </div>
<!-- Pagination --> <!-- Pagination -->
{ {totalPages > 1 && <Pagination currentPage={params.page} totalPages={totalPages} class="mt-8" />}
totalPages > 1 && (
<div class="mt-8 flex justify-center gap-2">
{params.page > 1 && (
<a
href={urlWithParams(Astro.url, { page: params.page - 1 })}
class="font-title rounded-md border border-zinc-700 px-3 py-1 text-sm transition-colors hover:border-green-500/50"
>
Previous
</a>
)}
<span class="font-title px-3 py-1 text-sm">
Page {params.page} of {totalPages}
</span>
{params.page < totalPages && (
<a
href={urlWithParams(Astro.url, { page: params.page + 1 })}
class="font-title rounded-md border border-zinc-700 px-3 py-1 text-sm transition-colors hover:border-green-500/50"
>
Next
</a>
)}
</div>
)
}
</BaseLayout> </BaseLayout>

View File

@@ -10,6 +10,7 @@ import Button from '../../../../components/Button.astro'
import FormSection from '../../../../components/FormSection.astro' import FormSection from '../../../../components/FormSection.astro'
import FormSubSection from '../../../../components/FormSubSection.astro' import FormSubSection from '../../../../components/FormSubSection.astro'
import InputCardGroup from '../../../../components/InputCardGroup.astro' import InputCardGroup from '../../../../components/InputCardGroup.astro'
import InputCheckbox from '../../../../components/InputCheckbox.astro'
import InputCheckboxGroup from '../../../../components/InputCheckboxGroup.astro' import InputCheckboxGroup from '../../../../components/InputCheckboxGroup.astro'
import InputImageFile from '../../../../components/InputImageFile.astro' import InputImageFile from '../../../../components/InputImageFile.astro'
import InputSelect from '../../../../components/InputSelect.astro' import InputSelect from '../../../../components/InputSelect.astro'
@@ -24,6 +25,7 @@ import UserBadge from '../../../../components/UserBadge.astro'
import { getAttributeCategoryInfo } from '../../../../constants/attributeCategories' import { getAttributeCategoryInfo } from '../../../../constants/attributeCategories'
import { getAttributeTypeInfo } from '../../../../constants/attributeTypes' import { getAttributeTypeInfo } from '../../../../constants/attributeTypes'
import { contactMethodUrlTypes, formatContactMethod } from '../../../../constants/contactMethods' import { contactMethodUrlTypes, formatContactMethod } from '../../../../constants/contactMethods'
import { countries } from '../../../../constants/countries'
import { currencies } from '../../../../constants/currencies' import { currencies } from '../../../../constants/currencies'
import { eventTypes, getEventTypeInfo } from '../../../../constants/eventTypes' import { eventTypes, getEventTypeInfo } from '../../../../constants/eventTypes'
import { kycLevelClarifications } from '../../../../constants/kycLevelClarifications' import { kycLevelClarifications } from '../../../../constants/kycLevelClarifications'
@@ -385,6 +387,36 @@ const apiCalls = await Astro.locals.banners.try(
/> />
</div> </div>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<InputText
label="Registered Company Name"
name="registeredCompanyName"
description="Official name of the registered company"
inputProps={{
value: service.registeredCompanyName,
placeholder: 'e.g. Example Corp Ltd.',
}}
error={serviceInputErrors.registeredCompanyName}
/>
<InputSelect
name="registrationCountryCode"
label="Company Registration Country"
description="Country where the service company is legally registered"
options={[
{ label: 'Not registered', value: '' },
...countries
.sort((a, b) => a.name.localeCompare(b.name))
.map((country) => ({
label: `${country.flag} ${country.name}`,
value: country.code,
}))
]}
selectedValue={service.registrationCountryCode || ''}
error={serviceInputErrors.registrationCountryCode}
/>
</div>
<div class="flex items-center justify-between gap-2"> <div class="flex items-center justify-between gap-2">
<InputImageFile <InputImageFile
label="Image" label="Image"
@@ -545,6 +577,24 @@ const apiCalls = await Astro.locals.banners.try(
cardSize="sm" cardSize="sm"
/> />
<InputCheckbox
label="Strict Commenting"
name="strictCommentingEnabled"
checked={service.strictCommentingEnabled}
descriptionInline="Require proof of being a client for comments."
/>
<InputTextArea
label="Comment Section Message"
name="commentSectionMessage"
value={service.commentSectionMessage ?? ''}
description="Markdown supported"
inputProps={{
rows: 4,
}}
error={serviceInputErrors.commentSectionMessage}
/>
<InputSubmitButton label="Update" icon="ri:save-line" hideCancel /> <InputSubmitButton label="Update" icon="ri:save-line" hideCancel />
</form> </form>
</FormSection> </FormSection>

View File

@@ -1,23 +1,57 @@
--- ---
import { AttributeCategory, Currency, VerificationStatus } from '@prisma/client' import { ServiceVisibility, VerificationStatus } from '@prisma/client'
import { Icon } from 'astro-icon/components'
import { actions, isInputError } from 'astro:actions' import { actions, isInputError } from 'astro:actions'
import { orderBy } from 'lodash-es'
import InputCardGroup from '../../../components/InputCardGroup.astro'
import InputCheckbox from '../../../components/InputCheckbox.astro'
import InputCheckboxGroup from '../../../components/InputCheckboxGroup.astro'
import InputImageFile from '../../../components/InputImageFile.astro'
import InputSelect from '../../../components/InputSelect.astro'
import InputSubmitButton from '../../../components/InputSubmitButton.astro'
import InputText from '../../../components/InputText.astro'
import InputTextArea from '../../../components/InputTextArea.astro'
import { getAttributeCategoryInfo } from '../../../constants/attributeCategories'
import { getAttributeTypeInfo } from '../../../constants/attributeTypes'
import { contactMethodUrlTypes } from '../../../constants/contactMethods'
import { countries } from '../../../constants/countries'
import { currencies } from '../../../constants/currencies'
import { kycLevelClarifications } from '../../../constants/kycLevelClarifications'
import { kycLevels } from '../../../constants/kycLevels'
import { serviceVisibilities } from '../../../constants/serviceVisibility'
import { verificationStatuses } from '../../../constants/verificationStatus'
import BaseLayout from '../../../layouts/BaseLayout.astro' import BaseLayout from '../../../layouts/BaseLayout.astro'
import { cn } from '../../../lib/cn'
import { prisma } from '../../../lib/prisma' import { prisma } from '../../../lib/prisma'
const categories = await Astro.locals.banners.try('Failed to fetch categories', () => const [categories, attributes] = await Astro.locals.banners.tryMany([
prisma.category.findMany({ [
orderBy: { name: 'asc' }, 'Failed to fetch categories',
}) () =>
) prisma.category.findMany({
orderBy: { name: 'asc' },
const attributes = await Astro.locals.banners.try('Failed to fetch attributes', () => select: {
prisma.attribute.findMany({ id: true,
orderBy: { category: 'asc' }, name: true,
}) icon: true,
) },
}),
[],
],
[
'Failed to fetch attributes',
() =>
prisma.attribute.findMany({
orderBy: { category: 'asc' },
select: {
id: true,
title: true,
category: true,
type: true,
},
}),
[],
],
])
const result = Astro.getActionResult(actions.admin.service.create) const result = Astro.getActionResult(actions.admin.service.create)
Astro.locals.banners.addIfSuccess(result, 'Service created successfully') Astro.locals.banners.addIfSuccess(result, 'Service created successfully')
@@ -27,353 +61,287 @@ if (result && !result.error) {
const inputErrors = isInputError(result?.error) ? result.error.fields : {} const inputErrors = isInputError(result?.error) ? result.error.fields : {}
--- ---
<BaseLayout pageTitle="Create Service" widthClassName="max-w-screen-sm"> <BaseLayout
<section class="mb-8"> pageTitle="Create Service"
<div class="font-title mb-4"> description="Create a new service for KYCnot.me"
<span class="text-sm text-green-500">service.create</span> widthClassName="max-w-screen-md"
>
<h1 class="font-title mt-12 mb-6 text-center text-3xl font-bold">Create Service</h1>
<form
method="POST"
action={actions.admin.service.create}
enctype="multipart/form-data"
class="space-y-6"
>
<InputText
label="Name"
name="name"
inputProps={{
required: true,
maxlength: 40,
}}
error={inputErrors.name}
/>
<InputTextArea
label="Description"
name="description"
inputProps={{
required: true,
}}
error={inputErrors.description}
/>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<InputTextArea
label="Service URLs"
description="One per line. Accepts **Web**, **Onion**, and **I2P** URLs."
name="allServiceUrls"
inputProps={{
placeholder: 'example1.com\nexample2.onion\nexample3.b32.i2p',
class: 'md:min-h-20 min-h-24 h-full',
required: true,
}}
class="flex flex-col self-stretch"
error={inputErrors.allServiceUrls}
/>
<InputTextArea
label="Contact Methods"
description={[
'One per line.',
`Accepts: ${contactMethodUrlTypes.map((type: any) => type.labelPlural).join(', ')}`,
].join('\n')}
name="contactMethods"
inputProps={{
placeholder: 'contact@example.com\nt.me/example\n+123 456 7890',
class: 'h-full',
}}
class="flex flex-col self-stretch"
error={inputErrors.contactMethods}
/>
</div> </div>
<form <div class="grid grid-cols-1 gap-4 md:grid-cols-2">
method="POST" <InputTextArea
action={actions.admin.service.create} label="ToS URLs"
class="space-y-4 rounded-lg border border-green-500/30 bg-black/40 p-6 shadow-[0_0_15px_rgba(34,197,94,0.2)] backdrop-blur-xs" description="One per line. AI review uses the first working URL only."
enctype="multipart/form-data" name="tosUrls"
> inputProps={{
<div> placeholder: 'example.com/tos',
<label for="name" class="font-title mb-2 block text-sm text-green-500">name</label> required: true,
<input class: 'min-h-10',
transition:persist }}
type="text" error={inputErrors.tosUrls}
name="name" />
id="name"
required
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 placeholder-gray-500 focus:border-green-500 focus:ring-green-500"
/>
{
inputErrors.name && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.name.join(', ')}</p>
)
}
</div>
<div> <InputText
<label for="description" class="font-title mb-2 block text-sm text-green-500">description</label> label="Operating since"
<textarea name="operatingSince"
transition:persist inputProps={{
name="description" type: 'date',
id="description" max: new Date().toISOString().slice(0, 10),
required }}
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 placeholder-gray-500 focus:border-green-500 focus:ring-green-500" error={inputErrors.operatingSince}
set:text="" />
/> </div>
{
inputErrors.description && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.description.join(', ')}</p>
)
}
</div>
<div> <div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<label for="allServiceUrls" class="font-title mb-2 block text-sm text-green-500">Service URLs</label> <InputText
<textarea label="Registered Company Name"
transition:persist name="registeredCompanyName"
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 placeholder-gray-500 focus:border-green-500 focus:ring-green-500" description="Official name of the registered company (optional)"
name="allServiceUrls" inputProps={{
id="allServiceUrls" placeholder: 'e.g. Example Corp Ltd.',
rows={3} }}
placeholder="https://example1.com\nhttps://example2.onion\nhttps://example3.b32.i2p" />
set:text=""
/>
{
inputErrors.allServiceUrls && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.allServiceUrls.join(', ')}</p>
)
}
</div>
<div> <InputSelect
<label for="tosUrls" class="font-title mb-2 block text-sm text-green-500">tosUrls</label> name="registrationCountryCode"
<textarea label="Company Registration Country"
transition:persist description="Country where the service company is legally registered (optional)"
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 placeholder-gray-500 focus:border-green-500 focus:ring-green-500" options={[
name="tosUrls" { label: 'Not registered', value: '' },
id="tosUrls" ...countries
rows={3} .sort((a: any, b: any) => a.name.localeCompare(b.name))
placeholder="https://example1.com/tos https://example2.com/tos" .map((country: any) => ({
set:text="" label: `${country.flag} ${country.name}`,
/> value: country.code,
{ }))
inputErrors.tosUrls && ( ]}
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.tosUrls.join(', ')}</p> selectedValue=""
) />
} </div>
</div>
<div> <InputCardGroup
<label for="imageFile" class="font-title mb-2 block text-sm text-green-500">serviceImage</label> name="kycLevel"
<div class="space-y-2"> label="KYC Level"
<input options={kycLevels.map((kycLevel: any) => ({
transition:persist label: kycLevel.name,
type="file" value: kycLevel.id.toString(),
name="imageFile" icon: kycLevel.icon,
id="imageFile" description: `${kycLevel.description}\n\n_KYC Level ${kycLevel.value}/4_`,
accept="image/*" }))}
required iconSize="md"
class="font-title file:font-title block w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 file:mr-3 file:rounded-md file:border-0 file:bg-green-500/30 file:px-3 file:py-1 file:text-gray-300 focus:border-green-500 focus:ring-green-500" cardSize="md"
/> required
<p class="font-title text-xs text-gray-400"> error={inputErrors.kycLevel}
Upload a square image for best results. Supported formats: JPG, PNG, WebP, SVG. />
</p>
</div>
{
inputErrors.imageFile && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.imageFile.join(', ')}</p>
)
}
</div>
<div> <InputCardGroup
<label class="font-title mb-2 block text-sm text-green-500" for="categories">categories</label> name="kycLevelClarification"
<div class="mt-2 grid grid-cols-2 gap-2"> label="KYC Level Clarification"
{ options={kycLevelClarifications.map((clarification: any) => ({
categories?.map((category) => ( label: clarification.label,
<label class="inline-flex items-center"> value: clarification.value,
<input icon: clarification.icon,
transition:persist description: clarification.description,
type="checkbox" }))}
name="categories" selectedValue="NONE"
value={category.id} iconSize="sm"
class="rounded-sm border-green-500/30 bg-black/50 text-green-500 focus:ring-green-500 focus:ring-offset-black" cardSize="sm"
/> error={inputErrors.kycLevelClarification}
<span class="font-title ml-2 flex items-center gap-2 text-gray-300"> />
<Icon class="h-3 w-3 text-green-500" name={category.icon} />
{category.name}
</span>
</label>
))
}
</div>
{
inputErrors.categories && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.categories.join(', ')}</p>
)
}
</div>
<div> <div class="xs:grid-cols-[1fr_2fr] grid grid-cols-1 items-stretch gap-x-4 gap-y-6">
<label for="kycLevel" class="font-title mb-2 block text-sm text-green-500">kycLevel</label> <InputCheckboxGroup
<input name="categories"
transition:persist label="Categories"
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 placeholder-gray-500 focus:border-green-500 focus:ring-green-500" required
type="number" options={categories.map((category: any) => ({
name="kycLevel" label: category.name,
id="kycLevel" value: category.id.toString(),
min={0} icon: category.icon,
max={4} }))}
value={4} size="lg"
required error={inputErrors.categories}
/> class="min-w-auto"
{ />
inputErrors.kycLevel && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.kycLevel.join(', ')}</p>
)
}
</div>
<div> <InputCheckboxGroup
<label class="font-title mb-2 block text-sm text-green-500" for="attributes">attributes</label> name="attributes"
<div class="space-y-4"> label="Attributes"
{ options={orderBy(
Object.values(AttributeCategory).map((category) => ( attributes.map((attribute: any) => ({
<div class="rounded-md border border-green-500/20 bg-black/30 p-4"> ...attribute,
<h4 class="font-title mb-3 text-green-400">{category}</h4> categoryInfo: getAttributeCategoryInfo(attribute.category),
<div class="grid grid-cols-1 gap-2"> typeInfo: getAttributeTypeInfo(attribute.type),
{attributes })),
?.filter((attr) => attr.category === category) ['categoryInfo.order', 'typeInfo.order']
.map((attr) => ( ).map((attribute: any) => ({
<label class="inline-flex items-center"> label: attribute.title,
<input value: attribute.id.toString(),
transition:persist icon: [attribute.categoryInfo.icon, attribute.typeInfo.icon],
type="checkbox" iconClassName: [attribute.categoryInfo.classNames.icon, attribute.typeInfo.classNames.icon],
name="attributes" }))}
value={attr.id} description="See list of [all attributes](/attributes) and their scoring."
class="rounded-sm border-green-500/30 bg-black/50 text-green-500 focus:ring-green-500 focus:ring-offset-black" error={inputErrors.attributes}
/> size="lg"
<span class="font-title ml-2 flex items-center gap-2 text-gray-300"> />
{attr.title} </div>
<span
class={cn('font-title rounded-sm px-1.5 py-0.5 text-xs', {
'border border-green-500/50 bg-green-500/20 text-green-400':
attr.type === 'GOOD',
'border border-red-500/50 bg-red-500/20 text-red-400': attr.type === 'BAD',
'border border-yellow-500/50 bg-yellow-500/20 text-yellow-400':
attr.type === 'WARNING',
'border border-blue-500/50 bg-blue-500/20 text-blue-400': attr.type === 'INFO',
})}
>
{attr.type}
</span>
</span>
</label>
))}
</div>
{inputErrors.attributes && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.attributes.join(', ')}</p>
)}
</div>
))
}
</div>
</div>
<div> <InputCardGroup
<label class="font-title mb-2 block text-sm text-green-500" for="verificationStatus" name="acceptedCurrencies"
>verificationStatus</label label="Accepted Currencies"
> options={currencies.map((currency: any) => ({
<select label: currency.name,
transition:persist value: currency.id,
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 focus:border-green-500 focus:ring-green-500" icon: currency.icon,
name="verificationStatus" }))}
id="verificationStatus" error={inputErrors.acceptedCurrencies}
required multiple
> />
{Object.values(VerificationStatus).map((status) => <option value={status}>{status}</option>)}
</select>
{
inputErrors.verificationStatus && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.verificationStatus.join(', ')}</p>
)
}
</div>
<div> <InputImageFile
<label class="font-title mb-2 block text-sm text-green-500" for="verificationSummary" label="Service Image"
>verificationSummary</label name="imageFile"
> description="Square image. At least 192x192px. Transparency supported."
<textarea error={inputErrors.imageFile}
transition:persist square
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 placeholder-gray-500 focus:border-green-500 focus:ring-green-500" required
name="verificationSummary" />
id="verificationSummary"
rows={3}
set:text=""
/>
{
inputErrors.verificationSummary && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.verificationSummary.join(', ')}</p>
)
}
</div>
<div> <InputSelect
<label class="font-title mb-2 block text-sm text-green-500" for="verificationProofMd" name="verificationStatus"
>verificationProofMd</label label="Verification Status"
> options={Object.values(VerificationStatus).map((status) => ({
<textarea label: status.replace(/_/g, ' ').toLowerCase().replace(/\b\w/g, (l: string) => l.toUpperCase()),
transition:persist value: status,
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 placeholder-gray-500 focus:border-green-500 focus:ring-green-500" }))}
name="verificationProofMd" error={inputErrors.verificationStatus}
id="verificationProofMd" />
rows={10}
set:text=""
/>
{
inputErrors.verificationProofMd && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.verificationProofMd.join(', ')}</p>
)
}
</div>
<div> <InputTextArea
<label class="font-title mb-2 block text-sm text-green-500" for="acceptedCurrencies" label="Verification Summary"
>acceptedCurrencies</label name="verificationSummary"
> error={inputErrors.verificationSummary}
<div class="mt-2 grid grid-cols-2 gap-2"> />
{
Object.values(Currency).map((currency) => (
<label class="inline-flex items-center">
<input
transition:persist
type="checkbox"
name="acceptedCurrencies"
value={currency}
class="rounded-sm border-green-500/30 bg-black/50 text-green-500 focus:ring-green-500 focus:ring-offset-black"
/>
<span class="font-title ml-2 text-gray-300">{currency}</span>
</label>
))
}
</div>
{
inputErrors.acceptedCurrencies && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.acceptedCurrencies.join(', ')}</p>
)
}
</div>
<div> <InputTextArea
<label class="font-title mb-2 block text-sm text-green-500" for="overallScore">overallScore</label> label="Verification Proof (Markdown)"
<input name="verificationProofMd"
transition:persist inputProps={{
type="number" rows: 10,
name="overallScore" }}
id="overallScore" error={inputErrors.verificationProofMd}
value={0} />
min={0}
max={10}
required
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 focus:border-green-500 focus:ring-green-500"
/>
{
inputErrors.overallScore && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.overallScore.join(', ')}</p>
)
}
</div>
<div> <InputText
<label class="font-title mb-2 block text-sm text-green-500" for="referral">referral link path</label> label="Referral Link Path"
<input name="referral"
transition:persist inputProps={{
type="text" placeholder: 'e.g. ?ref=123 or /ref/123',
name="referral" }}
id="referral" error={inputErrors.referral}
placeholder="e.g. ?ref=123 or /ref/123" description="Will be appended to the service URL"
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 placeholder-gray-500 focus:border-green-500 focus:ring-green-500" />
/>
{
inputErrors.referral && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.referral.join(', ')}</p>
)
}
</div>
<div> <InputCardGroup
<label for="internalNote" class="font-title mb-2 block text-sm text-green-500">internalNote</label> name="serviceVisibility"
<div class="space-y-2"> label="Service Visibility"
<textarea options={serviceVisibilities.map((visibility: any) => ({
transition:persist label: visibility.label,
name="internalNote" value: visibility.value,
id="internalNote" icon: visibility.icon,
rows={4} iconClass: visibility.iconClass,
placeholder="Markdown supported" description: visibility.description,
class="font-title w-full rounded-md border border-green-500/30 bg-black/50 p-2 text-gray-300 placeholder-gray-500 focus:border-green-500 focus:ring-green-500" }))}
set:text="" selectedValue="PUBLIC"
/> error={inputErrors.serviceVisibility}
</div> cardSize="sm"
{ />
inputErrors.internalNote && (
<p class="font-title mt-1 text-sm text-red-500">{inputErrors.internalNote.join(', ')}</p>
)
}
</div>
<button <InputTextArea
type="submit" label="Internal Note"
class="font-title inline-flex justify-center rounded-md border border-green-500/30 bg-green-500/10 px-4 py-2 text-sm text-green-400 shadow-xs transition-colors duration-200 hover:bg-green-500/20 focus:ring-2 focus:ring-green-500 focus:ring-offset-2 focus:ring-offset-black focus:outline-hidden" name="internalNote"
> description="Markdown supported. Internal notes for admins."
Create Service inputProps={{
</button> rows: 4,
</form> }}
</section> error={inputErrors.internalNote}
/>
<InputCheckbox
label="Strict Commenting"
name="strictCommentingEnabled"
checked={false}
descriptionInline="Require proof of being a client for comments."
error={inputErrors.strictCommentingEnabled}
/>
<InputTextArea
label="Comment Section Message"
name="commentSectionMessage"
description="Markdown supported. This message will be displayed in the comment section for root comments."
inputProps={{
rows: 4,
}}
error={inputErrors.commentSectionMessage}
/>
<InputSubmitButton label="Create Service" icon="ri:add-line" hideCancel />
</form>
</FormSection>
</div>
</BaseLayout> </BaseLayout>

View File

@@ -9,11 +9,15 @@ icon: 'ri:image-line'
import PressAssets from '../components/PressAssets.astro' import PressAssets from '../components/PressAssets.astro'
## How you can use our logo?
**You are not allowed to list us as partners**. We don't accept partnerships. You should make sure it's clear that you're adding our logo **voluntarily**. Examples of correct use: "Rate us on", "Listed on" sections.
Please, link back to [KYCnot.me](https://kycnot.me) when possible, and use responsibly. Please, link back to [KYCnot.me](https://kycnot.me) when possible, and use responsibly.
<PressAssets /> <PressAssets />
Review service link format: `https://kycnot.me/service/[slug]/review` > You can link to a service's review section with: `https://kycnot.me/service/[slug]/review`
## Brand design ## Brand design

View File

@@ -9,9 +9,7 @@ import Pagination from '../components/Pagination.astro'
import ServiceFiltersPillsRow from '../components/ServiceFiltersPillsRow.astro' import ServiceFiltersPillsRow from '../components/ServiceFiltersPillsRow.astro'
import ServicesFilters from '../components/ServicesFilters.astro' import ServicesFilters from '../components/ServicesFilters.astro'
import ServicesSearchResults from '../components/ServicesSearchResults.astro' import ServicesSearchResults from '../components/ServicesSearchResults.astro'
import { getAttributeCategoryInfo } from '../constants/attributeCategories' import { currenciesZodEnumBySlug, currencySlugToId } from '../constants/currencies'
import { getAttributeTypeInfo } from '../constants/attributeTypes'
import { currencies, currenciesZodEnumBySlug, currencySlugToId } from '../constants/currencies'
import { networks } from '../constants/networks' import { networks } from '../constants/networks'
import { import {
verificationStatuses, verificationStatuses,
@@ -25,89 +23,18 @@ import { parseIntWithFallback } from '../lib/numbers'
import { areEqualObjectsWithoutOrder } from '../lib/objects' import { areEqualObjectsWithoutOrder } from '../lib/objects'
import { zodParseQueryParamsStoringErrors } from '../lib/parseUrlFilters' import { zodParseQueryParamsStoringErrors } from '../lib/parseUrlFilters'
import { prisma } from '../lib/prisma' import { prisma } from '../lib/prisma'
import {
defaultSortOption,
makeSearchFiltersOptions,
modeOptions,
sortOptions,
} from '../lib/searchFiltersOptions'
import { makeSortSeed } from '../lib/sortSeed' import { makeSortSeed } from '../lib/sortSeed'
import type { Prisma } from '@prisma/client' import type { Prisma } from '@prisma/client'
const MIN_CATEGORIES_TO_SHOW = 8
const MIN_ATTRIBUTES_TO_SHOW = 8
const PAGE_SIZE = 30 const PAGE_SIZE = 30
const sortOptions = [
{
value: 'score-desc',
label: 'Score (High → Low)',
orderBy: {
key: 'overallScore',
direction: 'desc',
},
},
{
value: 'score-asc',
label: 'Score (Low → High)',
orderBy: {
key: 'overallScore',
direction: 'asc',
},
},
{
value: 'name-asc',
label: 'Name (A → Z)',
orderBy: {
key: 'name',
direction: 'asc',
},
},
{
value: 'name-desc',
label: 'Name (Z → A)',
orderBy: {
key: 'name',
direction: 'desc',
},
},
{
value: 'recent',
label: 'Date listed (New → Old)',
orderBy: {
key: 'listedAt',
direction: 'desc',
},
},
{
value: 'oldest',
label: 'Date listed (Old → New)',
orderBy: {
key: 'listedAt',
direction: 'asc',
},
},
] as const satisfies {
value: string
label: string
orderBy: {
key: keyof Prisma.ServiceSelect
direction: 'asc' | 'desc'
}
}[]
const defaultSortOption = sortOptions[0]
const modeOptions = [
{
value: 'or',
label: 'OR',
},
{
value: 'and',
label: 'AND',
},
] as const satisfies {
value: string
label: string
}[]
export type AttributeOption = { export type AttributeOption = {
value: string value: string
prefix: string prefix: string
@@ -478,62 +405,11 @@ const [categories, [services, totalServices], countCommunityOnly, attributes] =
], ],
]) ])
const attributesByCategory = orderBy( const filtersOptions = makeSearchFiltersOptions({
Object.entries( filters,
groupBy( categories,
attributes.map((attr) => { attributes,
return { })
typeInfo: getAttributeTypeInfo(attr.type),
...attr,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
value: filters.attr?.[attr.id] || undefined,
}
}),
'category'
)
).map(([category, attributes]) => ({
category,
categoryInfo: getAttributeCategoryInfo(category),
attributes: orderBy(
attributes,
['value', 'type', '_count.services', 'title'],
['asc', 'asc', 'desc', 'asc']
).map((attr, i) => ({
...attr,
showAlways: i < MIN_ATTRIBUTES_TO_SHOW || attr.value !== undefined,
})),
})),
['category'],
['asc']
)
const categoriesSorted = orderBy(
categories.map((category) => {
const checked = filters.categories.includes(category.slug)
return {
...category,
checked,
}
}),
['checked', '_count.services', 'name'],
['desc', 'desc', 'asc']
).map((category, i) => ({
...category,
showAlways: i < MIN_CATEGORIES_TO_SHOW || category.checked,
}))
const filtersOptions = {
currencies,
categories: categoriesSorted,
sort: sortOptions,
modeOptions,
network: networks,
verification: verificationStatuses,
attributesByCategory,
} as const
export type ServicesFiltersOptions = typeof filtersOptions
const searchResultsId = 'search-results' const searchResultsId = 'search-results'
const showFiltersId = 'show-filters' const showFiltersId = 'show-filters'
@@ -591,6 +467,7 @@ const showFiltersId = 'show-filters'
categories={categories} categories={categories}
attributes={attributes} attributes={attributes}
attributeOptions={attributeOptions} attributeOptions={attributeOptions}
inlineIcons={false}
/> />
) )
} }
@@ -616,6 +493,7 @@ const showFiltersId = 'show-filters'
/> />
<div <div
class="bg-night-700 fixed top-0 left-0 z-50 hidden h-dvh w-dvw shrink-0 translate-y-full overflow-y-auto overscroll-contain border-t border-green-500/30 px-8 pt-4 transition-transform peer-checked:translate-y-0 max-sm:peer-checked:block sm:relative sm:z-auto sm:block sm:h-auto sm:w-64 sm:translate-y-0 sm:overflow-visible sm:border-none sm:bg-none sm:p-0" class="bg-night-700 fixed top-0 left-0 z-50 hidden h-dvh w-dvw shrink-0 translate-y-full overflow-y-auto overscroll-contain border-t border-green-500/30 px-8 pt-4 transition-transform peer-checked:translate-y-0 max-sm:peer-checked:block sm:relative sm:z-auto sm:block sm:h-auto sm:w-64 sm:translate-y-0 sm:overflow-visible sm:border-none sm:bg-none sm:p-0"
aria-label="Search filters"
> >
<ServicesFilters <ServicesFilters
searchResultsId={searchResultsId} searchResultsId={searchResultsId}
@@ -643,6 +521,7 @@ const showFiltersId = 'show-filters'
filtersOptions={filtersOptions} filtersOptions={filtersOptions}
attributes={attributes} attributes={attributes}
attributeOptions={attributeOptions} attributeOptions={attributeOptions}
aria-label="Search results"
/> />
</div> </div>
{ {

View File

@@ -5,10 +5,12 @@ import { actions } from 'astro:actions'
import Button from '../components/Button.astro' import Button from '../components/Button.astro'
import CopyButton from '../components/CopyButton.astro' import CopyButton from '../components/CopyButton.astro'
import Pagination from '../components/Pagination.astro'
import PushNotificationBanner from '../components/PushNotificationBanner.astro' import PushNotificationBanner from '../components/PushNotificationBanner.astro'
import TimeFormatted from '../components/TimeFormatted.astro' import TimeFormatted from '../components/TimeFormatted.astro'
import Tooltip from '../components/Tooltip.astro' import Tooltip from '../components/Tooltip.astro'
import { getNotificationTypeInfo } from '../constants/notificationTypes' import { getNotificationTypeInfo } from '../constants/notificationTypes'
import { getReadStatus, readStatusZodEnum } from '../constants/readStatus'
import BaseLayout from '../layouts/BaseLayout.astro' import BaseLayout from '../layouts/BaseLayout.astro'
import { cn } from '../lib/cn' import { cn } from '../lib/cn'
import { getOrCreateNotificationPreferences } from '../lib/notificationPreferences' import { getOrCreateNotificationPreferences } from '../lib/notificationPreferences'
@@ -16,6 +18,10 @@ import { makeNotificationActions, makeNotificationContent, makeNotificationTitle
import { zodParseQueryParamsStoringErrors } from '../lib/parseUrlFilters' import { zodParseQueryParamsStoringErrors } from '../lib/parseUrlFilters'
import { prisma } from '../lib/prisma' import { prisma } from '../lib/prisma'
import { makeLoginUrl } from '../lib/redirectUrls' import { makeLoginUrl } from '../lib/redirectUrls'
import { transformCase } from '../lib/strings'
import { urlWithParams } from '../lib/urls'
import type { Prisma } from '@prisma/client'
const user = Astro.locals.user const user = Astro.locals.user
if (!user) return Astro.redirect(makeLoginUrl(Astro.url)) if (!user) return Astro.redirect(makeLoginUrl(Astro.url))
@@ -25,20 +31,26 @@ const PAGE_SIZE = 20
const { data: params } = zodParseQueryParamsStoringErrors( const { data: params } = zodParseQueryParamsStoringErrors(
{ {
page: z.coerce.number().int().min(1).default(1), page: z.coerce.number().int().min(1).default(1),
readStatus: readStatusZodEnum.optional(),
}, },
Astro Astro
) )
const skip = (params.page - 1) * PAGE_SIZE const skip = (params.page - 1) * PAGE_SIZE
const readStatusInfo = params.readStatus ? getReadStatus(params.readStatus) : undefined
const notificationWhereClause: Prisma.NotificationWhereInput = {
userId: user.id,
read: readStatusInfo?.readValue,
}
const [dbNotifications, notificationPreferences, totalNotifications, pushSubscriptions] = const [dbNotifications, notificationPreferences, totalNotifications, pushSubscriptions] =
await Astro.locals.banners.tryMany([ await Astro.locals.banners.tryMany([
[ [
'Error while fetching notifications', 'Error while fetching notifications',
() => () =>
prisma.notification.findMany({ prisma.notification.findMany({
where: { where: notificationWhereClause,
userId: user.id,
},
orderBy: { orderBy: {
createdAt: 'desc', createdAt: 'desc',
}, },
@@ -153,7 +165,7 @@ const [dbNotifications, notificationPreferences, totalNotifications, pushSubscri
], ],
[ [
'Error while fetching total notifications', 'Error while fetching total notifications',
() => prisma.notification.count({ where: { userId: user.id } }), () => prisma.notification.count({ where: notificationWhereClause }),
0, 0,
], ],
[ [
@@ -227,13 +239,18 @@ const notifications = dbNotifications.map((notification) => ({
) )
} }
<div class="mb-4 flex items-center justify-between"> <div class="xs:flex-row xs:flex-wrap mb-4 flex flex-col items-center justify-between gap-2">
<h1 class="font-title flex items-center text-2xl leading-tight font-bold tracking-wider"> <h1 class="font-title flex items-center text-2xl leading-tight font-bold tracking-wider">
<Icon name="ri:notification-line" class="mr-2 size-6 text-zinc-400" /> <Icon name="ri:notification-line" class="mr-2 size-6 text-zinc-400" />
Notifications
{transformCase(`${readStatusInfo?.label ?? ''} notifications`.trim(), 'sentence')}
</h1> </h1>
<form method="POST" action={actions.notification.updateReadStatus}> <form
method="POST"
action={actions.notification.updateReadStatus}
class="xs:justify-start flex flex-1 flex-row-reverse flex-wrap items-center justify-center gap-2"
>
<input type="hidden" name="notificationId" value="all" /> <input type="hidden" name="notificationId" value="all" />
<input type="hidden" name="read" value="true" /> <input type="hidden" name="read" value="true" />
<Button <Button
@@ -243,6 +260,25 @@ const notifications = dbNotifications.map((notification) => ({
disabled={notifications.length === 0} disabled={notifications.length === 0}
color="white" color="white"
/> />
{
params.readStatus === 'unread' ? (
<Button
as="a"
href={urlWithParams(Astro.url, { readStatus: null }, { clearExisting: true })}
label="See all"
icon="ri:eye-line"
color="black"
/>
) : (
<Button
as="a"
href={urlWithParams(Astro.url, { readStatus: 'unread' }, { clearExisting: true })}
label="See unread only"
icon="ri:eye-off-line"
color="black"
/>
)
}
</form> </form>
</div> </div>
@@ -323,31 +359,12 @@ const notifications = dbNotifications.map((notification) => ({
))} ))}
{totalPages > 1 && ( {totalPages > 1 && (
<div class="mt-8 flex justify-center gap-4"> <Pagination
<form method="GET" action="/notifications" class="inline"> currentPage={params.page}
<input type="hidden" name="page" value={params.page - 1} /> totalPages={totalPages}
<button currentUrl={Astro.url}
type="submit" class="mt-8"
class="rounded-md border border-zinc-700 bg-zinc-800 px-4 py-2 text-sm text-zinc-200 transition-colors duration-200 hover:bg-zinc-700" />
disabled={params.page <= 1}
>
Previous
</button>
</form>
<span class="inline-flex items-center px-2 text-sm text-zinc-400">
Page {params.page} of {totalPages}
</span>
<form method="GET" action="/notifications" class="inline">
<input type="hidden" name="page" value={params.page + 1} />
<button
type="submit"
class="rounded-md border border-zinc-700 bg-zinc-800 px-4 py-2 text-sm text-zinc-200 transition-colors duration-200 hover:bg-zinc-700"
disabled={params.page >= totalPages}
>
Next
</button>
</form>
</div>
)} )}
</div> </div>
) )

View File

@@ -15,12 +15,14 @@ import InputCheckbox from '../../components/InputCheckbox.astro'
import InputCheckboxGroup from '../../components/InputCheckboxGroup.astro' import InputCheckboxGroup from '../../components/InputCheckboxGroup.astro'
import InputHoneypotTrap from '../../components/InputHoneypotTrap.astro' import InputHoneypotTrap from '../../components/InputHoneypotTrap.astro'
import InputImageFile from '../../components/InputImageFile.astro' import InputImageFile from '../../components/InputImageFile.astro'
import InputSelect from '../../components/InputSelect.astro'
import InputSubmitButton from '../../components/InputSubmitButton.astro' import InputSubmitButton from '../../components/InputSubmitButton.astro'
import InputText from '../../components/InputText.astro' import InputText from '../../components/InputText.astro'
import InputTextArea from '../../components/InputTextArea.astro' import InputTextArea from '../../components/InputTextArea.astro'
import { getAttributeCategoryInfo } from '../../constants/attributeCategories' import { getAttributeCategoryInfo } from '../../constants/attributeCategories'
import { getAttributeTypeInfo } from '../../constants/attributeTypes' import { getAttributeTypeInfo } from '../../constants/attributeTypes'
import { contactMethodUrlTypes } from '../../constants/contactMethods' import { contactMethodUrlTypes } from '../../constants/contactMethods'
import { countries } from '../../constants/countries'
import { currencies } from '../../constants/currencies' import { currencies } from '../../constants/currencies'
import { kycLevelClarifications } from '../../constants/kycLevelClarifications' import { kycLevelClarifications } from '../../constants/kycLevelClarifications'
import { kycLevels } from '../../constants/kycLevels' import { kycLevels } from '../../constants/kycLevels'
@@ -262,6 +264,33 @@ const [categories, attributes] = await Astro.locals.banners.tryMany([
/> />
</div> </div>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<InputText
label="Registered Company Name"
name="registeredCompanyName"
description="Official name of the registered company (optional)"
inputProps={{
placeholder: 'e.g. Example Corp Ltd.',
}}
/>
<InputSelect
name="registrationCountryCode"
label="Company Registration Country"
description="Country where the service company is legally registered (optional)"
options={[
{ label: 'Not registered', value: '' },
...countries
.sort((a, b) => a.name.localeCompare(b.name))
.map((country) => ({
label: `${country.flag} ${country.name}`,
value: country.code,
}))
]}
selectedValue=""
/>
</div>
<InputCardGroup <InputCardGroup
name="kycLevel" name="kycLevel"
label="KYC Level" label="KYC Level"

View File

@@ -96,12 +96,16 @@ const [service, dbNotificationPreferences] = await Astro.locals.banners.tryMany(
createdAt: true, createdAt: true,
acceptedCurrencies: true, acceptedCurrencies: true,
operatingSince: true, operatingSince: true,
registrationCountryCode: true,
registeredCompanyName: true,
tosReview: true, tosReview: true,
tosReviewAt: true, tosReviewAt: true,
userSentiment: true, userSentiment: true,
userSentimentAt: true, userSentimentAt: true,
averageUserRating: true, averageUserRating: true,
isRecentlyApproved: true, isRecentlyApproved: true,
strictCommentingEnabled: true,
commentSectionMessage: true,
contactMethods: { contactMethods: {
select: { select: {
value: true, value: true,
@@ -294,8 +298,6 @@ const statusIcon = {
APPROVED: undefined, APPROVED: undefined,
}[service.verificationStatus] }[service.verificationStatus]
const isScam = service.verificationStatus === 'VERIFICATION_FAILED'
const shuffledLinks = { const shuffledLinks = {
clearnet: shuffle(service.serviceUrls), clearnet: shuffle(service.serviceUrls),
onion: shuffle(service.onionUrls), onion: shuffle(service.onionUrls),
@@ -412,6 +414,7 @@ const ogImageTemplateData = {
categories: service.categories.map((category) => pick(category, ['name', 'icon'])), categories: service.categories.map((category) => pick(category, ['name', 'icon'])),
score: service.overallScore, score: service.overallScore,
imageUrl: service.imageUrl, imageUrl: service.imageUrl,
verificationStatus: service.verificationStatus,
} satisfies OgImageAllTemplatesWithProps } satisfies OgImageAllTemplatesWithProps
const serviceVisibilityInfo = getServiceVisibilityInfo(service.serviceVisibility) const serviceVisibilityInfo = getServiceVisibilityInfo(service.serviceVisibility)
@@ -424,6 +427,30 @@ const activeAlertOrWarningEvents = service.events
.filter((event) => event.typeInfo.showBanner && (event.endedAt === null || event.endedAt >= now)) .filter((event) => event.typeInfo.showBanner && (event.endedAt === null || event.endedAt >= now))
const activeEventToShow = const activeEventToShow =
activeAlertOrWarningEvents.find((event) => event.type === EventType.ALERT) ?? activeAlertOrWarningEvents[0] activeAlertOrWarningEvents.find((event) => event.type === EventType.ALERT) ?? activeAlertOrWarningEvents[0]
// Sort verification steps: failed first, then warnings, then others, newest first within each group
const getVerificationStepPriority = (status: VerificationStepStatus) => {
switch (status) {
case VerificationStepStatus.FAILED:
return 0 // Highest priority
case VerificationStepStatus.WARNING:
return 1
case VerificationStepStatus.IN_PROGRESS:
return 2
case VerificationStepStatus.PENDING:
return 3
case VerificationStepStatus.PASSED:
return 4 // Lowest priority
default:
return 5
}
}
const sortedVerificationSteps = orderBy(
service.verificationSteps,
[(step) => getVerificationStepPriority(step.status), (step) => step.updatedAt],
['asc', 'desc'] // Priority ascending (failed first), date descending (newest first)
)
--- ---
<BaseLayout <BaseLayout
@@ -765,18 +792,12 @@ const activeEventToShow =
<ul aria-label="Service links" class="xs:justify-start mt-4 flex flex-wrap justify-center gap-2"> <ul aria-label="Service links" class="xs:justify-start mt-4 flex flex-wrap justify-center gap-2">
{shownLinks.map((url) => ( {shownLinks.map((url) => (
<li> <li>
{isScam ? ( <ServiceLinkButton
<span class="2xs:text-sm 2xs:h-8 2xs:gap-2 2xs:px-4 bg-day-800 inline-flex h-6 items-center gap-1 rounded-full px-2 text-xs whitespace-nowrap text-red-400"> url={url}
<Icon name="ri:alert-line" class="size-4 text-red-400" /> referral={service.referral}
{urlDomain(url)} enableMinWidth={shuffledLinks.onion.length + shuffledLinks.i2p.length > 0}
</span> isScam={service.verificationStatus === 'VERIFICATION_FAILED'}
) : ( />
<ServiceLinkButton
url={url}
referral={service.referral}
enableMinWidth={shuffledLinks.onion.length + shuffledLinks.i2p.length > 0}
/>
)}
</li> </li>
))} ))}
@@ -800,18 +821,12 @@ const activeEventToShow =
{hiddenLinks.map((url) => ( {hiddenLinks.map((url) => (
<li class="hidden peer-checked:block"> <li class="hidden peer-checked:block">
{isScam ? ( <ServiceLinkButton
<span class="2xs:text-sm 2xs:h-8 2xs:gap-2 2xs:px-4 bg-day-800 inline-flex h-6 items-center gap-1 rounded-full px-2 text-xs whitespace-nowrap text-red-400"> url={url}
<Icon name="ri:alert-line" class="size-4 text-red-400" /> referral={service.referral}
{urlDomain(url)} enableMinWidth={shuffledLinks.onion.length + shuffledLinks.i2p.length > 0}
</span> isScam={service.verificationStatus === 'VERIFICATION_FAILED'}
) : ( />
<ServiceLinkButton
url={url}
referral={service.referral}
enableMinWidth={shuffledLinks.onion.length + shuffledLinks.i2p.length > 0}
/>
)}
</li> </li>
))} ))}
</ul> </ul>
@@ -1474,11 +1489,11 @@ const activeEventToShow =
) )
} }
{ {
service.verificationSteps.length > 0 && ( sortedVerificationSteps.length > 0 && (
<> <>
<h3 class="font-title text-md mt-6 mb-2 font-semibold">Verification Steps</h3> <h3 class="font-title text-md mt-6 mb-2 font-semibold">Verification Steps</h3>
<ul class="mb-8 space-y-2"> <ul class="mb-8 space-y-2">
{service.verificationSteps.map((step) => { {sortedVerificationSteps.map((step) => {
const statusInfo = getVerificationStepStatusInfo(step.status) const statusInfo = getVerificationStepStatusInfo(step.status)
return ( return (
@@ -1533,6 +1548,20 @@ const activeEventToShow =
<li>Moderation is light.</li> <li>Moderation is light.</li>
<li>Double-check before trusting.</li> <li>Double-check before trusting.</li>
</ul> </ul>
{
service.strictCommentingEnabled && (
<p class="mt-2">
<Icon
name="ri:verified-badge-fill"
class="me-0.5 inline-block size-4 align-[-0.3em] text-orange-100/95"
/>
<span class="font-medium text-orange-100/95">Proof of being a client required</span>, for this
service.
</p>
)
}
<div class="absolute inset-y-2 right-2 flex flex-col justify-center"> <div class="absolute inset-y-2 right-2 flex flex-col justify-center">
<Icon name="ri:alert-line" class="xs:opacity-20 h-full max-h-16 w-auto opacity-10" /> <Icon name="ri:alert-line" class="xs:opacity-20 h-full max-h-16 w-auto opacity-10" />
</div> </div>

View File

@@ -0,0 +1,190 @@
/* eslint-disable import/no-named-as-default-member */
import he from 'he'
import { prisma } from '../../lib/prisma'
import { makeSearchFiltersOptions } from '../../lib/searchFiltersOptions'
import type { APIRoute } from 'astro'
export const GET: APIRoute = async ({ site }) => {
if (!site) return new Response('Site URL not configured', { status: 500 })
try {
const searchUrls = await generateSEOSitemapUrls(site.href)
const result = `
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${searchUrls.map((url) => `<url><loc>${he.encode(url)}</loc></url>`).join('\n')}
</urlset>
`.trim()
return new Response(result, {
headers: {
'Content-Type': 'application/xml',
},
})
} catch (error) {
console.error('Failed to generate SEO sitemap URLs:', error)
return new Response('Failed to generate SEO sitemap URLs', { status: 500 })
}
}
async function generateSEOSitemapUrls(siteUrl: string) {
const [categories, attributes] = await Promise.all([
prisma.category.findMany({
select: {
name: true,
namePluralLong: true,
slug: true,
icon: true,
_count: {
select: {
services: {
where: {
serviceVisibility: { in: ['PUBLIC', 'ARCHIVED'] },
},
},
},
},
},
}),
prisma.attribute.findMany({
select: {
id: true,
slug: true,
title: true,
category: true,
type: true,
_count: {
select: {
services: {
where: {
service: {
serviceVisibility: { in: ['PUBLIC', 'ARCHIVED'] },
},
},
},
},
},
},
orderBy: [{ category: 'asc' }, { type: 'asc' }, { title: 'asc' }],
}),
])
const filtersOptions = makeSearchFiltersOptions({
filters: null,
categories,
attributes,
})
const byCategory = filtersOptions.categories.map(
(category) =>
new URLSearchParams({
categories: category.slug,
})
)
const byVerificationStatus = filtersOptions.verification.map(
(status) =>
new URLSearchParams({
verification: status.slug,
})
)
const byKycLevel = filtersOptions.kycLevels.map(
(level) =>
new URLSearchParams({
'max-kyc': level.id,
})
)
const byCurrency = filtersOptions.currencies.map(
(currency) =>
new URLSearchParams({
currencies: currency.slug,
})
)
const withOneAttribute = filtersOptions.attributesByCategory
.flatMap(({ attributes }) => attributes)
.map(
(attribute) =>
new URLSearchParams({
[`attr-${attribute.id.toString()}`]: 'yes',
})
)
const withoutOneAttribute = filtersOptions.attributesByCategory
.flatMap(({ attributes }) => attributes)
.map(
(attribute) =>
new URLSearchParams({
[`attr-${attribute.id.toString()}`]: 'no',
})
)
const byCategoryAndCurrency = filtersOptions.categories.flatMap((category) =>
filtersOptions.currencies.map(
(currency) =>
new URLSearchParams({
categories: category.slug,
currencies: currency.slug,
})
)
)
const byCategoryAndAttributes = filtersOptions.categories.flatMap((category) =>
filtersOptions.attributesByCategory
.flatMap(({ attributes }) => attributes)
.flatMap((attribute) => [
new URLSearchParams({
categories: category.slug,
[`attr-${attribute.id.toString()}`]: 'yes',
}),
new URLSearchParams({
categories: category.slug,
[`attr-${attribute.id.toString()}`]: 'no',
}),
])
)
const relevantCurrencies = [
'xmr',
'btc',
] as const satisfies (typeof filtersOptions.currencies)[number]['slug'][]
const byCategoryAndAttributesAndRelevantCurrency = filtersOptions.categories.flatMap((category) =>
filtersOptions.attributesByCategory
.flatMap(({ attributes }) => attributes)
.flatMap((attribute) =>
relevantCurrencies.map(
(currency) =>
new URLSearchParams({
categories: category.slug,
currencies: currency,
[`attr-${attribute.id.toString()}`]:
attribute.type === 'GOOD' || attribute.type === 'INFO' ? 'yes' : 'no',
})
)
)
)
const allQueryParams = [
...byCategory,
...byVerificationStatus,
...byKycLevel,
...byCurrency,
...withOneAttribute,
...withoutOneAttribute,
...byCategoryAndCurrency,
...byCategoryAndAttributes,
...byCategoryAndAttributesAndRelevantCurrency,
] satisfies URLSearchParams[]
return allQueryParams.map((queryParams) => {
const url = new URL(siteUrl)
url.search = queryParams.toString()
return url.href
})
}

View File

@@ -1,14 +1,15 @@
import type { APIRoute } from 'astro' import type { APIRoute } from 'astro'
const getRobotsTxt = (sitemapURL: URL) => ` const getRobotsTxt = (sitemaps: `/${string}`[], siteUrl: URL) => `
User-agent: * User-agent: *
Allow: / Allow: /
Disallow: /admin/ Disallow: /admin/
Sitemap: ${sitemapURL.href} ${sitemaps.map((sitemap) => `Sitemap: ${new URL(sitemap, siteUrl).href}`).join('\n')}
` `
export const GET: APIRoute = ({ site }) => { export const GET: APIRoute = ({ site }) => {
const sitemapURL = new URL('sitemap-index.xml', site) if (!site) return new Response('Site URL not configured', { status: 500 })
return new Response(getRobotsTxt(sitemapURL))
return new Response(getRobotsTxt(['/sitemap-index.xml', '/sitemaps/search.xml'], site))
} }