From daa4ec6dbfd62b76b2809a205df56850263e7440 Mon Sep 17 00:00:00 2001 From: Henri Salmi Date: Sat, 17 Oct 2026 14:54:48 +0300 Subject: [PATCH 1/2] feat: prefill Telegram and dietary restriction answers in registrations Registration prefilled only the name and email. Telegram handles and dietary restrictions are asked with ordinary event questions, so an admin can now mark a TEXT question as one or the other (event_questions.prefill), and its answer is prefilled from the user's registration profile. The profile lives in its own table, readable only by its owner, because app_public.users is publicly visible. Users edit it on the profile settings page, and finishing a registration with one's own email saves the non-empty answers to marked questions into it. Co-Authored-By: Claude Opus 5.5 --- .../event/EventPage_Subscription.graphql | 1 + .../CreateEventRegistrationPage_Query.graphql | 6 + .../graphql/user/RegistrationProfile.graphql | 27 ++ .../pages/admin/event/update/[id]/index.tsx | 1 + .../event/[slug]/register/[quotaId]/index.tsx | 16 +- @app/client/src/pages/settings/profile.tsx | 95 ++++++- @app/client/src/translations/en/events.json | 5 + @app/client/src/translations/en/settings.json | 15 +- @app/client/src/translations/fi/events.json | 5 + @app/client/src/translations/fi/settings.json | 15 +- @app/client/src/translations/se/events.json | 5 + @app/client/src/translations/se/settings.json | 15 +- .../components/src/EventForm/QuestionsTab.tsx | 31 +- @app/components/src/EventForm/index.tsx | 1 + .../functions/update_event_questions.test.ts | 4 +- .../tables/registration_profiles.test.ts | 189 ++++++++++++ .../current/3-registration-prefill.sql | 268 ++++++++++++++++++ ...5eb51525232e5c040e1bc6ff8c1d5afa67.graphql | 17 ++ ...41a41f6d727ed35ca47e5d8a6c0002ce7e.graphql | 16 ++ ...cbe27a2a83fc6fa0a53d1fb53ad5b4973.graphql} | 1 + ...2e78b9cc86d4ae3993de80d9edfc3b2f8.graphql} | 15 + ...34a6cf40668c64c5288abb2ff39df1742.graphql} | 1 + ...dd7d32b3db48a73e81ec243258fd03919.graphql} | 1 + @app/graphql/client.json | 10 +- @app/graphql/server.json | 10 +- @app/server/postgraphile.tags.jsonc | 15 + data/schema.graphql | 100 +++++++ 27 files changed, 859 insertions(+), 26 deletions(-) create mode 100644 @app/client/src/graphql/user/RegistrationProfile.graphql create mode 100644 @app/db/__tests__/app_public/tables/registration_profiles.test.ts create mode 100644 @app/db/migrations/current/3-registration-prefill.sql create mode 100644 @app/graphql/.persisted_operations/1ffa1660f37a5697a34847cd779d385eb51525232e5c040e1bc6ff8c1d5afa67.graphql create mode 100644 @app/graphql/.persisted_operations/40299daf2530066a9fdf98480092ba41a41f6d727ed35ca47e5d8a6c0002ce7e.graphql rename @app/graphql/.persisted_operations/{2e4a7c74a71603bcec3debb7b11c003a481d28d6b25b130694e38f2760fcf7e9.graphql => 5e9f8cc96c5851df4eb697ba11ce834cbe27a2a83fc6fa0a53d1fb53ad5b4973.graphql} (99%) rename @app/graphql/.persisted_operations/{c80a1b7e4a79510cd8e544910e72dec734223574011e0a40bb00c78de8de310c.graphql => b938671bb3cd84f6a88ed440cf92c122e78b9cc86d4ae3993de80d9edfc3b2f8.graphql} (92%) rename @app/graphql/.persisted_operations/{7e487496b03e301f627d86bce4edd2273740b18548ad91c12bd6575aaff34ad7.graphql => c6c7c4ab71074bc63623a493b6d5a0c34a6cf40668c64c5288abb2ff39df1742.graphql} (99%) rename @app/graphql/.persisted_operations/{1583d624d064d3c3b0fc46fd55d971815a7a669d38c8f20fe06b2049fe048744.graphql => f0fee36c5d3237a65c097b307be21b3dd7d32b3db48a73e81ec243258fd03919.graphql} (99%) diff --git a/@app/client/src/graphql/event/EventPage_Subscription.graphql b/@app/client/src/graphql/event/EventPage_Subscription.graphql index c4e2ad9da..c07901b60 100644 --- a/@app/client/src/graphql/event/EventPage_Subscription.graphql +++ b/@app/client/src/graphql/event/EventPage_Subscription.graphql @@ -64,6 +64,7 @@ fragment EventPage_Question on EventQuestion { label isRequired data + prefill } fragment EventPage_Event on Event { diff --git a/@app/client/src/graphql/register/CreateEventRegistrationPage_Query.graphql b/@app/client/src/graphql/register/CreateEventRegistrationPage_Query.graphql index 48cfcb2aa..27fc5ffa5 100644 --- a/@app/client/src/graphql/register/CreateEventRegistrationPage_Query.graphql +++ b/@app/client/src/graphql/register/CreateEventRegistrationPage_Query.graphql @@ -1,5 +1,11 @@ fragment CreateEventRegistrationPage_Query on Query { ...SharedLayout_Query + currentUser { + id + registrationProfile { + ...RegistrationProfile + } + } eventBySlug(slug: $slug) { ...EventPage_Event } diff --git a/@app/client/src/graphql/user/RegistrationProfile.graphql b/@app/client/src/graphql/user/RegistrationProfile.graphql new file mode 100644 index 000000000..80aab7d2a --- /dev/null +++ b/@app/client/src/graphql/user/RegistrationProfile.graphql @@ -0,0 +1,27 @@ +fragment RegistrationProfile on RegistrationProfile { + userId + telegram + dietaryRestrictions +} + +query RegistrationProfile { + currentUser { + id + registrationProfile { + ...RegistrationProfile + } + } +} + +mutation SetRegistrationProfile( + $telegram: String! + $dietaryRestrictions: String! +) { + setRegistrationProfile( + input: { telegram: $telegram, dietaryRestrictions: $dietaryRestrictions } + ) { + registrationProfile { + ...RegistrationProfile + } + } +} diff --git a/@app/client/src/pages/admin/event/update/[id]/index.tsx b/@app/client/src/pages/admin/event/update/[id]/index.tsx index ce1be1708..2bd1a873d 100644 --- a/@app/client/src/pages/admin/event/update/[id]/index.tsx +++ b/@app/client/src/pages/admin/event/update/[id]/index.tsx @@ -83,6 +83,7 @@ function constructInitialValues(values: any) { "label", "isRequired", "data", + "prefill", ]) ) const languages = Object.keys(name || {}) diff --git a/@app/client/src/pages/event/[slug]/register/[quotaId]/index.tsx b/@app/client/src/pages/event/[slug]/register/[quotaId]/index.tsx index 47ebd8ff1..a25d44558 100644 --- a/@app/client/src/pages/event/[slug]/register/[quotaId]/index.tsx +++ b/@app/client/src/pages/event/[slug]/register/[quotaId]/index.tsx @@ -9,6 +9,7 @@ import { useTranslation, } from "@app/components" import { + QuestionPrefill, useCreateEventRegistrationPageQuery, useDeleteEventRegistrationMutation, } from "@app/graphql" @@ -35,15 +36,28 @@ const EventRegistrationPage: NextPage = () => { const quota = data?.quota const { signupClosed, signupUpcoming } = event || {} - const { name, primaryEmail } = currentUser || {} + const { name, primaryEmail, registrationProfile } = currentUser || {} // TODO: The users table schema could be changed to include first // and last names. For now infer first and last name like this... const [firstName, lastName] = name ? name.split(" ") : [] + // Answers to questions marked for prefill come from the registration profile + const prefillValues = { + [QuestionPrefill.Telegram]: registrationProfile?.telegram, + [QuestionPrefill.DietaryRestrictions]: + registrationProfile?.dietaryRestrictions, + } + const answers = Object.fromEntries( + (event?.eventQuestions?.nodes || []) + .filter((q) => q.prefill && prefillValues[q.prefill]) + .map((q) => [q.id, prefillValues[q.prefill]]) + ) + const formInitialValues = { firstName, lastName, email: primaryEmail, + answers, } const [, deleteRegistration] = useDeleteEventRegistrationMutation() diff --git a/@app/client/src/pages/settings/profile.tsx b/@app/client/src/pages/settings/profile.tsx index e06c0408d..6fc5b943f 100644 --- a/@app/client/src/pages/settings/profile.tsx +++ b/@app/client/src/pages/settings/profile.tsx @@ -8,11 +8,13 @@ import { } from "@app/components" import { SharedLayout_UserFragment, + useRegistrationProfileQuery, + useSetRegistrationProfileMutation, useSharedQuery, useUpdateUserMutation, } from "@app/graphql" import { formItemLayout, getCodeFromError, tailFormItemLayout } from "@app/lib" -import { Alert, Button, Form, Input } from "antd" +import { Alert, Button, Form, Input, Typography } from "antd" import type { NextPage } from "next" @@ -24,7 +26,10 @@ const Settings_Profile: NextPage = () => { return ( {data?.currentUser ? ( - + <> + + + ) : fetching ? ( t("common:loading") ) : error ? ( @@ -131,3 +136,89 @@ function ProfileSettingsForm({ user }: ProfileSettingsFormProps) { ) } + +function RegistrationProfileForm() { + const { t } = useTranslation("settings") + const [query] = useRegistrationProfileQuery() + const [{ error }, setRegistrationProfile] = + useSetRegistrationProfileMutation() + const [success, setSuccess] = useState(false) + + const handleSubmit = useCallback( + async (values) => { + setSuccess(false) + const { error } = await setRegistrationProfile({ + telegram: values.telegram ?? "", + dietaryRestrictions: values.dietaryRestrictions ?? "", + }) + if (!error) setSuccess(true) + }, + [setRegistrationProfile] + ) + + if (query.fetching && !query.data) return <>{t("common:loading")} + if (query.error) return + + const { telegram, dietaryRestrictions } = + query.data?.currentUser?.registrationProfile || {} + + return ( +
+ + + {t("registrationProfile.description")} + +
+ + + + + + + {error ? ( + + + + ) : success ? ( + + + + ) : null} + + + +
+
+ ) +} diff --git a/@app/client/src/translations/en/events.json b/@app/client/src/translations/en/events.json index 89617606a..46598243a 100644 --- a/@app/client/src/translations/en/events.json +++ b/@app/client/src/translations/en/events.json @@ -36,6 +36,7 @@ "questions": { "data": "Question", "label": "Label", + "prefill": "Prefill", "type": "Type" }, "quota": { @@ -79,6 +80,10 @@ "numRegistrations": "Registered people", "openQuota": "Open quota", "organizer": "Organizer", + "prefill": { + "DIETARY_RESTRICTIONS": "Dietary restrictions", + "TELEGRAM": "Telegram" + }, "queued": "Queue", "quota": "Quota", "removeOption": "Remove option", diff --git a/@app/client/src/translations/en/settings.json b/@app/client/src/translations/en/settings.json index 0ec27d743..e059af59d 100644 --- a/@app/client/src/translations/en/settings.json +++ b/@app/client/src/translations/en/settings.json @@ -6,12 +6,14 @@ "resetPassphrase": "Reset passphrase", "returnHome": "Return to homepage", "updateProfile": "Update profile", + "updateRegistrationProfile": "Update registration details", "wantToDeleteAccount": "I want to delete my account" }, "errors": { "accountDeleteFailedOrgOwner1": "You cannot delete your account whilst you are the owner of an organization.", "accountDeleteFailedOrgOwner2": "For each organization you are the owner of, please either assign your ownership to another user or delete the organization to continue.", "deleteFailed": "Requesting deletion failed", + "errorUpdatingRegistrationProfile": "Updating registration details failed", "errorUpdatingUsername": "Error updating username", "incorrectOldPassword": "Incorrect old passphrase", "usernameTaken": "This username is already in use, please pick a different name" @@ -22,18 +24,23 @@ "emailAddFailed": "Error adding email", "passwordChangeFailed": "Changing passphrase failed", "passwordChanged": "Password changed!", - "profileUpdated": "Profile updated" + "profileUpdated": "Profile updated", + "registrationProfileUpdated": "Registration details updated" }, "label": { + "dietaryRestrictions": "Dietary restrictions", "newEmail": "New email", "newPassphrase": "New passphrase", - "oldPassphrase": "Old passphrase" + "oldPassphrase": "Old passphrase", + "telegram": "Telegram" }, "messages": { + "dietaryRestrictionsTooLong": "Dietary restrictions can be at most 1000 characters", "email": "Please enter an email address", "name": "Please enter your name", "newPassword": "Please confirm your passphrase", "oldPassword": "Please input your passphrase", + "telegramTooLong": "Telegram can be at most 64 characters", "username": "Please choose a username" } }, @@ -84,11 +91,15 @@ "socialLoginNoPassword": "You registered your account through social login, so you do not currently have a passphrase. If you would like a passphrase, press the button below to request a passphrase reset email to '{{email}}' (you can choose a different email by making it primary in)" } }, + "registrationProfile": { + "description": "These details prefill the Telegram and dietary restriction questions in registration forms. Only you can see them, and they are updated when you register to an event." + }, "titles": { "accounts": "Linked accounts", "delete": "Delete account", "emails": "Email addresses", "index": "Edit profile", + "registrationProfile": "Registration details", "security": "Change passphrase" } } diff --git a/@app/client/src/translations/fi/events.json b/@app/client/src/translations/fi/events.json index d0f131eeb..282d3848b 100644 --- a/@app/client/src/translations/fi/events.json +++ b/@app/client/src/translations/fi/events.json @@ -36,6 +36,7 @@ "questions": { "data": "Kysymys", "label": "Otsikko", + "prefill": "Esitäyttö", "type": "Tyyppi" }, "quota": { @@ -79,6 +80,10 @@ "numRegistrations": "Ilmoittautuneita", "openQuota": "Avoin kiintiö", "organizer": "Järjestäjä", + "prefill": { + "DIETARY_RESTRICTIONS": "Erityisruokavaliot", + "TELEGRAM": "Telegram" + }, "queued": "Jonossa", "quota": "Kiintiö", "removeOption": "Poista vaihtoehto", diff --git a/@app/client/src/translations/fi/settings.json b/@app/client/src/translations/fi/settings.json index e22c81d7a..9a8ebeecc 100644 --- a/@app/client/src/translations/fi/settings.json +++ b/@app/client/src/translations/fi/settings.json @@ -6,12 +6,14 @@ "resetPassphrase": "Resetoi salasana", "returnHome": "Palaa etusivulle", "updateProfile": "Päivitä tiedot", + "updateRegistrationProfile": "Päivitä ilmoittautumistiedot", "wantToDeleteAccount": "Haluan poistaa käyttäjäni" }, "errors": { "accountDeleteFailedOrgOwner1": "Et voi poistaa tiliäsi, kun olet organisaation omistaja.", "accountDeleteFailedOrgOwner2": "Määritä omistajuutesi toiselle käyttäjälle tai poista organisaatio jokaisen omistamasi organisaation kohdalla.", "deleteFailed": "Poistopyyntö epäonnistui", + "errorUpdatingRegistrationProfile": "Ilmoittautumistietojen päivittäminen epäonnistui", "errorUpdatingUsername": "Virhe päivitettäesssä käyttäjänimeä", "incorrectOldPassword": "Väärä vanha salasana", "usernameTaken": "Tämä käyttäjänimi on jo käytössä, valitse toinen käyttäjänimi" @@ -22,18 +24,23 @@ "emailAddFailed": "Virhe lisättäessä sähköpostia", "passwordChangeFailed": "Salasanan vaihtaminen epäonnistui", "passwordChanged": "Salasana vaihdettu!", - "profileUpdated": "Profiili päivitetty" + "profileUpdated": "Profiili päivitetty", + "registrationProfileUpdated": "Ilmoittautumistiedot päivitetty" }, "label": { + "dietaryRestrictions": "Erityisruokavaliot", "newEmail": "Uusi sähköpostil", "newPassphrase": "Uusi salasana", - "oldPassphrase": "Vanha salasana" + "oldPassphrase": "Vanha salasana", + "telegram": "Telegram" }, "messages": { + "dietaryRestrictionsTooLong": "Erityisruokavaliot saavat olla enintään 1000 merkkiä", "email": "Kirjoita sähköpostiosoite", "name": "Kirjoita nimesi", "newPassword": "Vahvista tunnuslause", "oldPassword": "Kirjoita salasana", + "telegramTooLong": "Telegram saa olla enintään 64 merkkiä", "username": "Valitse käyttäjätunnus" } }, @@ -84,11 +91,15 @@ "socialLoginNoPassword": "Rekisteröit tilisi sosiaalisen kirjautumisen kautta, joten sinulla ei ole tällä hetkellä salasanaa. Jos haluat tunnuslauseen, paina alla olevaa painiketta ja pyydä salasanan vaihtosähköposti osoitteeseen {{email}} (voit valita toisen sähköpostin asettamalla sen ensisijaiseksi" } }, + "registrationProfile": { + "description": "Näillä tiedoilla esitäytetään ilmoittautumislomakkeen telegram- ja erityisruokavaliokysymykset. Tiedot näkyvät vain sinulle, ja ne päivittyvät, kun ilmoittaudut tapahtumaan." + }, "titles": { "accounts": "Linkitetyt tilit", "delete": "Poista käyttäjä", "emails": "Sähköpostiosoitteet", "index": "Muokkaa tiliä", + "registrationProfile": "Ilmoittautumistiedot", "security": "Vaihda salasana" } } diff --git a/@app/client/src/translations/se/events.json b/@app/client/src/translations/se/events.json index d30ac729a..eae6ab745 100644 --- a/@app/client/src/translations/se/events.json +++ b/@app/client/src/translations/se/events.json @@ -36,6 +36,7 @@ "questions": { "data": "Fråga", "label": "Etikett", + "prefill": "Förifyllning", "type": "Typ" }, "quota": { @@ -79,6 +80,10 @@ "numRegistrations": "Registrerade personer", "openQuota": "Öppen kvot", "organizer": "Arrangör", + "prefill": { + "DIETARY_RESTRICTIONS": "Specialdieter", + "TELEGRAM": "Telegram" + }, "queued": "Kö", "quota": "Kvota", "removeOption": "Ta bort alternativ", diff --git a/@app/client/src/translations/se/settings.json b/@app/client/src/translations/se/settings.json index 82a9ff7fc..f45da5cee 100644 --- a/@app/client/src/translations/se/settings.json +++ b/@app/client/src/translations/se/settings.json @@ -6,12 +6,14 @@ "resetPassphrase": "Återställ lösenfras", "returnHome": "Återgå till hemsidan", "updateProfile": "Uppdatera profil", + "updateRegistrationProfile": "Uppdatera anmälningsuppgifter", "wantToDeleteAccount": "Jag vill ta bort mitt konto" }, "errors": { "accountDeleteFailedOrgOwner1": "Du kan inte ta bort ditt konto medan du är ägare till en organisation.", "accountDeleteFailedOrgOwner2": "För varje organisation du är ägare till, tilldela antingen ditt ägande till en annan användare eller ta bort organisationen för att fortsätta.", "deleteFailed": "Begäran om borttagning misslyckades", + "errorUpdatingRegistrationProfile": "Det gick inte att uppdatera anmälningsuppgifterna", "errorUpdatingUsername": "Fel vid uppdatering av användarnamn", "incorrectOldPassword": "Felaktig gammal lösenordsfras", "usernameTaken": "Detta användarnamn används redan, välj ett annat namn" @@ -22,18 +24,23 @@ "emailAddFailed": "Fel vid tillägg av e-post", "passwordChangeFailed": "Det gick inte att ändra lösenordsfras", "passwordChanged": "Lösenordet ändrat!", - "profileUpdated": "Profil uppdaterad" + "profileUpdated": "Profil uppdaterad", + "registrationProfileUpdated": "Anmälningsuppgifterna har uppdaterats" }, "label": { + "dietaryRestrictions": "Specialdieter", "newEmail": "Ny e-post", "newPassphrase": "Ny lösenordsfras", - "oldPassphrase": "Gammal lösenfras" + "oldPassphrase": "Gammal lösenfras", + "telegram": "Telegram" }, "messages": { + "dietaryRestrictionsTooLong": "Specialdieter får vara högst 1000 tecken", "email": "Ange en e-postadress", "name": "Ange ditt namn", "newPassword": "Bekräfta din lösenfras", "oldPassword": "Ange din lösenfras", + "telegramTooLong": "Telegram får vara högst 64 tecken", "username": "Välj ett användarnamn" } }, @@ -84,11 +91,15 @@ "socialLoginNoPassword": "Du registrerade ditt konto genom social inloggning, så du har för närvarande ingen lösenfras. Om du vill ha en lösenfras, tryck på knappen nedan för att begära ett e-postmeddelande för återställning av lösenfras till '{{email}}' (du kan välj en annan e-postadress genom att göra den till primär i)" } }, + "registrationProfile": { + "description": "Dessa uppgifter förifyller frågorna om Telegram och specialdieter i anmälningsformulär. Endast du kan se dem, och de uppdateras när du anmäler dig till ett evenemang." + }, "titles": { "accounts": "Länkade konton", "delete": "Radera konto", "emails": "E-postadresser", "index": "Redigera profil", + "registrationProfile": "Anmälningsuppgifter", "security": "Ändra lösenfras" } } diff --git a/@app/components/src/EventForm/QuestionsTab.tsx b/@app/components/src/EventForm/QuestionsTab.tsx index 44e33658f..22abe9ca3 100644 --- a/@app/components/src/EventForm/QuestionsTab.tsx +++ b/@app/components/src/EventForm/QuestionsTab.tsx @@ -8,7 +8,7 @@ import { PlusCircleTwoTone, PlusOutlined, } from "@ant-design/icons" -import { QuestionType } from "@app/graphql" +import { QuestionPrefill, QuestionType } from "@app/graphql" import { arePropsEqual } from "@app/lib" import { Button, @@ -40,6 +40,7 @@ type QuestionData = { label: string isRequired: boolean data: string[] + prefill?: QuestionPrefill | null } interface QuestionsTabProps { @@ -71,16 +72,18 @@ export const QuestionsTab: React.FC = memo( questions, }) } else if (val === "RADIO" || val === "CHECKBOX") { - // If the type was changed to RADIO or CHECKBOX, set initial data + // If the type was changed to RADIO or CHECKBOX, set initial data. + // Only TEXT answers can be prefilled. let questions = getFieldValue("questions") const hasData = !!questions[index].data if (!hasData) { questions[index].data = [""] - setFieldsValue({ - questions, - }) } + questions[index].prefill = null + setFieldsValue({ + questions, + }) } forceUpdate() } @@ -195,8 +198,22 @@ export const QuestionsTab: React.FC = memo( <> {questionLabel} - {/* TEXT questions don't have any data associated with them. - This Col is included for layout. */} + {/* TEXT questions don't have any data associated with them, + but their answer can be prefilled from the registration profile */} + + + ) diff --git a/@app/components/src/EventForm/index.tsx b/@app/components/src/EventForm/index.tsx index 5cb3f92ad..34b14f40d 100644 --- a/@app/components/src/EventForm/index.tsx +++ b/@app/components/src/EventForm/index.tsx @@ -195,6 +195,7 @@ export const EventForm: React.FC = (props) => { "label", "isRequired", "data", + "prefill", ]) } ) diff --git a/@app/db/__tests__/app_public/functions/update_event_questions.test.ts b/@app/db/__tests__/app_public/functions/update_event_questions.test.ts index 343306706..db9ca3381 100644 --- a/@app/db/__tests__/app_public/functions/update_event_questions.test.ts +++ b/@app/db/__tests__/app_public/functions/update_event_questions.test.ts @@ -36,8 +36,8 @@ describe("Test app_public.update_event_questions function", () => { `select app_public.update_event_questions( $1, array[ - row($2::uuid, 0::smallint, 'TEXT'::app_public.question_type, $3::app_public.translated_field, false, null), - row(null, 1::smallint, 'TEXT'::app_public.question_type, $4::app_public.translated_field, false, null) + row($2::uuid, 0::smallint, 'TEXT'::app_public.question_type, $3::app_public.translated_field, false, null, null), + row(null, 1::smallint, 'TEXT'::app_public.question_type, $4::app_public.translated_field, false, null, null) ]::app_public.update_event_questions[] )`, [ diff --git a/@app/db/__tests__/app_public/tables/registration_profiles.test.ts b/@app/db/__tests__/app_public/tables/registration_profiles.test.ts new file mode 100644 index 000000000..a736d6c3e --- /dev/null +++ b/@app/db/__tests__/app_public/tables/registration_profiles.test.ts @@ -0,0 +1,189 @@ +import { PoolClient } from "pg" + +import { + becomeRoot, + becomeUser, + createEventCategories, + createEvents, + createOrganizations, + createQuestions, + createQuotas, + createUsers, + withAnonymousDb, + withRootDb, + withUserDb, +} from "../../helpers" + +async function setRegistrationProfile( + client: PoolClient, + telegram: string, + dietaryRestrictions: string +) { + const { + rows: [profile], + } = await client.query( + `select * from app_public.set_registration_profile($1, $2)`, + [telegram, dietaryRestrictions] + ) + return profile +} + +/** + * Creates an open event whose two TEXT questions are marked to be prefilled + * with the telegram handle and dietary restrictions, and an unfinished + * registration to it, the way claim_registration_token leaves one. + */ +async function setupRegistration(client: PoolClient, email: string) { + await becomeRoot(client) + const [organization] = await createOrganizations(client, 1) + const [eventCategory] = await createEventCategories( + client, + 1, + organization.id + ) + const [event] = await createEvents( + client, + 1, + organization.id, + eventCategory.id + ) + const [quota] = await createQuotas(client, 1, event.id) + const [telegramQuestion, dietaryQuestion] = await createQuestions( + client, + 2, + event.id, + false, + "TEXT" as any + ) + await client.query( + `update app_public.event_questions set prefill = 'TELEGRAM' where id = $1`, + [telegramQuestion.id] + ) + await client.query( + `update app_public.event_questions set prefill = 'DIETARY_RESTRICTIONS' where id = $1`, + [dietaryQuestion.id] + ) + const { + rows: [registration], + } = await client.query( + `insert into app_public.registrations(event_id, quota_id, first_name, last_name, email) + values ($1, $2, 'Testi', 'Testaaja', $3) + returning *`, + [event.id, quota.id, email] + ) + return { registration, telegramQuestion, dietaryQuestion } +} + +// The registration is finished by create_registration, a security definer +// function, so the update runs as root with the user's session still set. +async function finishRegistration( + client: PoolClient, + registrationId: string, + answers: Record +) { + await becomeRoot(client) + await client.query( + `update app_public.registrations set answers = $2, is_finished = true where id = $1`, + [registrationId, answers] + ) +} + +async function getProfile(client: PoolClient, userId: string) { + await becomeRoot(client) + const { + rows: [profile], + } = await client.query( + `select * from app_public.registration_profiles where user_id = $1`, + [userId] + ) + return profile +} + +describe("app_public.registration_profiles", () => { + it("can set and update own registration profile", () => + withUserDb(async (client, user) => { + const created = await setRegistrationProfile(client, "@testi", "Vegaani") + expect(created).toMatchObject({ + user_id: user.id, + telegram: "@testi", + dietary_restrictions: "Vegaani", + }) + + // Empty values are stored as null + const updated = await setRegistrationProfile(client, " @uusi ", "") + expect(updated).toMatchObject({ + user_id: user.id, + telegram: "@uusi", + dietary_restrictions: null, + }) + })) + + it("cannot see another user's registration profile", () => + withRootDb(async (client) => { + const [user, otherUser] = await createUsers(client, 2) + await becomeUser(client, user.id) + await setRegistrationProfile(client, "@testi", "Gluteeniton") + + await becomeUser(client, otherUser.id) + const { rows } = await client.query( + `select * from app_public.registration_profiles` + ) + expect(rows).toHaveLength(0) + })) + + it("cannot set a registration profile when logged out", () => + withAnonymousDb(async (client) => { + const promise = setRegistrationProfile(client, "@testi", "Vegaani") + await expect(promise).rejects.toMatchObject({ code: "LOGIN" }) + })) + + it("saves prefill answers when the user finishes their registration", () => + withUserDb(async (client, user) => { + const { registration, telegramQuestion, dietaryQuestion } = + await setupRegistration(client, user._email) + + await becomeUser(client, user.id) + await finishRegistration(client, registration.id, { + [telegramQuestion.id]: "@testi", + [dietaryQuestion.id]: "Laktoositon", + }) + + expect(await getProfile(client, user.id)).toMatchObject({ + telegram: "@testi", + dietary_restrictions: "Laktoositon", + }) + })) + + it("keeps saved values that a registration leaves unanswered", () => + withUserDb(async (client, user) => { + await setRegistrationProfile(client, "@vanha", "Vegaani") + const { registration, telegramQuestion } = await setupRegistration( + client, + user._email + ) + + await becomeUser(client, user.id) + await finishRegistration(client, registration.id, { + [telegramQuestion.id]: "@uusi", + }) + + expect(await getProfile(client, user.id)).toMatchObject({ + telegram: "@uusi", + dietary_restrictions: "Vegaani", + }) + })) + + it("does not save answers of a registration made for someone else", () => + withUserDb(async (client, user) => { + const { registration, telegramQuestion, dietaryQuestion } = + await setupRegistration(client, "kaveri@example.com") + + await becomeUser(client, user.id) + await finishRegistration(client, registration.id, { + [telegramQuestion.id]: "@kaveri", + [dietaryQuestion.id]: "Pähkinäallergia", + }) + + expect(await getProfile(client, user.id)).toBeUndefined() + })) +}) diff --git a/@app/db/migrations/current/3-registration-prefill.sql b/@app/db/migrations/current/3-registration-prefill.sql new file mode 100644 index 000000000..a5fa17063 --- /dev/null +++ b/@app/db/migrations/current/3-registration-prefill.sql @@ -0,0 +1,268 @@ +/* + * Registration prefill. The registration form prefills the registrant's name + * and email from their account. Telegram handles and dietary restrictions are + * asked with ordinary event questions, so an admin marks which question asks + * which (`event_questions.prefill`), and the answer is prefilled from the + * user's registration profile. + */ + +do $$ +begin + create type app_public.question_prefill as enum ( + 'TELEGRAM', + 'DIETARY_RESTRICTIONS' + ); +exception when duplicate_object then null; +end +$$; + +alter table app_public.event_questions + add column if not exists prefill app_public.question_prefill; + +-- The registration profile stores free text, which only fits a TEXT answer +alter table app_public.event_questions + drop constraint if exists _cnstr_prefill_text_only; +alter table app_public.event_questions + add constraint _cnstr_prefill_text_only check(prefill is null or type = 'TEXT'); + +comment on column app_public.event_questions.prefill is + E'Which registration profile field prefills the answer to this question, if any.'; + +grant + insert (prefill), + update (prefill) +on app_public.event_questions to :DATABASE_VISITOR; + +-- Input types for app_public.create_event_questions and +-- app_public.update_event_questions +do $$ +begin + alter type app_public.create_event_questions add attribute prefill app_public.question_prefill; +exception when duplicate_column then null; +end +$$; + +do $$ +begin + alter type app_public.update_event_questions add attribute prefill app_public.question_prefill; +exception when duplicate_column then null; +end +$$; + +create or replace function app_public.create_event_questions( + event_id uuid, + questions app_public.create_event_questions[] +) +returns app_public.event_questions[] as $$ +declare + v_input app_public.create_event_questions; + v_question app_public.event_questions; + v_ret app_public.event_questions[] default '{}'; +begin + -- Check permissions + call app_public.check_is_admin(); + + if questions is null then + return null; + end if; + + -- Create questions + foreach v_input in array questions loop + insert into app_public.event_questions(event_id, position, type, label, is_required, data, prefill) + values (event_id, v_input.position, v_input.type, v_input.label, v_input.is_required, v_input.data, v_input.prefill) + returning * into v_question; + + v_ret := array_append(v_ret, v_question); + end loop; + + return v_ret; +end; +$$ language plpgsql volatile security invoker set search_path = pg_catalog, public, pg_temp; + +create or replace function app_public.update_event_questions( + event_id uuid, + questions app_public.update_event_questions[] +) +returns app_public.event_questions[] as $$ +#variable_conflict use_variable +declare + v_question_ids_to_delete uuid[]; + v_input app_public.update_event_questions; + v_question app_public.event_questions; + v_ret app_public.event_questions[] default '{}'; +begin + -- Check permissions + call app_public.check_is_admin(); + + select array( + select id from app_public.event_questions as q + where q.event_id = event_id + and q.id not in (select id from unnest(questions) where id is not null) + ) + into v_question_ids_to_delete; + + -- Delete existing event questions that were not supplied + -- as input to this function + delete from app_public.event_questions as q + where q.id = any(v_question_ids_to_delete); + + foreach v_input in array questions loop + if exists(select 1 from app_public.event_questions where id = v_input.id) then + -- Update existing event questions by id + update app_public.event_questions + set position = v_input.position, type = v_input.type, label = v_input.label, is_required = v_input.is_required, data = v_input.data, prefill = v_input.prefill + where id = v_input.id + returning * into v_question; + else + -- Create new questions that didn't exist before + insert into app_public.event_questions(event_id, position, type, label, is_required, data, prefill) + values (event_id, v_input.position, v_input.type, v_input.label, v_input.is_required, v_input.data, v_input.prefill) + returning * into v_question; + end if; + + v_ret := array_append(v_ret, v_question); + end loop; + + return v_ret; +end; +$$ language plpgsql volatile security invoker set search_path = pg_catalog, public, pg_temp; + +/* + * The registration profile holds the values used to prefill registration + * answers. It is a table of its own rather than columns on app_public.users + * because users are publicly visible, and dietary restrictions are not + * anyone else's business. + */ +create table if not exists app_public.registration_profiles ( + user_id uuid primary key references app_public.users on delete cascade, + telegram text check(length(telegram) <= 64), + dietary_restrictions text check(length(dietary_restrictions) <= 1000), + created_at timestamptz not null default now(), + updated_at timestamptz not null default now() +); +alter table app_public.registration_profiles enable row level security; + +drop trigger if exists _100_timestamps on app_public.registration_profiles; +create trigger _100_timestamps + before insert or update on app_public.registration_profiles for each row + execute procedure app_private.tg__timestamps(); + +comment on table app_public.registration_profiles is + E'Values used to prefill event registration answers. Only visible to the user themselves.'; +comment on column app_public.registration_profiles.user_id is + E'The user this registration profile belongs to.'; +comment on column app_public.registration_profiles.telegram is + E'Telegram handle.'; +comment on column app_public.registration_profiles.dietary_restrictions is + E'Dietary restrictions and allergies.'; + +drop policy if exists select_own on app_public.registration_profiles; +drop policy if exists insert_own on app_public.registration_profiles; +drop policy if exists update_own on app_public.registration_profiles; +drop policy if exists delete_own on app_public.registration_profiles; +create policy select_own on app_public.registration_profiles for select using (user_id = app_public.current_user_id()); +create policy insert_own on app_public.registration_profiles for insert with check (user_id = app_public.current_user_id()); +create policy update_own on app_public.registration_profiles for update using (user_id = app_public.current_user_id()); +create policy delete_own on app_public.registration_profiles for delete using (user_id = app_public.current_user_id()); + +grant + select, + insert (user_id, telegram, dietary_restrictions), + update (telegram, dietary_restrictions), + delete +on app_public.registration_profiles to :DATABASE_VISITOR; + +/* + * Creates or replaces the current user's registration profile. Empty values + * are stored as null. + */ +create or replace function app_public.set_registration_profile( + telegram text, + dietary_restrictions text +) +returns app_public.registration_profiles as $$ +#variable_conflict use_variable +declare + v_user_id uuid := app_public.current_user_id(); + v_profile app_public.registration_profiles; +begin + if v_user_id is null then + raise exception 'You must log in to update your registration profile' using errcode = 'LOGIN'; + end if; + + insert into app_public.registration_profiles(user_id, telegram, dietary_restrictions) + values (v_user_id, nullif(trim(telegram), ''), nullif(trim(dietary_restrictions), '')) + on conflict (user_id) do update + set telegram = excluded.telegram, dietary_restrictions = excluded.dietary_restrictions + returning * into v_profile; + + return v_profile; +end; +$$ language plpgsql volatile security invoker set search_path = pg_catalog, public, pg_temp; +comment on function app_public.set_registration_profile(telegram text, dietary_restrictions text) is + E'Set the values used to prefill your event registrations.'; + +/* + * When a logged in user finishes a registration of their own, the answers to + * prefill questions are saved into their registration profile so that the + * next registration is prefilled with them. A registration made for someone + * else (with an email that isn't the user's) is left alone, and so are empty + * answers: clearing a saved value is done on the settings page. + */ +create or replace function app_private.tg_registrations__save_registration_profile() +returns trigger as $$ +declare + v_user_id uuid := app_public.current_user_id(); + v_telegram text; + v_dietary_restrictions text; +begin + if v_user_id is null or not exists( + select 1 from app_public.user_emails + where user_id = v_user_id and email = NEW.email + ) then + return NEW; + end if; + + select nullif(trim(NEW.answers ->> q.id::text), '') into v_telegram + from app_public.event_questions as q + where q.event_id = NEW.event_id and q.prefill = 'TELEGRAM' + order by q.position + limit 1; + + select nullif(trim(NEW.answers ->> q.id::text), '') into v_dietary_restrictions + from app_public.event_questions as q + where q.event_id = NEW.event_id and q.prefill = 'DIETARY_RESTRICTIONS' + order by q.position + limit 1; + + -- An answer too long for the profile is not saved. Failing the + -- registration over it is not an option. + if length(v_telegram) > 64 then + v_telegram := null; + end if; + if length(v_dietary_restrictions) > 1000 then + v_dietary_restrictions := null; + end if; + + if v_telegram is null and v_dietary_restrictions is null then + return NEW; + end if; + + insert into app_public.registration_profiles(user_id, telegram, dietary_restrictions) + values (v_user_id, v_telegram, v_dietary_restrictions) + on conflict (user_id) do update + set + telegram = coalesce(excluded.telegram, registration_profiles.telegram), + dietary_restrictions = coalesce(excluded.dietary_restrictions, registration_profiles.dietary_restrictions); + + return NEW; +end; +$$ language plpgsql volatile security definer set search_path to pg_catalog, public, pg_temp; +comment on function app_private.tg_registrations__save_registration_profile() is + E'Saves answers to prefill questions into the registering user''s registration profile.'; + +drop trigger if exists _500_save_registration_profile on app_public.registrations; +create trigger _500_save_registration_profile + after update on app_public.registrations + for each row when (NEW.is_finished and not OLD.is_finished) + execute procedure app_private.tg_registrations__save_registration_profile(); diff --git a/@app/graphql/.persisted_operations/1ffa1660f37a5697a34847cd779d385eb51525232e5c040e1bc6ff8c1d5afa67.graphql b/@app/graphql/.persisted_operations/1ffa1660f37a5697a34847cd779d385eb51525232e5c040e1bc6ff8c1d5afa67.graphql new file mode 100644 index 000000000..db82482ab --- /dev/null +++ b/@app/graphql/.persisted_operations/1ffa1660f37a5697a34847cd779d385eb51525232e5c040e1bc6ff8c1d5afa67.graphql @@ -0,0 +1,17 @@ +fragment RegistrationProfile on RegistrationProfile { + userId + telegram + dietaryRestrictions + __typename +} +mutation SetRegistrationProfile($telegram: String!, $dietaryRestrictions: String!) { + setRegistrationProfile( + input: {telegram: $telegram, dietaryRestrictions: $dietaryRestrictions} + ) { + registrationProfile { + ...RegistrationProfile + __typename + } + __typename + } +} \ No newline at end of file diff --git a/@app/graphql/.persisted_operations/40299daf2530066a9fdf98480092ba41a41f6d727ed35ca47e5d8a6c0002ce7e.graphql b/@app/graphql/.persisted_operations/40299daf2530066a9fdf98480092ba41a41f6d727ed35ca47e5d8a6c0002ce7e.graphql new file mode 100644 index 000000000..8bb685bd4 --- /dev/null +++ b/@app/graphql/.persisted_operations/40299daf2530066a9fdf98480092ba41a41f6d727ed35ca47e5d8a6c0002ce7e.graphql @@ -0,0 +1,16 @@ +fragment RegistrationProfile on RegistrationProfile { + userId + telegram + dietaryRestrictions + __typename +} +query RegistrationProfile { + currentUser { + id + registrationProfile { + ...RegistrationProfile + __typename + } + __typename + } +} \ No newline at end of file diff --git a/@app/graphql/.persisted_operations/2e4a7c74a71603bcec3debb7b11c003a481d28d6b25b130694e38f2760fcf7e9.graphql b/@app/graphql/.persisted_operations/5e9f8cc96c5851df4eb697ba11ce834cbe27a2a83fc6fa0a53d1fb53ad5b4973.graphql similarity index 99% rename from @app/graphql/.persisted_operations/2e4a7c74a71603bcec3debb7b11c003a481d28d6b25b130694e38f2760fcf7e9.graphql rename to @app/graphql/.persisted_operations/5e9f8cc96c5851df4eb697ba11ce834cbe27a2a83fc6fa0a53d1fb53ad5b4973.graphql index e2e80db2e..14c8f1814 100644 --- a/@app/graphql/.persisted_operations/2e4a7c74a71603bcec3debb7b11c003a481d28d6b25b130694e38f2760fcf7e9.graphql +++ b/@app/graphql/.persisted_operations/5e9f8cc96c5851df4eb697ba11ce834cbe27a2a83fc6fa0a53d1fb53ad5b4973.graphql @@ -184,6 +184,7 @@ fragment EventPage_Question on EventQuestion { label isRequired data + prefill __typename } query UpdateEventRegistrationPage($updateToken: String!) { diff --git a/@app/graphql/.persisted_operations/c80a1b7e4a79510cd8e544910e72dec734223574011e0a40bb00c78de8de310c.graphql b/@app/graphql/.persisted_operations/b938671bb3cd84f6a88ed440cf92c122e78b9cc86d4ae3993de80d9edfc3b2f8.graphql similarity index 92% rename from @app/graphql/.persisted_operations/c80a1b7e4a79510cd8e544910e72dec734223574011e0a40bb00c78de8de310c.graphql rename to @app/graphql/.persisted_operations/b938671bb3cd84f6a88ed440cf92c122e78b9cc86d4ae3993de80d9edfc3b2f8.graphql index 4f5141897..fb98bb073 100644 --- a/@app/graphql/.persisted_operations/c80a1b7e4a79510cd8e544910e72dec734223574011e0a40bb00c78de8de310c.graphql +++ b/@app/graphql/.persisted_operations/b938671bb3cd84f6a88ed440cf92c122e78b9cc86d4ae3993de80d9edfc3b2f8.graphql @@ -1,5 +1,13 @@ fragment CreateEventRegistrationPage_Query on Query { ...SharedLayout_Query + currentUser { + id + registrationProfile { + ...RegistrationProfile + __typename + } + __typename + } eventBySlug(slug: $slug) { ...EventPage_Event __typename @@ -72,6 +80,12 @@ fragment SharedLayout_Organization on Organization { slug __typename } +fragment RegistrationProfile on RegistrationProfile { + userId + telegram + dietaryRestrictions + __typename +} fragment EventPage_Event on Event { ...EventFields category { @@ -173,6 +187,7 @@ fragment EventPage_Question on EventQuestion { label isRequired data + prefill __typename } query CreateEventRegistrationPage($slug: String!, $quotaId: UUID!) { diff --git a/@app/graphql/.persisted_operations/7e487496b03e301f627d86bce4edd2273740b18548ad91c12bd6575aaff34ad7.graphql b/@app/graphql/.persisted_operations/c6c7c4ab71074bc63623a493b6d5a0c34a6cf40668c64c5288abb2ff39df1742.graphql similarity index 99% rename from @app/graphql/.persisted_operations/7e487496b03e301f627d86bce4edd2273740b18548ad91c12bd6575aaff34ad7.graphql rename to @app/graphql/.persisted_operations/c6c7c4ab71074bc63623a493b6d5a0c34a6cf40668c64c5288abb2ff39df1742.graphql index 273307430..011edadc5 100644 --- a/@app/graphql/.persisted_operations/7e487496b03e301f627d86bce4edd2273740b18548ad91c12bd6575aaff34ad7.graphql +++ b/@app/graphql/.persisted_operations/c6c7c4ab71074bc63623a493b6d5a0c34a6cf40668c64c5288abb2ff39df1742.graphql @@ -161,6 +161,7 @@ fragment EventPage_Question on EventQuestion { label isRequired data + prefill __typename } query UpdateEventPage($id: UUID!) { diff --git a/@app/graphql/.persisted_operations/1583d624d064d3c3b0fc46fd55d971815a7a669d38c8f20fe06b2049fe048744.graphql b/@app/graphql/.persisted_operations/f0fee36c5d3237a65c097b307be21b3dd7d32b3db48a73e81ec243258fd03919.graphql similarity index 99% rename from @app/graphql/.persisted_operations/1583d624d064d3c3b0fc46fd55d971815a7a669d38c8f20fe06b2049fe048744.graphql rename to @app/graphql/.persisted_operations/f0fee36c5d3237a65c097b307be21b3dd7d32b3db48a73e81ec243258fd03919.graphql index 2bee7ad6f..4c32baae0 100644 --- a/@app/graphql/.persisted_operations/1583d624d064d3c3b0fc46fd55d971815a7a669d38c8f20fe06b2049fe048744.graphql +++ b/@app/graphql/.persisted_operations/f0fee36c5d3237a65c097b307be21b3dd7d32b3db48a73e81ec243258fd03919.graphql @@ -150,6 +150,7 @@ fragment EventPage_Question on EventQuestion { label isRequired data + prefill __typename } subscription EventPage($slug: String!) { diff --git a/@app/graphql/client.json b/@app/graphql/client.json index c68ae7607..89ca7452c 100644 --- a/@app/graphql/client.json +++ b/@app/graphql/client.json @@ -12,7 +12,7 @@ "DeleteEvent": "75c86da8b31d18d79c4dcab26bacfffb860b4c7933568ca830731c793f815338", "ListEventsPage": "f03f38c3d71fd696ef382a99987cf83cc85f699074616d593fbd4216e7de1a2f", "TranslateText": "2fd1ef03df33a4dacf0b46162521f2bec22b99971807fb81a205aa5d36a0e59c", - "UpdateEventPage": "7e487496b03e301f627d86bce4edd2273740b18548ad91c12bd6575aaff34ad7", + "UpdateEventPage": "c6c7c4ab71074bc63623a493b6d5a0c34a6cf40668c64c5288abb2ff39df1742", "UpdateEvent": "063ffe79e5b7bcf7d58cc1b0742a2526dfd993ebd5550a37cc5d326b8fd35d00", "InviteToOrganization": "c639d16546c2d6c7133350ef65627885f7e11a1e33ec9ae099d0bb4a9b9af331", "OrganizationBySlug": "7d4e6fe382bf3e0467c9372406e18fd1e63b6aa3f1aea2530a66c60cdfa3da2d", @@ -26,7 +26,7 @@ "AdminDeleteUser": "272d8236ba9669d320fc31b805cbeeb08662b4f7a510392a307694c420e030fd", "AdminListUsers": "9dc8f24c328dc0dc2e150a71047eecfa5bbf8e350f9fa1b3e9bd3abef4a6edc0", "SetAdminStatus": "9622d74eaeb7042221e04a2d63ed26a4e3c673071f7538537d36fdf1f453ba69", - "EventPage": "1583d624d064d3c3b0fc46fd55d971815a7a669d38c8f20fe06b2049fe048744", + "EventPage": "f0fee36c5d3237a65c097b307be21b3dd7d32b3db48a73e81ec243258fd03919", "EventRegistrations": "c22efb8e3e3226153a7be53c61321e72c94f3cbc667ca769cc056b4fee27678c", "HomePageEvents": "368543083e66d7a6ae5e78654849ec0d94283752aece92394005e027bf3e429c", "HomePage": "301da0928db49b18b443128fd731b8815df9fd05a090c4f6e648837bc2436754", @@ -37,10 +37,10 @@ "DeleteOrganization": "39f623b7dd9b3111922c0937f5985ef32d8de76b88898b043daaf53dc20877b2", "InvitationDetail": "3d3ae0471e11f29477713606f9d884cb6d2a031b1a8bed9e220bec4c5e54337f", "ClaimRegistrationToken": "c3c63bf12e25e4025a986f94781d706f7adb2261e91689d356069378faec2c4a", - "CreateEventRegistrationPage": "c80a1b7e4a79510cd8e544910e72dec734223574011e0a40bb00c78de8de310c", + "CreateEventRegistrationPage": "b938671bb3cd84f6a88ed440cf92c122e78b9cc86d4ae3993de80d9edfc3b2f8", "CreateEventRegistration": "e97c6726ce1d78c512935a15f46e8315e8ab2e50b2776d4fa1c92a5e8a54c566", "DeleteEventRegistration": "be0f72e306dcf5e22dbaa962b5228422a5a0bd12dc68d688ee8b9a28b479318b", - "UpdateEventRegistrationPage": "2e4a7c74a71603bcec3debb7b11c003a481d28d6b25b130694e38f2760fcf7e9", + "UpdateEventRegistrationPage": "5e9f8cc96c5851df4eb697ba11ce834cbe27a2a83fc6fa0a53d1fb53ad5b4973", "UpdateEventRegistration": "a073a90b247942ecbca6dd214aa1b2dcbe42ab30618e881c8a8d90b1c5097739", "AddEmail": "da27b66ae2e115cc90ba53748aaadae32ba97b016e2783550fe847089f7423c2", "ChangePassword": "2532c897bead71cb8b9171c240298a47c4b6b13197886c990ccfcc937356ceab", @@ -53,6 +53,8 @@ "Logout": "953cdfb120682429839e878cb7f9e483d97dff06ed0d4eb80428cb98896c58fd", "MakeEmailPrimary": "585b5baf970ccdcfc9031b3063524111fb24c972b41b6902e0b97c26eed8407d", "PasswordStrength": "bb833917071d149b426642c0a8b641b629532a44f6c2ab3794a625f91e4d862e", + "RegistrationProfile": "40299daf2530066a9fdf98480092ba41a41f6d727ed35ca47e5d8a6c0002ce7e", + "SetRegistrationProfile": "1ffa1660f37a5697a34847cd779d385eb51525232e5c040e1bc6ff8c1d5afa67", "RequestAccountDeletion": "a15c749947f08c4c76e36aaa48042537e7f011318cb0424a67cceb336b8f1f7d", "ResendEmailVerification": "91c3f0e452f0295520ee02ffbb79759b6a96cac6fc9ccaa514ffaa4e1ca8deba", "ResetPassword": "0c6997c5a3b8b971a99c59a3ec6bd05d7fd24ff1aa3d7bbcc8a4bb0808de0ad7", diff --git a/@app/graphql/server.json b/@app/graphql/server.json index ae4556691..d44791ca6 100644 --- a/@app/graphql/server.json +++ b/@app/graphql/server.json @@ -12,7 +12,7 @@ "75c86da8b31d18d79c4dcab26bacfffb860b4c7933568ca830731c793f815338": "mutation DeleteEvent($id: UUID!) {\n deleteEvent(input: {id: $id}) {\n clientMutationId\n __typename\n }\n}", "f03f38c3d71fd696ef382a99987cf83cc85f699074616d593fbd4216e7de1a2f": "fragment ListEventsPage_Query on Query {\n ...SharedLayout_Query\n eventCategories {\n nodes {\n ...EventPage_EventCategory\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_Query on Query {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n organizations(orderBy: SLUG_ASC) {\n nodes {\n ...SharedLayout_Organization\n __typename\n }\n __typename\n }\n ssoLoginEnabled\n supportedLanguages\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment SharedLayout_Organization on Organization {\n id\n name\n slug\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nquery ListEventsPage {\n ...ListEventsPage_Query\n}", "2fd1ef03df33a4dacf0b46162521f2bec22b99971807fb81a205aa5d36a0e59c": "mutation TranslateText($from: SupportedLanguages!, $to: SupportedLanguages!, $text: String!) {\n translateText(fromLanguage: $from, toLanguage: $to, text: $text) {\n originalText\n translatedText\n __typename\n }\n}", - "7e487496b03e301f627d86bce4edd2273740b18548ad91c12bd6575aaff34ad7": "fragment UpdateEventPage_Query on Query {\n ...SharedLayout_Query\n event(id: $id) {\n ...UpdateEventPage_Event\n __typename\n }\n eventCategories(orderBy: NAME_ASC) {\n nodes {\n ...EventPage_EventCategory\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_Query on Query {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n organizations(orderBy: SLUG_ASC) {\n nodes {\n ...SharedLayout_Organization\n __typename\n }\n __typename\n }\n ssoLoginEnabled\n supportedLanguages\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment SharedLayout_Organization on Organization {\n id\n name\n slug\n __typename\n}\nfragment UpdateEventPage_Event on Event {\n ...EventFields\n category {\n ...EventPage_EventCategory\n __typename\n }\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n registrations {\n totalCount\n __typename\n }\n __typename\n }\n __typename\n }\n eventQuestions(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Question\n __typename\n }\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nfragment EventPage_Question on EventQuestion {\n id\n position\n type\n label\n isRequired\n data\n __typename\n}\nquery UpdateEventPage($id: UUID!) {\n ...UpdateEventPage_Query\n}", + "c6c7c4ab71074bc63623a493b6d5a0c34a6cf40668c64c5288abb2ff39df1742": "fragment UpdateEventPage_Query on Query {\n ...SharedLayout_Query\n event(id: $id) {\n ...UpdateEventPage_Event\n __typename\n }\n eventCategories(orderBy: NAME_ASC) {\n nodes {\n ...EventPage_EventCategory\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_Query on Query {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n organizations(orderBy: SLUG_ASC) {\n nodes {\n ...SharedLayout_Organization\n __typename\n }\n __typename\n }\n ssoLoginEnabled\n supportedLanguages\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment SharedLayout_Organization on Organization {\n id\n name\n slug\n __typename\n}\nfragment UpdateEventPage_Event on Event {\n ...EventFields\n category {\n ...EventPage_EventCategory\n __typename\n }\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n registrations {\n totalCount\n __typename\n }\n __typename\n }\n __typename\n }\n eventQuestions(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Question\n __typename\n }\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nfragment EventPage_Question on EventQuestion {\n id\n position\n type\n label\n isRequired\n data\n prefill\n __typename\n}\nquery UpdateEventPage($id: UUID!) {\n ...UpdateEventPage_Query\n}", "063ffe79e5b7bcf7d58cc1b0742a2526dfd993ebd5550a37cc5d326b8fd35d00": "fragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nmutation UpdateEvent($input: UpdateEventInput!) {\n updateEvent(input: $input) {\n event {\n ...EventFields\n __typename\n }\n __typename\n }\n}", "c639d16546c2d6c7133350ef65627885f7e11a1e33ec9ae099d0bb4a9b9af331": "mutation InviteToOrganization($organizationId: UUID!, $email: String, $username: String) {\n inviteToOrganization(\n input: {organizationId: $organizationId, email: $email, username: $username}\n ) {\n clientMutationId\n __typename\n }\n}", "7d4e6fe382bf3e0467c9372406e18fd1e63b6aa3f1aea2530a66c60cdfa3da2d": "query OrganizationBySlug($slug: String!) {\n organizationBySlug(slug: $slug) {\n id\n name\n slug\n __typename\n }\n}", @@ -26,7 +26,7 @@ "272d8236ba9669d320fc31b805cbeeb08662b4f7a510392a307694c420e030fd": "mutation AdminDeleteUser($id: UUID!) {\n adminDeleteUser(input: {id: $id}) {\n success\n __typename\n }\n}", "9dc8f24c328dc0dc2e150a71047eecfa5bbf8e350f9fa1b3e9bd3abef4a6edc0": "fragment AdminListUsers_User on User {\n id\n username\n name\n avatarUrl\n isAdmin\n isVerified\n createdAt\n __typename\n}\nquery AdminListUsers {\n adminListUsers {\n nodes {\n ...AdminListUsers_User\n __typename\n }\n __typename\n }\n}", "9622d74eaeb7042221e04a2d63ed26a4e3c673071f7538537d36fdf1f453ba69": "mutation SetAdminStatus($input: SetAdminStatusInput!) {\n setAdminStatus(input: $input) {\n success\n __typename\n }\n}", - "1583d624d064d3c3b0fc46fd55d971815a7a669d38c8f20fe06b2049fe048744": "fragment EventPage_Subscription on Subscription {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n eventBySlug(slug: $slug) {\n ...EventPage_Event\n __typename\n }\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment EventPage_Event on Event {\n ...EventFields\n category {\n ...EventPage_EventCategory\n __typename\n }\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n __typename\n }\n __typename\n }\n registrations(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Registration\n __typename\n }\n __typename\n }\n eventQuestions(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Question\n __typename\n }\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nfragment EventPage_Registration on Registration {\n id\n fullName\n status\n position\n createdAt\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment EventPage_Question on EventQuestion {\n id\n position\n type\n label\n isRequired\n data\n __typename\n}\nsubscription EventPage($slug: String!) {\n ...EventPage_Subscription\n}", + "f0fee36c5d3237a65c097b307be21b3dd7d32b3db48a73e81ec243258fd03919": "fragment EventPage_Subscription on Subscription {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n eventBySlug(slug: $slug) {\n ...EventPage_Event\n __typename\n }\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment EventPage_Event on Event {\n ...EventFields\n category {\n ...EventPage_EventCategory\n __typename\n }\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n __typename\n }\n __typename\n }\n registrations(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Registration\n __typename\n }\n __typename\n }\n eventQuestions(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Question\n __typename\n }\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nfragment EventPage_Registration on Registration {\n id\n fullName\n status\n position\n createdAt\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment EventPage_Question on EventQuestion {\n id\n position\n type\n label\n isRequired\n data\n prefill\n __typename\n}\nsubscription EventPage($slug: String!) {\n ...EventPage_Subscription\n}", "c22efb8e3e3226153a7be53c61321e72c94f3cbc667ca769cc056b4fee27678c": "fragment EventPage_Registration on Registration {\n id\n fullName\n status\n position\n createdAt\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nsubscription EventRegistrations($eventId: UUID!, $after: Datetime!) {\n eventRegistrations(eventId: $eventId) {\n registrations(after: $after) {\n ...EventPage_Registration\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n }\n __typename\n }\n}", "368543083e66d7a6ae5e78654849ec0d94283752aece92394005e027bf3e429c": "fragment HomePageClosedEvents_Query on Query {\n signupClosedEvents: events(\n first: $first\n offset: $offset\n filter: {signupClosed: {equalTo: true}, name: {containsKey: $language}}\n orderBy: EVENT_END_TIME_DESC\n ) {\n nodes {\n ...HomePage_Event\n __typename\n }\n totalCount\n __typename\n }\n __typename\n}\nfragment HomePage_Event on Event {\n ...EventFields\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n category {\n ...EventPage_EventCategory\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n registrations {\n totalCount\n __typename\n }\n __typename\n }\n __typename\n }\n registrations {\n totalCount\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nquery HomePageEvents($offset: Int, $first: Int, $language: String) {\n ...HomePageClosedEvents_Query\n}", "301da0928db49b18b443128fd731b8815df9fd05a090c4f6e648837bc2436754": "fragment HomePage_Query on Query {\n ...SharedLayout_Query\n signupOpenEvents: events(\n filter: {signupOpen: {equalTo: true}, isDraft: {equalTo: false}, name: {containsKey: $language}}\n orderBy: [IS_HIGHLIGHTED_DESC, REGISTRATION_END_TIME_ASC]\n ) {\n nodes {\n ...HomePage_Event\n __typename\n }\n __typename\n }\n signupUpcomingEvents: events(\n filter: {signupUpcoming: {equalTo: true}, isDraft: {equalTo: false}, name: {containsKey: $language}}\n orderBy: [IS_HIGHLIGHTED_DESC, REGISTRATION_END_TIME_ASC]\n ) {\n nodes {\n ...HomePage_Event\n __typename\n }\n __typename\n }\n eventCategories {\n nodes {\n ...EventPage_EventCategory\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_Query on Query {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n organizations(orderBy: SLUG_ASC) {\n nodes {\n ...SharedLayout_Organization\n __typename\n }\n __typename\n }\n ssoLoginEnabled\n supportedLanguages\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment SharedLayout_Organization on Organization {\n id\n name\n slug\n __typename\n}\nfragment HomePage_Event on Event {\n ...EventFields\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n category {\n ...EventPage_EventCategory\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n registrations {\n totalCount\n __typename\n }\n __typename\n }\n __typename\n }\n registrations {\n totalCount\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nquery HomePage($language: String!) {\n ...HomePage_Query\n}", @@ -37,10 +37,10 @@ "39f623b7dd9b3111922c0937f5985ef32d8de76b88898b043daaf53dc20877b2": "mutation DeleteOrganization($organizationId: UUID!) {\n deleteOrganization(input: {organizationId: $organizationId}) {\n clientMutationId\n __typename\n }\n}", "3d3ae0471e11f29477713606f9d884cb6d2a031b1a8bed9e220bec4c5e54337f": "fragment SharedLayout_Query on Query {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n organizations(orderBy: SLUG_ASC) {\n nodes {\n ...SharedLayout_Organization\n __typename\n }\n __typename\n }\n ssoLoginEnabled\n supportedLanguages\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment SharedLayout_Organization on Organization {\n id\n name\n slug\n __typename\n}\nquery InvitationDetail($id: UUID!, $code: String) {\n ...SharedLayout_Query\n organizationForInvitation(invitationId: $id, code: $code) {\n id\n name\n slug\n __typename\n }\n}", "c3c63bf12e25e4025a986f94781d706f7adb2261e91689d356069378faec2c4a": "mutation ClaimRegistrationToken($input: ClaimRegistrationTokenInput!) {\n claimRegistrationToken(input: $input) {\n claimRegistrationTokenOutput {\n registrationToken\n updateToken\n __typename\n }\n __typename\n }\n}", - "c80a1b7e4a79510cd8e544910e72dec734223574011e0a40bb00c78de8de310c": "fragment CreateEventRegistrationPage_Query on Query {\n ...SharedLayout_Query\n eventBySlug(slug: $slug) {\n ...EventPage_Event\n __typename\n }\n quota(id: $quotaId) {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment SharedLayout_Query on Query {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n organizations(orderBy: SLUG_ASC) {\n nodes {\n ...SharedLayout_Organization\n __typename\n }\n __typename\n }\n ssoLoginEnabled\n supportedLanguages\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment SharedLayout_Organization on Organization {\n id\n name\n slug\n __typename\n}\nfragment EventPage_Event on Event {\n ...EventFields\n category {\n ...EventPage_EventCategory\n __typename\n }\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n __typename\n }\n __typename\n }\n registrations(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Registration\n __typename\n }\n __typename\n }\n eventQuestions(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Question\n __typename\n }\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nfragment EventPage_Registration on Registration {\n id\n fullName\n status\n position\n createdAt\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment EventPage_Question on EventQuestion {\n id\n position\n type\n label\n isRequired\n data\n __typename\n}\nquery CreateEventRegistrationPage($slug: String!, $quotaId: UUID!) {\n ...CreateEventRegistrationPage_Query\n}", + "b938671bb3cd84f6a88ed440cf92c122e78b9cc86d4ae3993de80d9edfc3b2f8": "fragment CreateEventRegistrationPage_Query on Query {\n ...SharedLayout_Query\n currentUser {\n id\n registrationProfile {\n ...RegistrationProfile\n __typename\n }\n __typename\n }\n eventBySlug(slug: $slug) {\n ...EventPage_Event\n __typename\n }\n quota(id: $quotaId) {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment SharedLayout_Query on Query {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n organizations(orderBy: SLUG_ASC) {\n nodes {\n ...SharedLayout_Organization\n __typename\n }\n __typename\n }\n ssoLoginEnabled\n supportedLanguages\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment SharedLayout_Organization on Organization {\n id\n name\n slug\n __typename\n}\nfragment RegistrationProfile on RegistrationProfile {\n userId\n telegram\n dietaryRestrictions\n __typename\n}\nfragment EventPage_Event on Event {\n ...EventFields\n category {\n ...EventPage_EventCategory\n __typename\n }\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n __typename\n }\n __typename\n }\n registrations(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Registration\n __typename\n }\n __typename\n }\n eventQuestions(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Question\n __typename\n }\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nfragment EventPage_Registration on Registration {\n id\n fullName\n status\n position\n createdAt\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment EventPage_Question on EventQuestion {\n id\n position\n type\n label\n isRequired\n data\n prefill\n __typename\n}\nquery CreateEventRegistrationPage($slug: String!, $quotaId: UUID!) {\n ...CreateEventRegistrationPage_Query\n}", "e97c6726ce1d78c512935a15f46e8315e8ab2e50b2776d4fa1c92a5e8a54c566": "fragment EventPage_Registration on Registration {\n id\n fullName\n status\n position\n createdAt\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nmutation CreateEventRegistration($input: CreateRegistrationInput!) {\n createRegistration(input: $input) {\n registration {\n ...EventPage_Registration\n quota {\n ...EventPage_Quota\n __typename\n }\n event {\n id\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n}", "be0f72e306dcf5e22dbaa962b5228422a5a0bd12dc68d688ee8b9a28b479318b": "mutation DeleteEventRegistration($updateToken: String!) {\n deleteRegistration(input: {updateToken: $updateToken}) {\n success\n __typename\n }\n}", - "2e4a7c74a71603bcec3debb7b11c003a481d28d6b25b130694e38f2760fcf7e9": "fragment UpdateEventRegistrationPage_Query on Query {\n ...SharedLayout_Query\n registrationByUpdateToken(updateToken: $updateToken) {\n ...UpdateEventRegistrationPage_Registration\n quota {\n ...EventPage_Quota\n __typename\n }\n event {\n ...EventPage_Event\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_Query on Query {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n organizations(orderBy: SLUG_ASC) {\n nodes {\n ...SharedLayout_Organization\n __typename\n }\n __typename\n }\n ssoLoginEnabled\n supportedLanguages\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment SharedLayout_Organization on Organization {\n id\n name\n slug\n __typename\n}\nfragment UpdateEventRegistrationPage_Registration on Registration {\n id\n firstName\n lastName\n answers\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nfragment EventPage_Event on Event {\n ...EventFields\n category {\n ...EventPage_EventCategory\n __typename\n }\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n __typename\n }\n __typename\n }\n registrations(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Registration\n __typename\n }\n __typename\n }\n eventQuestions(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Question\n __typename\n }\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_Registration on Registration {\n id\n fullName\n status\n position\n createdAt\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment EventPage_Question on EventQuestion {\n id\n position\n type\n label\n isRequired\n data\n __typename\n}\nquery UpdateEventRegistrationPage($updateToken: String!) {\n ...UpdateEventRegistrationPage_Query\n}", + "5e9f8cc96c5851df4eb697ba11ce834cbe27a2a83fc6fa0a53d1fb53ad5b4973": "fragment UpdateEventRegistrationPage_Query on Query {\n ...SharedLayout_Query\n registrationByUpdateToken(updateToken: $updateToken) {\n ...UpdateEventRegistrationPage_Registration\n quota {\n ...EventPage_Quota\n __typename\n }\n event {\n ...EventPage_Event\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_Query on Query {\n currentUser {\n ...SharedLayout_User\n __typename\n }\n organizations(orderBy: SLUG_ASC) {\n nodes {\n ...SharedLayout_Organization\n __typename\n }\n __typename\n }\n ssoLoginEnabled\n supportedLanguages\n __typename\n}\nfragment SharedLayout_User on User {\n id\n name\n username\n avatarUrl\n isAdmin\n isVerified\n primaryEmail\n userEmails(first: 50) {\n nodes {\n ...SharedLayout_UserEmail\n __typename\n }\n __typename\n }\n organizationMemberships(first: 20) {\n totalCount\n nodes {\n id\n isOwner\n organization {\n id\n name\n slug\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nfragment SharedLayout_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nfragment SharedLayout_Organization on Organization {\n id\n name\n slug\n __typename\n}\nfragment UpdateEventRegistrationPage_Registration on Registration {\n id\n firstName\n lastName\n answers\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nfragment EventPage_Event on Event {\n ...EventFields\n category {\n ...EventPage_EventCategory\n __typename\n }\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n quotas(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Quota\n __typename\n }\n __typename\n }\n registrations(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Registration\n __typename\n }\n __typename\n }\n eventQuestions(orderBy: POSITION_ASC) {\n nodes {\n ...EventPage_Question\n __typename\n }\n __typename\n }\n __typename\n}\nfragment EventFields on Event {\n id\n name\n slug\n description\n location\n eventStartTime\n eventEndTime\n registrationStartTime\n registrationEndTime\n isHighlighted\n isDraft\n headerImageFile\n openQuotaSize\n signupOpen\n signupUpcoming\n signupClosed\n createdBy\n updatedBy\n createdAt\n updatedAt\n __typename\n}\nfragment EventPage_EventCategory on EventCategory {\n id\n description\n name\n color\n ownerOrganization {\n ...EventPage_Organization\n __typename\n }\n updatedAt\n __typename\n}\nfragment EventPage_Organization on Organization {\n id\n name\n slug\n color\n __typename\n}\nfragment EventPage_Registration on Registration {\n id\n fullName\n status\n position\n createdAt\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment EventPage_Question on EventQuestion {\n id\n position\n type\n label\n isRequired\n data\n prefill\n __typename\n}\nquery UpdateEventRegistrationPage($updateToken: String!) {\n ...UpdateEventRegistrationPage_Query\n}", "a073a90b247942ecbca6dd214aa1b2dcbe42ab30618e881c8a8d90b1c5097739": "fragment EventPage_Registration on Registration {\n id\n fullName\n status\n position\n createdAt\n quota {\n ...EventPage_Quota\n __typename\n }\n __typename\n}\nfragment EventPage_Quota on Quota {\n id\n position\n title\n size\n __typename\n}\nmutation UpdateEventRegistration($input: UpdateRegistrationInput!) {\n updateRegistration(input: $input) {\n registration {\n ...EventPage_Registration\n firstName\n lastName\n answers\n updatedAt\n __typename\n }\n __typename\n }\n}", "da27b66ae2e115cc90ba53748aaadae32ba97b016e2783550fe847089f7423c2": "fragment EmailsForm_UserEmail on UserEmail {\n id\n email\n isVerified\n isPrimary\n createdAt\n __typename\n}\nmutation AddEmail($email: Email!) {\n createUserEmail(input: {userEmail: {email: $email}}) {\n user {\n id\n userEmails(first: 50) {\n nodes {\n ...EmailsForm_UserEmail\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}", "2532c897bead71cb8b9171c240298a47c4b6b13197886c990ccfcc937356ceab": "mutation ChangePassword($oldPassword: String!, $newPassword: String!) {\n changePassword(input: {oldPassword: $oldPassword, newPassword: $newPassword}) {\n success\n __typename\n }\n}", @@ -53,6 +53,8 @@ "953cdfb120682429839e878cb7f9e483d97dff06ed0d4eb80428cb98896c58fd": "mutation Logout {\n logout {\n success\n redirectTo\n __typename\n }\n}", "585b5baf970ccdcfc9031b3063524111fb24c972b41b6902e0b97c26eed8407d": "mutation MakeEmailPrimary($emailId: UUID!) {\n makeEmailPrimary(input: {emailId: $emailId}) {\n user {\n id\n userEmails(first: 50) {\n nodes {\n id\n isPrimary\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}", "bb833917071d149b426642c0a8b641b629532a44f6c2ab3794a625f91e4d862e": "mutation PasswordStrength($password: String!) {\n calculatePasswordStrength(password: $password) {\n score\n feedback {\n suggestions\n __typename\n }\n __typename\n }\n}", + "40299daf2530066a9fdf98480092ba41a41f6d727ed35ca47e5d8a6c0002ce7e": "fragment RegistrationProfile on RegistrationProfile {\n userId\n telegram\n dietaryRestrictions\n __typename\n}\nquery RegistrationProfile {\n currentUser {\n id\n registrationProfile {\n ...RegistrationProfile\n __typename\n }\n __typename\n }\n}", + "1ffa1660f37a5697a34847cd779d385eb51525232e5c040e1bc6ff8c1d5afa67": "fragment RegistrationProfile on RegistrationProfile {\n userId\n telegram\n dietaryRestrictions\n __typename\n}\nmutation SetRegistrationProfile($telegram: String!, $dietaryRestrictions: String!) {\n setRegistrationProfile(\n input: {telegram: $telegram, dietaryRestrictions: $dietaryRestrictions}\n ) {\n registrationProfile {\n ...RegistrationProfile\n __typename\n }\n __typename\n }\n}", "a15c749947f08c4c76e36aaa48042537e7f011318cb0424a67cceb336b8f1f7d": "mutation RequestAccountDeletion {\n requestAccountDeletion(input: {}) {\n success\n __typename\n }\n}", "91c3f0e452f0295520ee02ffbb79759b6a96cac6fc9ccaa514ffaa4e1ca8deba": "mutation ResendEmailVerification($emailId: UUID!) {\n resendEmailVerificationCode(input: {emailId: $emailId}) {\n success\n __typename\n }\n}", "0c6997c5a3b8b971a99c59a3ec6bd05d7fd24ff1aa3d7bbcc8a4bb0808de0ad7": "mutation ResetPassword($userId: UUID!, $token: String!, $password: String!) {\n resetPassword(\n input: {userId: $userId, resetToken: $token, newPassword: $password}\n ) {\n success\n __typename\n }\n}", diff --git a/@app/server/postgraphile.tags.jsonc b/@app/server/postgraphile.tags.jsonc index 7a2313ec8..dc71ad9db 100644 --- a/@app/server/postgraphile.tags.jsonc +++ b/@app/server/postgraphile.tags.jsonc @@ -147,6 +147,21 @@ "tags": { "omit": "create,update,delete" } + }, + // A registration profile is read through `User.registrationProfile` and + // written with the `setRegistrationProfile` mutation. + "app_public.registration_profiles": { + "tags": { + "omit": "create,update,delete,all" + }, + "constraint": { + // user_id is the primary key, so a user has at most one profile + "registration_profiles_user_id_fkey": { + "tags": { + "omit": "many" + } + } + } } }, "procedure": { diff --git a/data/schema.graphql b/data/schema.graphql index d973bbe26..ecbb3c581 100644 --- a/data/schema.graphql +++ b/data/schema.graphql @@ -309,6 +309,7 @@ input CreateEventQuestionInput { isRequired: Boolean label: TranslatedField position: Int + prefill: QuestionPrefill type: QuestionType } @@ -1221,6 +1222,11 @@ type EventQuestion { """Question position. Used to order question.""" position: Int! + """ + Which registration profile field prefills the answer to this question, if any. + """ + prefill: QuestionPrefill + """Question type (e.g. radio button, text, checkbox).""" type: QuestionType! updatedAt: Datetime! @@ -1796,6 +1802,14 @@ type Mutation { input: SetAdminStatusInput! ): SetAdminStatusPayload + """Set the values used to prefill your event registrations.""" + setRegistrationProfile( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: SetRegistrationProfileInput! + ): SetRegistrationProfilePayload + """ The owner of an `Organization` may use this mutation to transfer ownership to a different organization member. Take care, if you assign ownership to someone who cannot or will not access their account then you may need to contact support to have ownership reassigned. """ @@ -2443,6 +2457,7 @@ type Query { """Get registration by update token.""" registrationByUpdateToken(updateToken: String!): Registration + registrationProfile(userId: UUID!): RegistrationProfile """Reads and enables pagination through a set of `Registration`.""" registrations( @@ -2496,6 +2511,11 @@ type Query { userEmail(id: UUID!): UserEmail } +enum QuestionPrefill { + DIETARY_RESTRICTIONS + TELEGRAM +} + enum QuestionType { CHECKBOX RADIO @@ -2772,6 +2792,44 @@ input RegistrationFilter { updatedBy: UUIDFilter } +""" +Values used to prefill event registration answers. Only visible to the user themselves. +""" +type RegistrationProfile { + createdAt: Datetime! + + """Dietary restrictions and allergies.""" + dietaryRestrictions: String + + """Telegram handle.""" + telegram: String + updatedAt: Datetime! + + """Reads a single `User` that is related to this `RegistrationProfile`.""" + user: User + + """The user this registration profile belongs to.""" + userId: UUID! +} + +"""A `RegistrationProfile` edge in the connection.""" +type RegistrationProfilesEdge { + """A cursor for use in pagination.""" + cursor: Cursor + + """The `RegistrationProfile` at the end of the edge.""" + node: RegistrationProfile! +} + +"""Methods to use when ordering `RegistrationProfile`.""" +enum RegistrationProfilesOrderBy { + NATURAL + PRIMARY_KEY_ASC + PRIMARY_KEY_DESC + USER_ID_ASC + USER_ID_DESC +} + enum RegistrationStatus { IN_OPEN_QUOTA IN_QUEUE @@ -3002,6 +3060,41 @@ type SetAdminStatusPayload { success: Boolean } +"""All input for the `setRegistrationProfile` mutation.""" +input SetRegistrationProfileInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + dietaryRestrictions: String! + telegram: String! +} + +"""The output of our `setRegistrationProfile` mutation.""" +type SetRegistrationProfilePayload { + """ + The exact same `clientMutationId` that was provided in the mutation input, + unchanged and unused. May be used by a client to track mutations. + """ + clientMutationId: String + + """ + Our root query field type. Allows us to run any query from our mutation payload. + """ + query: Query + registrationProfile: RegistrationProfile + + """An edge for our `RegistrationProfile`. May be used by Relay 1.""" + registrationProfileEdge( + """The method to use when ordering `RegistrationProfile`.""" + orderBy: [RegistrationProfilesOrderBy!] = [PRIMARY_KEY_ASC] + ): RegistrationProfilesEdge + + """Reads a single `User` that is related to this `RegistrationProfile`.""" + user: User +} + """ A filter to be used against String fields. All fields are combined with a logical ‘and.’ """ @@ -3407,6 +3500,9 @@ type Subscription { """Get registration by update token. (live)""" registrationByUpdateToken(updateToken: String!): Registration + """ (live)""" + registrationProfile(userId: UUID!): RegistrationProfile + """Reads and enables pagination through a set of `Registration`. (live)""" registrations( """Read all values in the set after (below) this cursor.""" @@ -3712,6 +3808,7 @@ input UpdateEventQuestionInput { isRequired: Boolean label: TranslatedField position: Int + prefill: QuestionPrefill type: QuestionType } @@ -3902,6 +3999,9 @@ type User { """Users primary email.""" primaryEmail: String + + """Reads a single `RegistrationProfile` that is related to this `User`.""" + registrationProfile: RegistrationProfile updatedAt: Datetime! """Reads and enables pagination through a set of `UserAuthentication`.""" From 66eb86121837520344f7fc9afab5cd642c5c1a8a Mon Sep 17 00:00:00 2001 From: Henri Salmi Date: Sat, 17 Oct 2026 15:12:22 +0300 Subject: [PATCH 2/2] feat: pick prefill questions from the question type select Telegram and dietary restrictions are now options in the same type select as Text, Radio and Checkbox instead of a separate prefill select on TEXT questions. Picking one stores a TEXT question with `prefill` set and fills in its label for every selected language, keeping labels the admin has written themselves. Co-Authored-By: Claude Opus 5.5 --- @app/client/src/translations/en/events.json | 1 - @app/client/src/translations/fi/events.json | 1 - @app/client/src/translations/se/events.json | 1 - .../components/src/EventForm/QuestionsTab.tsx | 85 ++++++++++++++----- 4 files changed, 65 insertions(+), 23 deletions(-) diff --git a/@app/client/src/translations/en/events.json b/@app/client/src/translations/en/events.json index 46598243a..46bc09539 100644 --- a/@app/client/src/translations/en/events.json +++ b/@app/client/src/translations/en/events.json @@ -36,7 +36,6 @@ "questions": { "data": "Question", "label": "Label", - "prefill": "Prefill", "type": "Type" }, "quota": { diff --git a/@app/client/src/translations/fi/events.json b/@app/client/src/translations/fi/events.json index 282d3848b..b00007a8b 100644 --- a/@app/client/src/translations/fi/events.json +++ b/@app/client/src/translations/fi/events.json @@ -36,7 +36,6 @@ "questions": { "data": "Kysymys", "label": "Otsikko", - "prefill": "Esitäyttö", "type": "Tyyppi" }, "quota": { diff --git a/@app/client/src/translations/se/events.json b/@app/client/src/translations/se/events.json index eae6ab745..c1c6da7b7 100644 --- a/@app/client/src/translations/se/events.json +++ b/@app/client/src/translations/se/events.json @@ -36,7 +36,6 @@ "questions": { "data": "Fråga", "label": "Etikett", - "prefill": "Förifyllning", "type": "Typ" }, "quota": { diff --git a/@app/components/src/EventForm/QuestionsTab.tsx b/@app/components/src/EventForm/QuestionsTab.tsx index 22abe9ca3..cbca0f07d 100644 --- a/@app/components/src/EventForm/QuestionsTab.tsx +++ b/@app/components/src/EventForm/QuestionsTab.tsx @@ -50,6 +50,22 @@ interface QuestionsTabProps { const colSpan = { md: { span: 6 }, sm: { span: 12 }, xs: { span: 24 } } +// Prefill questions are TEXT questions with a fixed label. The admin picks +// them from the type select, and the label is filled in for every language. +const PREFILL_LABELS: Record> = { + [QuestionPrefill.Telegram]: { + fi: "Telegram-käyttäjänimi", + en: "Telegram username", + }, + [QuestionPrefill.DietaryRestrictions]: { + fi: "Erityisruokavaliot ja allergiat", + en: "Dietary restrictions and allergies", + }, +} + +const isPrefill = (val: unknown): val is QuestionPrefill => + Object.values(QuestionPrefill).includes(val as QuestionPrefill) + export const QuestionsTab: React.FC = memo( ({ form, selectedLanguages }) => { /** @@ -64,10 +80,30 @@ export const QuestionsTab: React.FC = memo( const questions = getFieldValue("questions") as QuestionData[] function handleTypeChange(val: SelectValue, index: number) { - if (val === "TEXT") { - // If the type was changed to TEXT, reset question data + if (val === "TEXT" || isPrefill(val)) { + // If the type was changed to TEXT, reset question data. The type + // field itself is normalized to TEXT for prefill questions. let questions = getFieldValue("questions") - questions[index].data = null + const question = questions[index] + question.data = null + question.prefill = isPrefill(val) ? val : null + + // Fill in the label of a prefill question, keeping labels the admin + // has written themselves + if (isPrefill(val)) { + const autoLabels = Object.values(PREFILL_LABELS) + question.label = Object.fromEntries( + selectedLanguages.map((l) => { + const lang = l.toLowerCase() + const current = question.label?.[lang] + const isAuto = + !current || + autoLabels.some((labels) => labels[lang] === current) + const label = PREFILL_LABELS[val][lang] ?? PREFILL_LABELS[val].en + return [lang, isAuto ? label : current] + }) + ) + } setFieldsValue({ questions, }) @@ -198,22 +234,8 @@ export const QuestionsTab: React.FC = memo( <> {questionLabel} - {/* TEXT questions don't have any data associated with them, - but their answer can be prefilled from the registration profile */} - - - + {/* TEXT questions don't have any data associated with them. + This Col is included for layout. */} ) @@ -329,14 +351,27 @@ export const QuestionsTab: React.FC = memo( + + + + {/* A prefill question shows as its own type, but + is stored as a TEXT question with `prefill` set */} ({ + value: + getFieldValue(["questions", name, "prefill"]) ?? + type, + })} name={[name, "type"]} + normalize={(val) => + isPrefill(val) ? QuestionType.Text : val + } rules={[ { required: true, @@ -349,7 +384,8 @@ export const QuestionsTab: React.FC = memo( >