diff --git a/src/pages/organizer/events/dashboard/SellerManagementPage.tsx b/src/pages/organizer/events/dashboard/SellerManagementPage.tsx
index e18d6f31..e0693721 100644
--- a/src/pages/organizer/events/dashboard/SellerManagementPage.tsx
+++ b/src/pages/organizer/events/dashboard/SellerManagementPage.tsx
@@ -1,3 +1,5 @@
+import { SortMarkBadge } from '../../../../components/sellers/SortMarkBadge';
+import { downloadSortSheets } from '../../../../lib/sortSheetsPdf';
import { useMemo, useState } from 'react';
import { WalkInBadge } from '../../../../components/walkIn/WalkInBadge';
import { SellerNumberBadge } from '../../../../components/sellers/SellerNumberBadge';
@@ -32,12 +34,14 @@ import {
AlertTriangle,
Info,
Megaphone,
+ Printer,
} from 'lucide-react';
import { formatPriceDE } from '../../../../lib/utils';
import type { VendorWithCalculations } from '../../../../lib/api/types';
import { Tabs, TabsList, TabsTrigger } from '../../../../components/ui/tabs';
import { Button } from '../../../../components/ui/button';
import { toast } from 'sonner';
+import { getUserFacingErrorMessage } from '../../../../lib/errors';
import {
AlertDialog,
AlertDialogAction,
@@ -86,6 +90,12 @@ export function SellerManagementPage() {
const vendors = useQuery(api.eventRoles.getVendorsForEvent, {
eventId: eventId as Id<'events'>,
}) as VendorWithCalculations[] | undefined;
+ // Only universal labels bring a sorting code along: one sheet for each seller's basket
+ const sortSheetSellers = (vendors ?? []).flatMap((v) =>
+ v.sortCode === undefined
+ ? []
+ : [{ sortCode: v.sortCode, name: v.name ?? '-', sellerNumber: v.sellerNumber }]
+ );
const addHelper = useMutation(api.eventRoles.addCoOrganizerForEvent);
useAssignMissingSellerNumbers(eventId as Id<'events'>, vendors, canManage);
@@ -169,6 +179,20 @@ export function SellerManagementPage() {
>
{t('sellers.walkIn')}
+ {sortSheetSellers.length > 0 && (
+
+ )}
{v.name}
+ {v.sortCode !== undefined && (
+
+ )}
{v.managedByEventId && }
{v.isHelper && !isOwner && (
diff --git a/src/pages/organizer/events/dashboard/components/EventSettingsSummary.tsx b/src/pages/organizer/events/dashboard/components/EventSettingsSummary.tsx
index c2b0c9ba..363d2ee0 100644
--- a/src/pages/organizer/events/dashboard/components/EventSettingsSummary.tsx
+++ b/src/pages/organizer/events/dashboard/components/EventSettingsSummary.tsx
@@ -1,7 +1,7 @@
import type { ReactNode } from 'react';
import { Check, Minus } from 'lucide-react';
import type { Doc } from '../../../../../lib/api/types';
-import { resolveEventFeatures } from '../../../../../shared/eventFeatures';
+import { effectiveLabelMark, resolveEventFeatures } from '../../../../../shared/eventFeatures';
import { VISIBILITY_OPTIONS } from '../../../../../constants/records';
import { formatDateRangeDE, formatPriceDE } from '../../../../../lib/utils';
import { Badge } from '../../../../../components/ui/badge';
@@ -64,6 +64,7 @@ export function EventSettingsSummary({ event }: { event: EventWithLabels }) {
minute: '2-digit',
});
const features = resolveEventFeatures(event);
+ const labelMark = effectiveLabelMark(event);
const logistics = event.sellerLogistics;
const discountDetail = [
features.discountStartsAt
@@ -155,7 +156,12 @@ export function EventSettingsSummary({ event }: { event: EventWithLabels }) {
features.labelFormat === 'small' ? t('summary.labelsSmall') : t('summary.labelsLarge')
}
/>
-
+ {
it('tells the seller when the labels of a bazaar can be reused', async () => {
const reusable = {
...events[0],
- features: { sellerNumberOnLabel: false },
+ features: { labelFormat: 'small', labelMark: 'universal' },
} as unknown as Doc<'events'>;
render(
{
eventId="later"
/>
);
- expect(await screen.findByText(/beim nächsten Basar wiederverwenden/)).toBeInTheDocument();
+ expect(
+ await screen.findByText(/anderen Basaren mit Universal-Etiketten wiederverwenden/)
+ ).toBeInTheDocument();
+ });
+
+ it('starts on a free place of a partly used sheet (#238)', async () => {
+ renderDialog('next');
+ expect(await screen.findByText('42 Etiketten auf 2 A4-Seiten')).toBeInTheDocument();
+ fireEvent.change(screen.getByLabelText('Erstes freies Feld auf dem Bogen'), {
+ target: { value: '40' },
+ });
+ // One label left on the first sheet, 41 need two more
+ expect(await screen.findByText('42 Etiketten auf 3 A4-Seiten')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'PDF herunterladen' }));
+ await waitFor(() =>
+ expect(downloadLabelsPdf).toHaveBeenCalledWith(client, expect.any(Array), 'next', 40)
+ );
});
it('prints the unsold items of the chosen bazaar for that bazaar', async () => {
@@ -87,7 +103,9 @@ describe('LabelPrintDialog', () => {
expect(await screen.findByText('1 Etikett auf 1 A4-Seite')).toBeInTheDocument();
expect(screen.getByText('Format Standard: 12 große Etiketten pro Seite')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'PDF herunterladen' }));
- await waitFor(() => expect(downloadLabelsPdf).toHaveBeenCalledWith(client, ['p101'], 'later'));
+ await waitFor(() =>
+ expect(downloadLabelsPdf).toHaveBeenCalledWith(client, ['p101'], 'later', 1)
+ );
});
it('falls back to all available items without a bazaar', async () => {
@@ -98,7 +116,7 @@ describe('LabelPrintDialog', () => {
expect(screen.getByText(/nach dem jeweils nächsten Basar/)).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'PDF herunterladen' }));
await waitFor(() =>
- expect(downloadLabelsPdf).toHaveBeenCalledWith(client, expect.any(Array), undefined)
+ expect(downloadLabelsPdf).toHaveBeenCalledWith(client, expect.any(Array), undefined, 1)
);
expect(vi.mocked(downloadLabelsPdf).mock.calls[0][1]).toHaveLength(43);
});
diff --git a/src/pages/seller/products/components/LabelPrintDialog.tsx b/src/pages/seller/products/components/LabelPrintDialog.tsx
index 657149ec..1a312658 100644
--- a/src/pages/seller/products/components/LabelPrintDialog.tsx
+++ b/src/pages/seller/products/components/LabelPrintDialog.tsx
@@ -11,6 +11,8 @@ import {
DialogTitle,
} from '../../../../components/ui/dialog';
import { Button } from '../../../../components/ui/button';
+import { Input } from '../../../../components/ui/input';
+import { Label } from '../../../../components/ui/label';
import {
Select,
SelectContent,
@@ -23,6 +25,7 @@ import type { Doc, Id } from '../../../../lib/api/types';
import { getUserFacingErrorMessage } from '../../../../lib/errors';
import { LABEL_LAYOUTS, downloadLabelsPdf } from '../../../../lib/productQRCodePdf';
import { formatDateDE } from '../../../../lib/utils';
+import { effectiveLabelMark } from '../../../../shared/eventFeatures';
/** Without a bazaar: all available items, each on the sheet of its next bazaar */
const ALL = 'all';
@@ -51,6 +54,7 @@ export function LabelPrintDialog({
const client = useApiClient();
const [choice, setChoice] = useState(ALL);
const [isCreating, setIsCreating] = useState(false);
+ const [startInput, setStartInput] = useState('1');
const available = useMemo(() => products.filter((p) => !p.sold), [products]);
@@ -71,18 +75,23 @@ export function LabelPrintDialog({
if (!open) return;
const preselected = bazaars.find((bazaar) => bazaar.event._id === eventId);
setChoice(preselected?.event._id ?? bazaars[0]?.event._id ?? ALL);
+ setStartInput('1');
}, [open, eventId, bazaars]);
const bazaar = bazaars.find((entry) => entry.event._id === choice);
const ids = bazaar ? bazaar.ids : available.map((p) => p._id);
const format = bazaar?.event.features?.labelFormat ?? 'standard';
const { cols, rows } = LABEL_LAYOUTS[format];
- const pages = Math.ceil(ids.length / (cols * rows));
+ const perPage = cols * rows;
+ // Only for one bazaar: only then the sheet is known before the PDF is made
+ const startAt = bazaar ? Math.min(Math.max(Math.trunc(Number(startInput)) || 1, 1), perPage) : 1;
+ const pages = Math.ceil((ids.length + startAt - 1) / perPage);
+ const mark = bazaar && effectiveLabelMark(bazaar.event);
const create = async () => {
setIsCreating(true);
try {
- const count = await downloadLabelsPdf(client, ids, bazaar?.event._id);
+ const count = await downloadLabelsPdf(client, ids, bazaar?.event._id, startAt);
toast.success(t('labels.created', { count }));
onOpenChange(false);
} catch (e) {
@@ -128,10 +137,30 @@ export function LabelPrintDialog({
})
: t('labels.formatPerItem')}
- {bazaar?.event.features?.sellerNumberOnLabel === false && (
-
{t('labels.reusable')}
+ {mark === 'universal' && (
+
{t('labels.reusableUniversal')}
)}
+ {mark === 'none' &&
{t('labels.reusable')}
}
+
+ {bazaar && (
+
+
+ setStartInput(e.target.value)}
+ />
+
+ {t('labels.startAtHint', { perPage })}
+
+
+ )}
diff --git a/src/shared/constants.ts b/src/shared/constants.ts
index d7d6aff6..6404ebfb 100644
--- a/src/shared/constants.ts
+++ b/src/shared/constants.ts
@@ -25,6 +25,10 @@ export const PLACEHOLDER_PATTERN = /\[\[[^\]]+\]\]/;
export const LABEL_FORMATS = ['standard', 'small'] as const;
export type LabelFormat = (typeof LABEL_FORMATS)[number];
+/** What tells sellers' items apart on labels: see EventFeatures.labelMark */
+export const LABEL_MARKS = ['number', 'universal', 'none'] as const;
+export type LabelMark = (typeof LABEL_MARKS)[number];
+
export const SYSTEM_ROLES = ['admin', 'user'] as const; // leave admin always on position SYSTEM_ROLES[0]!!
export type SystemRole = (typeof SYSTEM_ROLES)[number];
diff --git a/src/shared/eventFeatures.ts b/src/shared/eventFeatures.ts
index 1a44c4b6..ae602e1e 100644
--- a/src/shared/eventFeatures.ts
+++ b/src/shared/eventFeatures.ts
@@ -1,4 +1,4 @@
-import type { LabelFormat } from './constants';
+import type { LabelFormat, LabelMark } from './constants';
import type { ErrorCode } from './errorCodes';
import type { CategoryField } from './categoryFields';
/**
@@ -38,10 +38,11 @@ export interface EventFeatures {
/** Print the price on labels; only takes effect while discounts are off. */
priceOnLabel: boolean;
/**
- * Print the seller number on labels. Off, a label holds nothing specific to this bazaar
- * (the QR code only links to the item), so sellers can reuse it at their next one.
+ * The seller's mark on labels. `number`: the number at this bazaar. `universal`: a code
+ * that stays with the seller, read by sight (small labels only). `none`: only the QR code,
+ * which just links to the item. The last two can be reused at the next bazaar.
*/
- sellerNumberOnLabel: boolean;
+ labelMark: LabelMark;
/** Fixed fee in € per accepted item (sold or not), kept from the payout; unset means none. */
intakeFee?: number;
/** Sellers confirm when joining that they sell as private persons, not as traders. */
@@ -70,7 +71,7 @@ export const DEFAULT_EVENT_FEATURES: EventFeatures = {
photosOptional: false,
labelFormat: 'standard',
priceOnLabel: false,
- sellerNumberOnLabel: true,
+ labelMark: 'number',
privateSellersOnly: false,
fixedSellerData: false,
};
@@ -185,6 +186,14 @@ export function areOffersOpen(
return listing.status === 'available' && listing.startDate <= now && now <= listing.endDate;
}
+/** The mark labels of this event really carry: universal ones need the small sheet. */
+export function effectiveLabelMark(event: { features?: StoredEventFeatures }): LabelMark {
+ const features = resolveEventFeatures(event);
+ return features.labelMark === 'universal' && features.labelFormat !== 'small'
+ ? 'number'
+ : features.labelMark;
+}
+
/** Whether labels of this event show the price: a discount would make a printed price wrong. */
export function showsPriceOnLabel(event: { features?: StoredEventFeatures }): boolean {
const features = resolveEventFeatures(event);
diff --git a/src/shared/sortCode.test.ts b/src/shared/sortCode.test.ts
new file mode 100644
index 00000000..e7091533
--- /dev/null
+++ b/src/shared/sortCode.test.ts
@@ -0,0 +1,37 @@
+import { describe, expect, it } from 'vitest';
+import { compareSortCodes, sortMark } from './sortCode';
+
+const signature = (code: number) => {
+ const mark = sortMark(code);
+ return `${mark.digit}|${mark.fields.map((field) => field.id).join()}|${mark.letter}`;
+};
+
+describe('sortMark', () => {
+ it('gives every seller an own mark', () => {
+ const marks = new Set(Array.from({ length: 30_000 }, (_, code) => signature(code + 1)));
+ expect(marks.size).toBe(30_000);
+ });
+
+ it('needs no letter for the first 2160 sellers', () => {
+ expect(sortMark(1).letter).toBe('');
+ expect(sortMark(2159).letter).toBe('');
+ expect(sortMark(2160).letter).toBe('A');
+ expect(sortMark(2160 * 26).letter).toBe('Z');
+ expect(sortMark(2160 * 27).letter).toBe('AA');
+ });
+
+ it('makes codes of one pile differ in all fields, also one after the other', () => {
+ const [a, b] = [sortMark(15), sortMark(25)];
+ expect(a.digit).toBe(b.digit);
+ a.fields.forEach((field, i) => expect(field.id).not.toBe(b.fields[i].id));
+ });
+
+ it('stays the same: printed labels depend on it', () => {
+ expect(signature(175)).toBe('5|diamond,circle,bars|');
+ });
+
+ it('sorts by digit first', () => {
+ const sorted = [13, 22, 31, 40].sort(compareSortCodes);
+ expect(sorted.map((code) => code % 10)).toEqual([0, 1, 2, 3]);
+ });
+});
diff --git a/src/shared/sortCode.ts b/src/shared/sortCode.ts
new file mode 100644
index 00000000..69d9ad09
--- /dev/null
+++ b/src/shared/sortCode.ts
@@ -0,0 +1,83 @@
+/**
+ * Sorting code of universal labels. Unsold items are sorted back without reading: first
+ * into piles by the large digit, then by the three fields. A seller keeps the code at
+ * every bazaar, so printed labels stay valid.
+ *
+ * Every field has a color and its own symbol: most sellers print in black and white, and
+ * not every helper tells all colors apart. A letter only appears after the first 2160
+ * sellers, to tell two sellers with the same digit and fields apart.
+ */
+
+export interface SortSymbol {
+ id: 'circle' | 'triangle' | 'square' | 'diamond' | 'cross' | 'bars';
+ /** Field color, also distinct for color-blind helpers (Okabe-Ito) */
+ fill: [number, number, number];
+ /** Color of the symbol on the field, the stronger contrast also in black and white */
+ ink: [number, number, number];
+}
+
+const WHITE: [number, number, number] = [255, 255, 255];
+const BLACK: [number, number, number] = [0, 0, 0];
+
+export const SORT_SYMBOLS: readonly SortSymbol[] = [
+ { id: 'circle', fill: [0, 114, 178], ink: WHITE },
+ { id: 'triangle', fill: [230, 159, 0], ink: BLACK },
+ { id: 'square', fill: [0, 120, 90], ink: WHITE },
+ { id: 'diamond', fill: [240, 228, 66], ink: BLACK },
+ { id: 'cross', fill: [204, 121, 167], ink: BLACK },
+ { id: 'bars', fill: [30, 30, 30], ink: WHITE },
+];
+
+const PATTERNS = SORT_SYMBOLS.length ** 3;
+/**
+ * Walks through all patterns so that neighboring codes differ in all three fields:
+ * sellers who sign up one after the other are easy to tell apart. Coprime to PATTERNS.
+ */
+const PATTERN_STEP = 121;
+
+export interface SortMark {
+ digit: number;
+ fields: [SortSymbol, SortSymbol, SortSymbol];
+ /** Empty for most sellers */
+ letter: string;
+}
+
+function letterOf(index: number): string {
+ let letter = '';
+ for (let rest = index; rest > 0; rest = Math.floor((rest - 1) / 26)) {
+ letter = String.fromCharCode(65 + ((rest - 1) % 26)) + letter;
+ }
+ return letter;
+}
+
+export function sortMark(code: number): SortMark {
+ const group = Math.floor(code / 10);
+ const pattern = (group * PATTERN_STEP) % PATTERNS;
+ const count = SORT_SYMBOLS.length;
+ return {
+ digit: code % 10,
+ fields: [
+ SORT_SYMBOLS[Math.floor(pattern / count ** 2)],
+ SORT_SYMBOLS[Math.floor(pattern / count) % count],
+ SORT_SYMBOLS[pattern % count],
+ ],
+ letter: letterOf(Math.floor(group / PATTERNS)),
+ };
+}
+
+/** For putting the baskets in a row in sorting order: by digit, then by the fields. */
+export function compareSortCodes(a: number, b: number): number {
+ const key = (code: number) => {
+ const mark = sortMark(code);
+ return [
+ mark.digit,
+ ...mark.fields.map((field) => SORT_SYMBOLS.indexOf(field)),
+ mark.letter.length,
+ ];
+ };
+ const [left, right] = [key(a), key(b)];
+ for (const [i, value] of left.entries()) {
+ if (value !== right[i]) return value - right[i];
+ }
+ return sortMark(a).letter.localeCompare(sortMark(b).letter);
+}
From c1d3f0113238f2eab43e772d89d2b572ccd9618d Mon Sep 17 00:00:00 2001
From: Ivo Zeitz
Date: Mon, 2 Nov 2026 10:59:05 +0100
Subject: [PATCH 04/58] feat(events): universal labels by default for kids and
clothing bazaars
Co-Authored-By: Claude Opus 5.5
---
src/lib/eventTypes.test.ts | 14 +++++++++++++-
src/lib/eventTypes.ts | 4 ++++
src/locales/de/organizer.json | 2 +-
src/locales/en/organizer.json | 2 +-
4 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/lib/eventTypes.test.ts b/src/lib/eventTypes.test.ts
index 278d7990..21370d55 100644
--- a/src/lib/eventTypes.test.ts
+++ b/src/lib/eventTypes.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { EVENT_TYPES, findEventType } from './eventTypes';
-import { showsPriceOnLabel } from '../shared/eventFeatures';
+import { effectiveLabelMark, showsPriceOnLabel } from '../shared/eventFeatures';
import { REQUIRABLE_FIELD_KEYS } from '../shared/categoryFields';
import i18n from '../i18n';
@@ -21,6 +21,18 @@ describe('event types', () => {
}
});
+ it('uses universal labels where many small items are sorted back', () => {
+ const marks = Object.fromEntries(
+ EVENT_TYPES.map((type) => [type.id, effectiveLabelMark(type)])
+ );
+ expect(marks).toEqual({
+ kidsBazaar: 'universal',
+ clothingBazaar: 'universal',
+ skiBazaar: 'number',
+ bikeExchange: 'number',
+ });
+ });
+
it('the most asked for kinds come first, each with examples for the previews', () => {
expect(EVENT_TYPES.map((type) => type.id)).toEqual([
'kidsBazaar',
diff --git a/src/lib/eventTypes.ts b/src/lib/eventTypes.ts
index 0db4bc4b..af51467a 100644
--- a/src/lib/eventTypes.ts
+++ b/src/lib/eventTypes.ts
@@ -38,6 +38,8 @@ export const EVENT_TYPES: EventType[] = [
photosOptional: true,
maxItemsPerSeller: 50,
labelFormat: 'small',
+ // Many small items: sorted back by sight, and the labels work at the next bazaar
+ labelMark: 'universal',
priceOnLabel: false,
},
categoryMatch: /kind|baby|spiel|kleid|schuh|buch/i,
@@ -57,6 +59,8 @@ export const EVENT_TYPES: EventType[] = [
photosOptional: true,
maxItemsPerSeller: 30,
labelFormat: 'small',
+ // Many small items: sorted back by sight, and the labels work at the next bazaar
+ labelMark: 'universal',
priceOnLabel: false,
},
categoryMatch: /kleid|schuh|accessoir|haushalt|buch|spiel/i,
diff --git a/src/locales/de/organizer.json b/src/locales/de/organizer.json
index 69db4127..5ed54778 100644
--- a/src/locales/de/organizer.json
+++ b/src/locales/de/organizer.json
@@ -902,7 +902,7 @@
"kidsBazaar": {
"title": "Kinderbasar",
"text": "Kinderkleidung, Spielzeug, Bücher und Ausstattung – viele kleine Teile pro Familie.",
- "highlights": ["Kleine Etiketten", "Fotos freiwillig", "Rabatte zum Schluss"],
+ "highlights": ["Universal-Etiketten", "Fotos freiwillig", "Rabatte zum Schluss"],
"exampleTitle": "Kinderbasar",
"exampleItems": [
"T-Shirt und Latzhose, Gr. 98",
diff --git a/src/locales/en/organizer.json b/src/locales/en/organizer.json
index 321a9453..bc006076 100644
--- a/src/locales/en/organizer.json
+++ b/src/locales/en/organizer.json
@@ -902,7 +902,7 @@
"kidsBazaar": {
"title": "Children's bazaar",
"text": "Children's clothes, toys, books and gear – many small items per family.",
- "highlights": ["Small labels", "Photos optional", "Discounts at the end"],
+ "highlights": ["Universal labels", "Photos optional", "Discounts at the end"],
"exampleTitle": "Children's bazaar",
"exampleItems": ["T-shirt and dungarees, size 98", "Lego box, mixed", "Rubber boots, size 27"]
},
From d00c820d945d4b6f5546c67c2029b167c341274e Mon Sep 17 00:00:00 2001
From: Ivo Zeitz
Date: Mon, 2 Nov 2026 13:43:57 +0100
Subject: [PATCH 05/58] feat(demo): seed universal labels, QR-only labels and
venue addresses
The kids and clothing bazaars print universal labels, the flea market
QR-only labels. Venues get a structured address, including one in Austria.
Co-Authored-By: Claude Opus 5.5
---
backend/src/demo/extended.rs | 54 ++++++++++++++++++++++++++++++++---
backend/tests/api/demo.rs | 55 ++++++++++++++++++++++++++++++++++++
2 files changed, 105 insertions(+), 4 deletions(-)
diff --git a/backend/src/demo/extended.rs b/backend/src/demo/extended.rs
index 57c5cddf..bfd47e87 100644
--- a/backend/src/demo/extended.rs
+++ b/backend/src/demo/extended.rs
@@ -108,11 +108,21 @@ struct Demo<'a> {
single: bool,
}
+/// Address of the venue. Empty parts in English: the address form knows no British towns,
+/// those demos keep it all in the location, as older events do.
+struct Venue {
+ street: Text,
+ postal_code: Text,
+ city: Text,
+ country: &'static str,
+}
+
struct EventPlan {
organizer: Uuid,
title: Text,
description: Text,
location: Text,
+ address: Option,
contact: &'static str,
services: &'static [&'static str],
visibility: &'static str,
@@ -239,6 +249,14 @@ impl Demo<'_> {
"commission": plan.commission,
"features": plan.features,
});
+ if let Some(venue) = &plan.address {
+ args["address"] = json!({
+ "street": self.text(venue.street),
+ "postalCode": self.text(venue.postal_code),
+ "city": self.text(venue.city),
+ "country": venue.country,
+ });
+ }
if let Some(cover) = self.seeder.image(plan.cover) {
args["coverImage"] = json!(cover);
}
@@ -659,9 +677,15 @@ async fn kids_bazaar(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"Second-hand bazaar for children's clothes, toys, books and prams. Run by the parents' council, 15 % go to the nursery. With a cake buffet!\n\nDrop-off the day before, unsold items can be picked up from 3 pm.",
),
location: t(
- "Kita Sonnenschein, Turnraum, Lindenstraße 4, Ulm",
+ "Kita Sonnenschein, Turnraum",
"Sunshine Nursery, gym, 4 Linden Street, Oxford",
),
+ address: Some(Venue {
+ street: t("Lindenstraße 4", ""),
+ postal_code: t("89073", ""),
+ city: t("Ulm", ""),
+ country: "DE",
+ }),
contact: "elternbeirat@example.org",
services: &["Imbiss", "Getränke"],
visibility: "public",
@@ -678,6 +702,7 @@ async fn kids_bazaar(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"minimumPrice": true,
"questions": true,
"labelFormat": "small",
+ "labelMark": "universal",
"intakeFee": 0.5,
"privateSellersOnly": true,
"fixedSellerData": true,
@@ -948,9 +973,15 @@ async fn ski_bazaar(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"Used skis, snowboards, boots, helmets and winter clothing. Our instructors help you choose, and the waxing service is on site.\n\nSellers register with the access code from the club newsletter.",
),
location: t(
- "Mehrzweckhalle Blaustein, Am Sportplatz 2",
+ "Mehrzweckhalle Blaustein",
"Blue Valley sports hall, 2 Sports Ground Road",
),
+ address: Some(Venue {
+ street: t("Am Sportplatz 2", ""),
+ postal_code: t("89134", ""),
+ city: t("Blaustein", ""),
+ country: "DE",
+ }),
contact: "skibasar@example.org",
services: &["Parkplatz", "Skiservice", "Getränke"],
visibility: "public",
@@ -1096,9 +1127,15 @@ async fn flea_market(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"Flea market in the courtyard of the community centre: household goods, furniture, electronics, bikes and clothes. Coffee and waffles from the neighbourhood café.",
),
location: t(
- "Stadtteiltreff Südstadt, Gartenweg 12",
+ "Stadtteiltreff Südstadt",
"Southside community centre, 12 Garden Lane",
),
+ address: Some(Venue {
+ street: t("Gartenweg 12", ""),
+ postal_code: t("89077", ""),
+ city: t("Ulm", ""),
+ country: "DE",
+ }),
contact: "suedstadt@example.org",
services: &["Gastronomie"],
visibility: "public",
@@ -1114,6 +1151,8 @@ async fn flea_market(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"priceOffers": true,
"minimumPrice": true,
"questions": true,
+ // Only the QR code: sellers bring the labels of their last flea market
+ "labelMark": "none",
}),
},
true,
@@ -1290,6 +1329,12 @@ async fn book_market(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"Second-hand books for a good cause: novels, non-fiction and children's books. Proceeds go to reading programmes.",
),
location: t("Stadtbibliothek, Foyer", "City library, foyer"),
+ address: Some(Venue {
+ street: t("Kirchstraße 12", "Kirchstraße 12"),
+ postal_code: t("6900", "6900"),
+ city: t("Bregenz", "Bregenz"),
+ country: "AT",
+ }),
contact: "bibliothek@example.org",
services: &["Getränke"],
visibility: "public",
@@ -1354,6 +1399,7 @@ async fn other_events(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()
title,
description,
location,
+ address: None,
contact: "kontakt@example.org",
services: &[],
visibility: "public",
@@ -1431,7 +1477,7 @@ async fn other_events(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()
vendor_limit: Some(3),
visibility: "logged-in",
categories: &[Cat::Clothing, Cat::Shoes],
- features: json!({ "discounts": false, "labelFormat": "small" }),
+ features: json!({ "discounts": false, "labelFormat": "small", "labelMark": "universal" }),
..plan(
sabine,
t("Kleiderbasar Gemeindehaus", "Parish Hall Clothes Sale"),
diff --git a/backend/tests/api/demo.rs b/backend/tests/api/demo.rs
index 2db9d361..73321117 100644
--- a/backend/tests/api/demo.rs
+++ b/backend/tests/api/demo.rs
@@ -157,6 +157,61 @@ async fn bazaars_in_every_state(db: PgPool) {
// The views of organizers, sellers and admins work on the data
let kids = event_id(&db, "Kinderbasar Kita Sonnenschein").await;
+ // Universal labels: the seller's lasting code instead of the number of this bazaar
+ let item: String = sqlx::query_scalar(
+ "SELECT p.id::text FROM products p
+ JOIN event_products ep ON ep.product_id = p.id
+ JOIN events e ON e.id = ep.event_id
+ JOIN users u ON u.id = p.vendor_id
+ WHERE e.title = 'Kinderbasar Kita Sonnenschein' AND u.email = 'anna.schmidt@example.org'
+ LIMIT 1",
+ )
+ .fetch_one(&db)
+ .await
+ .unwrap();
+ let labels = ok(
+ &app,
+ "labels.getLabelData",
+ json!({ "productIds": [item], "eventId": kids }),
+ Some(&seller),
+ )
+ .await;
+ assert_eq!(labels["format"], "small");
+ assert!(labels["labels"][0]["sortCode"].is_number());
+ assert!(labels["labels"][0].get("sellerNumber").is_none());
+ let vendors = ok(
+ &app,
+ "eventRoles.getVendorsForEvent",
+ json!({ "eventId": kids }),
+ Some(&organizer),
+ )
+ .await;
+ assert!(
+ vendors
+ .as_array()
+ .unwrap()
+ .iter()
+ .any(|vendor| vendor["sortCode"].is_number())
+ );
+ // The address form: venue name and address apart, also outside of Germany
+ assert_eq!(
+ count(
+ &db,
+ "SELECT count(*) FROM events WHERE title = 'Kinderbasar Kita Sonnenschein'
+ AND location = 'Kita Sonnenschein, Turnraum' AND street = 'Lindenstraße 4'
+ AND postal_code = '89073' AND city = 'Ulm'"
+ )
+ .await,
+ 1
+ );
+ assert_eq!(
+ count(
+ &db,
+ "SELECT count(*) FROM events WHERE country = 'AT' AND city = 'Bregenz'"
+ )
+ .await,
+ 1
+ );
let event = json!({ "eventId": kids });
let summary = ok(
&app,
From 66fc7943439b148bc4745c4e3aecc76fc0a724c5 Mon Sep 17 00:00:00 2001
From: Ivo Zeitz
Date: Mon, 2 Nov 2026 21:36:49 +0100
Subject: [PATCH 06/58] feat(marketing): explain universal labels on the public
pages
The features page shows example labels and links to the guide, the pricing
FAQ answers what a universal label is, and the short texts name the option.
Co-Authored-By: Claude Opus 5.5
---
src/locales/de/company.json | 31 ++++++-
src/locales/de/landing.json | 2 +-
src/locales/de/organizer.json | 2 +-
src/locales/en/company.json | 31 ++++++-
src/locales/en/landing.json | 2 +-
src/locales/en/organizer.json | 2 +-
src/pages/public/company/FeaturesPage.tsx | 3 +
src/pages/public/company/PricingPage.tsx | 2 +-
.../components/UniversalLabelSection.tsx | 91 +++++++++++++++++++
9 files changed, 157 insertions(+), 9 deletions(-)
create mode 100644 src/pages/public/company/components/UniversalLabelSection.tsx
diff --git a/src/locales/de/company.json b/src/locales/de/company.json
index 824565f7..7263f1eb 100644
--- a/src/locales/de/company.json
+++ b/src/locales/de/company.json
@@ -44,6 +44,29 @@
"text": "App und E-Mails gibt es auf Deutsch und Englisch. Jeder bekommt Mails in seiner Sprache."
}
},
+ "universalLabel": {
+ "eyebrow": "Universal-Etikett",
+ "title": "Zurücksortieren, ohne zu lesen",
+ "text": "Bei Kinder- und Kleiderbasaren müssen am Ende Hunderte kleine Teile zurück zu ihren Verkäufern. Dabei hilft ein Zeichen aus Ziffer, Farben und Symbolen, das jeder Verkäufer behält.",
+ "example": "Beispiel für drei Etiketten eines Verkäufers mit demselben Sortierzeichen",
+ "exampleItems": ["Body mit Bären", "Regenjacke", "Gummistiefel"],
+ "steps": {
+ "sort": {
+ "title": "Auf einen Blick sortieren",
+ "text": "Helfer legen die Ware erst nach der großen Ziffer auf Stapel und dann nach Farben und Symbolen in die Kiste des Verkäufers. Die Sortierblätter für die Kisten druckt BazarPro."
+ },
+ "reuse": {
+ "title": "Beim nächsten Basar wiederverwenden",
+ "text": "Das Zeichen bleibt beim Verkäufer. Unverkaufte Teile behalten ihr Etikett, wenn auch der nächste Basar Universal-Etiketten nutzt."
+ },
+ "print": {
+ "title": "Auf jedem Drucker",
+ "text": "Jede Farbe hat ihr eigenes Symbol, deshalb klappt es auch im Schwarz-Weiß-Druck und für farbenblinde Helfer."
+ }
+ },
+ "default": "Bei den Vorlagen für Kinder- und Kleiderbasare schon eingestellt. Für wenige große Artikel wie Fahrräder bleibt die Verkäufernummer die bessere Wahl.",
+ "guide": "So funktioniert das Universal-Etikett"
+ },
"useCases": {
"eyebrow": "Einsatzbereiche",
"title": "Für jeden Second-Hand-Basar",
@@ -53,7 +76,7 @@
"bazaarTypes": {
"kids": {
"title": "Kinderkleiderbasar",
- "text": "Kleiderbasar, Kinderbasar oder Nummernbasar: viele kleine Teile, kleine Etiketten, Fotos freiwillig."
+ "text": "Kleiderbasar, Kinderbasar oder Nummernbasar: viele kleine Teile, Universal-Etiketten zum Wiederverwenden, Fotos freiwillig."
},
"bikes": {
"title": "Fahrradbörse",
@@ -80,7 +103,7 @@
"wizard": "Assistent zum Anlegen mit Vorlagen für Fahrradbörse, Kinderbasar und Flohmarkt",
"registration": "Online-Anmeldung von Verkäufern mit Zugangscode und Teilnehmerlimit",
"listing": "Artikel mit Foto und Preis online erfassen",
- "labels": "QR-Code-Etiketten als PDF, groß oder klein, mit Verkäufernummer",
+ "labels": "QR-Code-Etiketten als PDF, groß oder klein, mit Verkäufernummer oder als wiederverwendbares Universal-Etikett",
"scan": "Warenannahme und Kasse per Smartphone-Scan",
"cart": "Kasse mit Warenkorb, per Handykamera oder Hand-Scanner",
"offline": "Offline-Kasse in der App: verkauft ohne Internet und bucht später nach",
@@ -216,6 +239,10 @@
"question": "Brauche ich eine Kasse oder einen Scanner?",
"answer": "Nein. Warenannahme und Verkauf laufen im Browser über die Kamera eines Smartphones oder Tablets. Einen Hand-Scanner kannst du an der Kasse zusätzlich nutzen. Etiketten druckst du auf normalem Papier."
},
+ "universalLabels": {
+ "question": "Was ist ein Universal-Etikett?",
+ "answer": "Ein kleines Etikett, das statt der Verkäufernummer ein festes Zeichen des Verkäufers aus Ziffer, Farben und Symbolen trägt. Helfer sortieren unverkaufte Ware danach zurück, ohne zu lesen. Unverkaufte Teile behalten ihr Etikett beim nächsten Basar mit Universal-Etiketten, und es funktioniert auch im Schwarz-Weiß-Druck."
+ },
"selfHost": {
"question": "Kann ich BazarPro auf meinem eigenen Server betreiben?",
"answer": "Ja. BazarPro ist Open Source unter MIT-Lizenz. Mit Docker Compose läuft es auf einem eigenen Server – die Anleitung steht in der Dokumentation unter docs.bazarpro.de."
diff --git a/src/locales/de/landing.json b/src/locales/de/landing.json
index 17d4629b..b7e4a7b8 100644
--- a/src/locales/de/landing.json
+++ b/src/locales/de/landing.json
@@ -18,7 +18,7 @@
},
"printer": {
"title": "Etiketten als PDF",
- "text": "Groß oder klein, mit Verkäufernummer – einzeln oder alle auf einmal."
+ "text": "Groß oder klein, mit Verkäufernummer oder als Universal-Etikett zum Wiederverwenden – einzeln oder alle auf einmal."
},
"badgePercent": {
"title": "Rabatte",
diff --git a/src/locales/de/organizer.json b/src/locales/de/organizer.json
index 5ed54778..04cfa5f8 100644
--- a/src/locales/de/organizer.json
+++ b/src/locales/de/organizer.json
@@ -913,7 +913,7 @@
"clothingBazaar": {
"title": "Kleider- & Second-Hand-Basar",
"text": "Damen-, Herren- oder Familienkleidung, Schuhe und Haushalt – oder ein klassischer Flohmarkt.",
- "highlights": ["Preisvorschläge", "Fragen an Verkäufer", "Rabatte"],
+ "highlights": ["Universal-Etiketten", "Preisvorschläge", "Fragen an Verkäufer"],
"exampleTitle": "Second-Hand-Basar",
"exampleItems": ["Jacke, Gr. 38", "Lederstiefel, Gr. 39", "Handtasche, Leder"]
},
diff --git a/src/locales/en/company.json b/src/locales/en/company.json
index dd7c0d6d..4afc655e 100644
--- a/src/locales/en/company.json
+++ b/src/locales/en/company.json
@@ -44,6 +44,29 @@
"text": "The app and its emails are available in German and English. Everyone gets emails in their own language."
}
},
+ "universalLabel": {
+ "eyebrow": "Universal label",
+ "title": "Sort items back without reading",
+ "text": "At kids' and clothing bazaars, hundreds of small items have to go back to their sellers at the end. A mark made of a digit, colors and symbols, which each seller keeps, makes this easier.",
+ "example": "Example of three labels from one seller with the same sorting mark",
+ "exampleItems": ["Bodysuit with bears", "Rain jacket", "Rubber boots"],
+ "steps": {
+ "sort": {
+ "title": "Sort at a glance",
+ "text": "Helpers pile the items by the large digit first, then put them into the seller's basket by colors and symbols. BazarPro prints the sorting sheets for the baskets."
+ },
+ "reuse": {
+ "title": "Reuse at the next bazaar",
+ "text": "The mark stays with the seller. Unsold items keep their label if the next bazaar uses universal labels too."
+ },
+ "print": {
+ "title": "On any printer",
+ "text": "Every color has its own symbol, so it also works in black and white and for color-blind helpers."
+ }
+ },
+ "default": "Already set in the templates for kids' and clothing bazaars. For a few large items such as bikes, the seller number remains the better choice.",
+ "guide": "How the universal label works"
+ },
"useCases": {
"eyebrow": "Use cases",
"title": "For every second-hand bazaar",
@@ -53,7 +76,7 @@
"bazaarTypes": {
"kids": {
"title": "Children's clothing bazaar",
- "text": "Clothing, kids' or numbered bazaar: many small items, small labels, photos optional."
+ "text": "Clothing, kids' or numbered bazaar: many small items, reusable universal labels, photos optional."
},
"bikes": {
"title": "Bike sale",
@@ -80,7 +103,7 @@
"wizard": "Creation wizard with presets for bike sales, kids' bazaars and flea markets",
"registration": "Online seller registration with access code and participant limit",
"listing": "Enter items online with photo and price",
- "labels": "QR code labels as PDF, large or small, with seller number",
+ "labels": "QR code labels as PDF, large or small, with seller number or as a reusable universal label",
"scan": "Drop-off and checkout by smartphone scan",
"cart": "Checkout with a cart, by phone camera or hand scanner",
"offline": "Offline checkout in the app: sells without internet and books the sales later",
@@ -216,6 +239,10 @@
"question": "Do I need a till or a scanner?",
"answer": "No. Drop-off and sales run in the browser using the camera of a smartphone or tablet. You can also use a hand scanner at the checkout. You print labels on regular paper."
},
+ "universalLabels": {
+ "question": "What is a universal label?",
+ "answer": "A small label that carries a seller's lasting mark made of a digit, colors and symbols instead of the seller number. Helpers sort unsold items back by it without reading. Unsold items keep their label at the next bazaar with universal labels, and it also works in black and white."
+ },
"selfHost": {
"question": "Can I run BazarPro on my own server?",
"answer": "Yes. BazarPro is open source under the MIT license. With Docker Compose it runs on your own server – the guide is in the documentation at docs.bazarpro.de."
diff --git a/src/locales/en/landing.json b/src/locales/en/landing.json
index 286e8ef8..97adf42b 100644
--- a/src/locales/en/landing.json
+++ b/src/locales/en/landing.json
@@ -18,7 +18,7 @@
},
"printer": {
"title": "Labels as PDF",
- "text": "Large or small, with your seller number – one by one or all at once."
+ "text": "Large or small, with your seller number or as a reusable universal label – one by one or all at once."
},
"badgePercent": {
"title": "Discounts",
diff --git a/src/locales/en/organizer.json b/src/locales/en/organizer.json
index bc006076..bd0dbc0b 100644
--- a/src/locales/en/organizer.json
+++ b/src/locales/en/organizer.json
@@ -909,7 +909,7 @@
"clothingBazaar": {
"title": "Clothing & second-hand bazaar",
"text": "Women's, men's or family clothing, shoes and household goods – or a classic flea market.",
- "highlights": ["Price offers", "Questions to sellers", "Discounts"],
+ "highlights": ["Universal labels", "Price offers", "Questions to sellers"],
"exampleTitle": "Second-hand bazaar",
"exampleItems": ["Jacket, size 38", "Leather boots, size 39", "Leather handbag"]
},
diff --git a/src/pages/public/company/FeaturesPage.tsx b/src/pages/public/company/FeaturesPage.tsx
index e7cddb4f..f3fa1523 100644
--- a/src/pages/public/company/FeaturesPage.tsx
+++ b/src/pages/public/company/FeaturesPage.tsx
@@ -27,6 +27,7 @@ import { LandingCTA } from '../landing/components/LandingCTA';
import { LandingFeatures } from '../landing/components/LandingFeatures';
import { MarketingHero, SectionHeading } from './components/MarketingHero';
import { OpenSourceSection } from './components/OpenSourceSection';
+import { UniversalLabelSection } from './components/UniversalLabelSection';
import { useStartActions } from './components/useStartActions';
import { Trans, useTranslation } from 'react-i18next';
@@ -186,6 +187,8 @@ export function FeaturesPage() {
+
+
{/* Use cases */}
diff --git a/src/pages/public/company/PricingPage.tsx b/src/pages/public/company/PricingPage.tsx
index 011d7d66..4ea30193 100644
--- a/src/pages/public/company/PricingPage.tsx
+++ b/src/pages/public/company/PricingPage.tsx
@@ -15,7 +15,7 @@ const HOSTED_FEATURES = ['unlimited', 'labels', 'settlement', 'instant'] as cons
const SELFHOSTED_FEATURES = ['allFeatures', 'ownData', 'ownDomain', 'docker'] as const;
-const FAQ = ['free', 'useCases', 'commission', 'hardware', 'selfHost'] as const;
+const FAQ = ['free', 'useCases', 'commission', 'hardware', 'universalLabels', 'selfHost'] as const;
export function PricingPage() {
const { isAuthenticated, goToOrganizer, goToSeller } = useStartActions();
diff --git a/src/pages/public/company/components/UniversalLabelSection.tsx b/src/pages/public/company/components/UniversalLabelSection.tsx
new file mode 100644
index 00000000..2a05c159
--- /dev/null
+++ b/src/pages/public/company/components/UniversalLabelSection.tsx
@@ -0,0 +1,91 @@
+import { ArrowRight, Printer, Recycle, ScanEye, type LucideIcon } from 'lucide-react';
+import { QRCodeSVG } from 'qrcode.react';
+import { useTranslation } from 'react-i18next';
+import { SortMarkBadge } from '../../../../components/sellers/SortMarkBadge';
+import { docsUrl } from '../../../../lib/links';
+import { SectionHeading } from './MarketingHero';
+
+/** Any code gives a realistic mark; this one has three clearly different fields. */
+const EXAMPLE_SORT_CODE = 175;
+
+const STEPS: { icon: LucideIcon; id: 'sort' | 'reuse' | 'print' }[] = [
+ { icon: ScanEye, id: 'sort' },
+ { icon: Recycle, id: 'reuse' },
+ { icon: Printer, id: 'print' },
+];
+
+/** Explains universal labels with labels as they are printed, in every theme on white. */
+export function UniversalLabelSection() {
+ const { t, i18n } = useTranslation('company');
+ const items = t('featuresPage.universalLabel.exampleItems', {
+ returnObjects: true,
+ }) as string[];
+
+ return (
+
+
+
+ );
+}
From 89d84a45978d22005d13ea6e1d6cc1c5db34036c Mon Sep 17 00:00:00 2001
From: Ivo Zeitz
Date: Tue, 3 Nov 2026 04:51:32 +0100
Subject: [PATCH 07/58] feat(account): country selector in the profile and the
join wizard
Profiles now store country codes like events do, and the postal code is
checked by the chosen country. A migration converts common spellings; other
text stays selectable and is shown as typed.
Co-Authored-By: Claude Opus 5.5
---
backend/migrations/0018_user_country_code.sql | 13 +++++
backend/src/demo/catalog.rs | 6 +--
backend/src/demo/core.rs | 2 +-
backend/src/modules/users.rs | 2 +-
backend/tests/api/users.rs | 34 +++++++++++++
.../ValidateProfileInformation.test.tsx | 50 +++++++++++++++++++
.../events/ValidateProfileInformation.tsx | 32 ++++++------
src/components/sellers/SellerIdCheck.tsx | 3 +-
src/components/ui/country-select.tsx | 34 +++++++++++++
src/i18n/countries.test.ts | 20 ++++++++
src/i18n/countries.ts | 11 ++++
src/lib/proofOfOffersPdf.ts | 4 +-
src/locales/de/account.json | 4 +-
src/locales/de/common.json | 7 +++
src/locales/de/organizer.json | 7 ---
src/locales/en/account.json | 4 +-
src/locales/en/common.json | 7 +++
src/locales/en/organizer.json | 7 ---
src/pages/account/components/ProfileCard.tsx | 22 ++++----
src/pages/organizer/events/EditEventForm.tsx | 6 +--
.../events/components/EditEventBasicInfo.tsx | 15 +-----
.../dashboard/ProductManagementPage.tsx | 5 +-
src/shared/constants.ts | 15 ++++--
src/tests/auth/profile.spec.ts | 4 +-
24 files changed, 240 insertions(+), 74 deletions(-)
create mode 100644 backend/migrations/0018_user_country_code.sql
create mode 100644 src/components/events/ValidateProfileInformation.test.tsx
create mode 100644 src/components/ui/country-select.tsx
create mode 100644 src/i18n/countries.test.ts
create mode 100644 src/i18n/countries.ts
diff --git a/backend/migrations/0018_user_country_code.sql b/backend/migrations/0018_user_country_code.sql
new file mode 100644
index 00000000..5e138199
--- /dev/null
+++ b/backend/migrations/0018_user_country_code.sql
@@ -0,0 +1,13 @@
+-- Profile countries were free text; now they are ISO 3166-1 alpha-2 codes like those of events.
+-- Other values stay as they are and keep being shown as typed. Snapshots of sellers keep what
+-- was true when they were taken.
+UPDATE users SET country = CASE
+ WHEN lower(trim(country)) IN ('de', 'd', 'deu', 'ger', 'brd', 'deutschland', 'germany') THEN 'DE'
+ -- translate: lower() leaves Ö alone in databases with the C locale
+ WHEN translate(lower(trim(country)), 'Ö', 'ö') IN ('at', 'a', 'aut', 'österreich', 'oesterreich', 'austria') THEN 'AT'
+ WHEN lower(trim(country)) IN ('ch', 'che', 'schweiz', 'switzerland', 'suisse', 'svizzera') THEN 'CH'
+ WHEN lower(trim(country)) IN ('li', 'lie', 'liechtenstein') THEN 'LI'
+ WHEN lower(trim(country)) IN ('lu', 'lux', 'luxemburg', 'luxembourg') THEN 'LU'
+ ELSE country
+ END
+WHERE country IS NOT NULL;
diff --git a/backend/src/demo/catalog.rs b/backend/src/demo/catalog.rs
index 670a1bee..7e379f81 100644
--- a/backend/src/demo/catalog.rs
+++ b/backend/src/demo/catalog.rs
@@ -211,17 +211,17 @@ pub fn city(locale: Locale, index: usize) -> City {
City {
zip: "89073",
name: "Ulm",
- country: "Deutschland",
+ country: "DE",
},
City {
zip: "89231",
name: "Neu-Ulm",
- country: "Deutschland",
+ country: "DE",
},
City {
zip: "89077",
name: "Ulm",
- country: "Deutschland",
+ country: "DE",
},
];
const EN: [City; 3] = [
diff --git a/backend/src/demo/core.rs b/backend/src/demo/core.rs
index d96fefcd..1f66e96b 100644
--- a/backend/src/demo/core.rs
+++ b/backend/src/demo/core.rs
@@ -653,7 +653,7 @@ pub async fn insert_users(seeder: &Seeder, ctx: &mut Ctx) -> AppResult AppResult String {
+ sqlx::query("UPDATE users SET country = $2 WHERE id = $1")
+ .bind(user)
+ .bind(stored)
+ .execute(&db)
+ .await
+ .unwrap();
+ sqlx::raw_sql(include_str!("../../migrations/0018_user_country_code.sql"))
+ .execute(&db)
+ .await
+ .unwrap();
+ sqlx::query_scalar("SELECT country FROM users WHERE id = $1")
+ .bind(user)
+ .fetch_one(&db)
+ .await
+ .unwrap()
+ };
+ for (stored, code) in [
+ ("Deutschland", "DE"),
+ (" germany ", "DE"),
+ ("de", "DE"),
+ ("Österreich", "AT"),
+ ("ÖSTERREICH", "AT"),
+ ("Schweiz", "CH"),
+ ("Luxembourg", "LU"),
+ ("United Kingdom", "United Kingdom"),
+ ] {
+ assert_eq!(country(stored).await, code);
+ }
+}
diff --git a/src/components/events/ValidateProfileInformation.test.tsx b/src/components/events/ValidateProfileInformation.test.tsx
new file mode 100644
index 00000000..d21bcd07
--- /dev/null
+++ b/src/components/events/ValidateProfileInformation.test.tsx
@@ -0,0 +1,50 @@
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import type { Doc } from '../../lib/api/types';
+import { ValidateProfileInformation } from './ValidateProfileInformation';
+
+const update = vi.hoisted(() => vi.fn(async () => undefined));
+vi.mock('../../lib/api/react', () => ({ useMutation: () => update }));
+
+const fill = (label: string, value: string) =>
+ fireEvent.change(screen.getByLabelText(label), { target: { value } });
+
+function renderAddressStep(country?: string) {
+ render(
+ }
+ />
+ );
+ fill('Straße und Hausnummer', 'Kirchstraße 12');
+ fill('Ort', 'Bregenz');
+}
+
+describe('ValidateProfileInformation', () => {
+ beforeEach(() => update.mockClear());
+
+ it('preselects Germany and checks the postal code by the chosen country', async () => {
+ renderAddressStep();
+ expect(screen.getByLabelText('Land')).toHaveValue('DE');
+ fill('Postleitzahl', '6900');
+ fireEvent.click(screen.getByRole('button', { name: 'Adresse speichern' }));
+ expect(await screen.findByText('Ungültige Postleitzahl für dieses Land')).toBeVisible();
+ expect(update).not.toHaveBeenCalled();
+
+ fill('Land', 'AT');
+ fireEvent.click(screen.getByRole('button', { name: 'Adresse speichern' }));
+ await waitFor(() =>
+ expect(update).toHaveBeenCalledWith({
+ street: 'Kirchstraße 12',
+ city: 'Bregenz',
+ zipCode: '6900',
+ country: 'AT',
+ })
+ );
+ });
+
+ it('keeps a country typed into an older profile', () => {
+ renderAddressStep('United Kingdom');
+ expect(screen.getByLabelText('Land')).toHaveValue('United Kingdom');
+ });
+});
diff --git a/src/components/events/ValidateProfileInformation.tsx b/src/components/events/ValidateProfileInformation.tsx
index 094ffc14..1d1dc5a3 100644
--- a/src/components/events/ValidateProfileInformation.tsx
+++ b/src/components/events/ValidateProfileInformation.tsx
@@ -2,6 +2,7 @@ import { useEffect } from 'react';
import { Label } from '../ui/label';
import { Input } from '../ui/input';
import { Button } from '../ui/button';
+import { CountrySelect } from '../ui/country-select';
import { useMutation } from '../../lib/api/react';
import { api } from '../../lib/api/functions';
import type { Doc } from '../../lib/api/types';
@@ -11,6 +12,7 @@ import { useForm } from 'react-hook-form';
import { getUserFacingErrorMessage } from '../../lib/errors';
import { useTranslation } from 'react-i18next';
import i18n from '../../i18n';
+import { isPostalCodeValid } from '../../shared/constants';
/** Error text in the current language, read when validating */
const msg = (key: string, ns = 'events') => ({
@@ -27,10 +29,7 @@ const profileSchema = z.object({
.regex(/^\+?[0-9\s\-()]{7,20}$/, msg('profile.invalidPhone', 'account')),
street: z.string().trim().min(1, msg('profile.streetRequired')),
city: z.string().trim().min(1, msg('profile.cityRequired')),
- zipCode: z
- .string()
- .trim()
- .regex(/^\d{5}$/, msg('profile.invalidZip', 'account')),
+ zipCode: z.string().trim().min(1, msg('profile.invalidZip', 'account')),
country: z.string().trim().min(1, msg('profile.countryRequired')),
});
@@ -40,12 +39,17 @@ const basicProfileSchema = profileSchema.pick({
phone: true,
});
-const addressProfileSchema = profileSchema.pick({
- street: true,
- city: true,
- zipCode: true,
- country: true,
-});
+const addressProfileSchema = profileSchema
+ .pick({
+ street: true,
+ city: true,
+ zipCode: true,
+ country: true,
+ })
+ .refine((address) => isPostalCodeValid(address.zipCode, address.country), {
+ path: ['zipCode'],
+ ...msg('profile.invalidZip', 'account'),
+ });
type ProfileFormData = z.infer;
type BasicProfileFormData = z.infer;
@@ -93,7 +97,7 @@ export function ValidateProfileInformation({
street: user.street ?? '',
city: user.city ?? '',
zipCode: user.zipCode ?? '',
- country: user.country ?? '',
+ country: user.country || 'DE',
});
}, [user, isDirty, reset]);
@@ -259,11 +263,7 @@ export function ValidateProfileInformation({
-
+
{errors.country && (
{errors.country.message}
)}
diff --git a/src/components/sellers/SellerIdCheck.tsx b/src/components/sellers/SellerIdCheck.tsx
index 67cb5afb..fe4cba74 100644
--- a/src/components/sellers/SellerIdCheck.tsx
+++ b/src/components/sellers/SellerIdCheck.tsx
@@ -2,6 +2,7 @@ import { IdCard } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Alert, AlertDescription, AlertTitle } from '../ui/alert';
import type { VendorWithCalculations } from '../../lib/api/types';
+import { countryName } from '../../i18n/countries';
/**
* Bazaars with fixedSellerData: name and address as they will be recorded with the first
@@ -20,7 +21,7 @@ export function SellerIdCheck({ seller }: { seller: VendorWithCalculations }) {
{name &&
{name}
}
{seller.street &&
{seller.street}
}
{place &&
{place}
}
- {seller.country &&
{seller.country}
}
+ {seller.country &&
{countryName(seller.country)}
}
{t('products.idCheckText')}
diff --git a/src/components/ui/country-select.tsx b/src/components/ui/country-select.tsx
new file mode 100644
index 00000000..3790e594
--- /dev/null
+++ b/src/components/ui/country-select.tsx
@@ -0,0 +1,34 @@
+import type { ComponentProps } from 'react';
+import { useTranslation } from 'react-i18next';
+import { isCountry } from '../../i18n/countries';
+import { COUNTRIES } from '../../shared/constants';
+import { cn } from '../utils';
+
+interface CountrySelectProps extends ComponentProps<'select'> {
+ /** Value already saved: free text of an older profile stays selectable, not overwritten */
+ saved?: string;
+ /** Adds a choice for no country, with this label */
+ emptyLabel?: string;
+}
+
+export function CountrySelect({ saved, emptyLabel, className, ...props }: CountrySelectProps) {
+ const { t } = useTranslation('common');
+ return (
+
+ );
+}
diff --git a/src/i18n/countries.test.ts b/src/i18n/countries.test.ts
new file mode 100644
index 00000000..693cf9fc
--- /dev/null
+++ b/src/i18n/countries.test.ts
@@ -0,0 +1,20 @@
+import { describe, expect, it } from 'vitest';
+import { isPostalCodeValid } from '../shared/constants';
+import { countryName } from './countries';
+
+describe('countries', () => {
+ it('names known codes and leaves the free text of older profiles', () => {
+ expect(countryName('AT')).toBe('Österreich');
+ expect(countryName('United Kingdom')).toBe('United Kingdom');
+ });
+
+ it('checks postal codes by country', () => {
+ expect(isPostalCodeValid('89073', 'DE')).toBe(true);
+ expect(isPostalCodeValid('6900', 'DE')).toBe(false);
+ expect(isPostalCodeValid('6900', 'AT')).toBe(true);
+ expect(isPostalCodeValid('89073', 'AT')).toBe(false);
+ // No country counts as Germany, free text has no known format
+ expect(isPostalCodeValid('6900', '')).toBe(false);
+ expect(isPostalCodeValid('OX1 2JD', 'United Kingdom')).toBe(true);
+ });
+});
diff --git a/src/i18n/countries.ts b/src/i18n/countries.ts
new file mode 100644
index 00000000..4c9a9ed1
--- /dev/null
+++ b/src/i18n/countries.ts
@@ -0,0 +1,11 @@
+import i18n from '.';
+import { COUNTRIES, type Country } from '../shared/constants';
+
+export function isCountry(value: string | null | undefined): value is Country {
+ return COUNTRIES.some((code) => code === value);
+}
+
+/** Name in the current language; older profiles and records may hold free text, shown as is. */
+export function countryName(value: string): string {
+ return isCountry(value) ? (i18n.t(`countries.${value}`, { ns: 'common' }) as string) : value;
+}
diff --git a/src/lib/proofOfOffersPdf.ts b/src/lib/proofOfOffersPdf.ts
index 91165cb9..e3407ee9 100644
--- a/src/lib/proofOfOffersPdf.ts
+++ b/src/lib/proofOfOffersPdf.ts
@@ -2,6 +2,7 @@ import { jsPDF } from 'jspdf';
import type { ProofItem, ProofSeller } from './api/types';
import { formatPriceDE } from './utils';
import { categoryFieldText } from '../i18n/categoryFields';
+import { countryName } from '../i18n/countries';
import i18n from '../i18n';
import { dateLocale } from '../i18n/format';
import { saveFile, savePdf } from './saveFile';
@@ -36,7 +37,8 @@ export function sellerAddress(
seller: Pick
): string {
const city = [seller.zipCode, seller.city].filter(Boolean).join(' ');
- return [seller.street, city, seller.country].filter(Boolean).join(', ') || '–';
+ const country = seller.country && countryName(seller.country);
+ return [seller.street, city, country].filter(Boolean).join(', ') || '–';
}
function contact(seller: ProofSeller): string {
diff --git a/src/locales/de/account.json b/src/locales/de/account.json
index c149a144..9fb7e84e 100644
--- a/src/locales/de/account.json
+++ b/src/locales/de/account.json
@@ -16,9 +16,9 @@
"city": "Ort",
"cityPlaceholder": "Musterstadt",
"country": "Land",
- "countryPlaceholder": "Deutschland",
+ "countryNone": "Bitte wählen",
"invalidPhone": "Ungültiges Telefonnummer-Format (z. B. +49 123 456789)",
- "invalidZip": "Ungültige Postleitzahl (5 Ziffern erforderlich)",
+ "invalidZip": "Ungültige Postleitzahl für dieses Land",
"save": "Profil aktualisieren",
"saved": "Profil erfolgreich aktualisiert!",
"saveFailed": "Fehler beim Aktualisieren des Profils.",
diff --git a/src/locales/de/common.json b/src/locales/de/common.json
index 443d5729..f3ddebec 100644
--- a/src/locales/de/common.json
+++ b/src/locales/de/common.json
@@ -1,4 +1,11 @@
{
+ "countries": {
+ "DE": "Deutschland",
+ "AT": "Österreich",
+ "CH": "Schweiz",
+ "LI": "Liechtenstein",
+ "LU": "Luxemburg"
+ },
"header": {
"login": "Anmelden",
"register": "Registrieren",
diff --git a/src/locales/de/organizer.json b/src/locales/de/organizer.json
index 04cfa5f8..27b91008 100644
--- a/src/locales/de/organizer.json
+++ b/src/locales/de/organizer.json
@@ -64,13 +64,6 @@
"postalCode": "PLZ",
"city": "Ort",
"country": "Land",
- "countries": {
- "DE": "Deutschland",
- "AT": "Österreich",
- "CH": "Schweiz",
- "LI": "Liechtenstein",
- "LU": "Luxemburg"
- },
"start": "Startdatum *",
"end": "Enddatum *"
},
diff --git a/src/locales/en/account.json b/src/locales/en/account.json
index 19a06890..f7f245ff 100644
--- a/src/locales/en/account.json
+++ b/src/locales/en/account.json
@@ -16,9 +16,9 @@
"city": "City",
"cityPlaceholder": "Sample City",
"country": "Country",
- "countryPlaceholder": "Germany",
+ "countryNone": "Please choose",
"invalidPhone": "Invalid phone number format (e.g. +49 123 456789)",
- "invalidZip": "Invalid postal code (5 digits required)",
+ "invalidZip": "Invalid postal code for this country",
"save": "Update profile",
"saved": "Profile updated!",
"saveFailed": "The profile could not be updated.",
diff --git a/src/locales/en/common.json b/src/locales/en/common.json
index f1b5e964..ec7b5189 100644
--- a/src/locales/en/common.json
+++ b/src/locales/en/common.json
@@ -1,4 +1,11 @@
{
+ "countries": {
+ "DE": "Germany",
+ "AT": "Austria",
+ "CH": "Switzerland",
+ "LI": "Liechtenstein",
+ "LU": "Luxembourg"
+ },
"header": {
"login": "Log in",
"register": "Sign up",
diff --git a/src/locales/en/organizer.json b/src/locales/en/organizer.json
index bd0dbc0b..4e1aca14 100644
--- a/src/locales/en/organizer.json
+++ b/src/locales/en/organizer.json
@@ -64,13 +64,6 @@
"postalCode": "Postal code",
"city": "Town",
"country": "Country",
- "countries": {
- "DE": "Germany",
- "AT": "Austria",
- "CH": "Switzerland",
- "LI": "Liechtenstein",
- "LU": "Luxembourg"
- },
"start": "Start date *",
"end": "End date *"
},
diff --git a/src/pages/account/components/ProfileCard.tsx b/src/pages/account/components/ProfileCard.tsx
index eaadc968..fea5b32d 100644
--- a/src/pages/account/components/ProfileCard.tsx
+++ b/src/pages/account/components/ProfileCard.tsx
@@ -5,6 +5,7 @@ import { z } from 'zod';
import { useMutation, useQuery } from '../../../lib/api/react';
import { api } from '../../../lib/api/functions';
import { Button } from '../../../components/ui/button';
+import { CountrySelect } from '../../../components/ui/country-select';
import { Input } from '../../../components/ui/input';
import { Label } from '../../../components/ui/label';
import { Separator } from '../../../components/ui/separator';
@@ -15,9 +16,10 @@ import { getUserFacingErrorMessage } from '../../../lib/errors';
import { useTranslation } from 'react-i18next';
import type { TFunction } from 'i18next';
import { Alert, AlertDescription } from '../../../components/ui/alert';
+import { isPostalCodeValid } from '../../../shared/constants';
function buildProfileSchema(t: TFunction<'account'>) {
- return z.object({
+ const schema = z.object({
firstName: z.string().optional(),
lastName: z.string().optional(),
phone: z
@@ -28,14 +30,13 @@ function buildProfileSchema(t: TFunction<'account'>) {
}),
street: z.string().optional(),
city: z.string().optional(),
- zipCode: z
- .string()
- .optional()
- .refine((val) => !val || /^\d{5}$/.test(val), {
- message: t('profile.invalidZip'),
- }),
+ zipCode: z.string().optional(),
country: z.string().optional(),
});
+ return schema.refine(({ zipCode, country }) => !zipCode || isPostalCodeValid(zipCode, country), {
+ path: ['zipCode'],
+ message: t('profile.invalidZip'),
+ });
}
type ProfileFormData = z.infer>;
@@ -200,10 +201,11 @@ export function ProfileCard({ user }: ProfileCardProps) {