feat: allow users to sign up and fill out public forms#1114
Conversation
|
There was a problem hiding this comment.
please add to this when you encounter an issue!
There was a problem hiding this comment.
ideally we would define most errors for server actions like this i think, rather than having a bunch of random return { error: 'xxxx' } everywhere
There was a problem hiding this comment.
i thought i wanted to use this in a playwright test (to do a rollback), which is why i moved it. didn't actually want to turns out, bc if you update things in a transaction, ofc the app will not reflect those changes before you commit
|
|
||
| const handleSubmit = useCallback( | ||
| async (data: SignupFormSchema) => { | ||
| // TODO: this is not very nice UX, we should wait a sec and show a loading state |
There was a problem hiding this comment.
since the signup function already redirected users i didn't really want to change it, but we should figure out some nice pattern here
There was a problem hiding this comment.
this is the signup form for users who are invited using the email action to complete their signup. i think we should phase this out and handle those invites the same as invites where we do not create an account yet (#1002)
There was a problem hiding this comment.
users who are already logged in should not sign up again, they can just join the community immediately.
both this and the signup form (or just that page) should show some branding in the future.
| [FormAccessType.inviteOnly]: { | ||
| Icon: Contact, | ||
| description: "Accessible via URL with tracked submissions", | ||
| name: "Invite Only", | ||
| help: "Community members & invited contributors can submit", | ||
| }, |
There was a problem hiding this comment.
As per the extra work in #1051 , we now only have private and public forms
There was a problem hiding this comment.
this logic is getting very complex. in my next pr i will create some kind of centralized place to handle this, like a Service class or something
| "display": "Next.js", | ||
| "extends": "./base.json", | ||
| "compilerOptions": { | ||
| "plugins": [{ "name": "next" }], |
There was a problem hiding this comment.
this removal doesn't really do anything other than make me feel better.
| type?: "button" | "submit" | "reset"; | ||
| }; | ||
|
|
||
| export const SubmitButton = ({ |
|
I tested using the preview environment, though I wasn't able to see the pub once I hit submit on the form. I saw the 'Go see your pubs here' link, and clicked here, but then got redirected to sign in. I tried to sign in but it didn't work (this might just be because I didn't remember my temp password right). the pub I made is there though: https://pr-1114-public-form-u-ip-54-221-104-228.my.preview.run/c/croccroc/pubs/84e66eea-563f-4c2c-ba90-fcfd1f781cea I'll try locally too to see if maybe it's just something is up with the preview env |
|
well it seems to work locally! although I can't seem to change a form to private so haven't been able to test the 'no forms should show up' state yet Screen.Recording.2025-04-02.at.11.28.26.AM.mov |
|
huh that's strange, ill have a look! |
|
The "not being able to change access types" is a bug in the formbuilder, you need to change something else about the form in order for it to change. ill put up a quick pr which addresses that (and some other thing), but i don't want this pr to be even bigger! |
allisonking
left a comment
There was a problem hiding this comment.
ah okay great! I confirmed that I can make private if I also add another form element, and then the not-signed-in user can't see it 👍 nice work!
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Issue(s) Resolved
Resolves #1053
Resolves #1051
High-level Explanation of PR
There is now the possibility for people to sign up to communities without being invited.
Communities that have at least one public form now automatically enable signups at
/c/{communitySlug}/public/signup. There currently is no way to disable this aside from settings your forms to private.Users who go to a public form, will now be redirected to the signup page, where they can sign up to the community. Once complete, they will be redirected to the form they tried to access.
Separately from all this: once a user creates a pub using the PubEditor, they will be added as a Contributor to the pub. This allows the user to see the pub in the pub list.
This PR also removes the "Invite Only" access type. Forms which were set to this will be set to
privateinstead.Extra credits
Redirect to the created pub
Currently there is no easy way to direct the user to their created pub. I added a new option to the
:linktoken that allows you to link to a pub. It goes like:link(page='currentPub' text='View your pub'). This will link to the pub that the user just created. By setting the postsubmit screen like i do herehttps://github.com/pubpub/platform/blob/1e622788da94c05597f27a586f5df2040bd40bea/core/playwright/formAccess.spec.ts#L126-L131
the user will see a screen like this (note how it links to a direct pub)
We should probably have some redirect action instead, see #1115 for more details.
Nicer button
I added a button that automatically does broadly correct loading state showing, see:
Screen.Recording.2025-03-27.at.19.55.02.mov
The code is here:
https://github.com/pubpub/platform/blob/8b86f1f18dd978de78d5622e7c0ede14d322066c/core/app/components/SubmitButton.tsx#L1-L176
I think it's nice and we should use it in more places.
Test Plan
As always, convince yourself of the truth and accuracy of the added tests.
Do maybe the same again after changing the form to private (and logging out). You should not be able to see the form/signup page at all.
Screenshots (if applicable)
Demo:
Screenshare.-.2025-03-27.8_21_16.PM.mp4
I changed the spacing of button config form from this
to this
Notes