Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build the registration from using the userschema provided by backend #6435

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
05139cb
build the registration from using the userschema provided by backend
erral Oct 24, 2024
7882859
Merge branch 'main' into erral-registration-form-with-userschema
erral Oct 24, 2024
fbb5e5b
prettier
erral Oct 24, 2024
d86b649
Update packages/volto/news/6434.feature
erral Oct 25, 2024
22cdbb1
Update packages/volto/src/components/theme/Register/Register.stories.jsx
erral Oct 25, 2024
dc1e596
Update packages/volto/src/components/theme/Register/Register.stories.jsx
erral Oct 25, 2024
fac9aa7
Merge branch 'main' into erral-registration-form-with-userschema
erral Oct 25, 2024
906a485
Merge branch 'main' into erral-registration-form-with-userschema
erral Oct 25, 2024
f544fe0
s/fullname/full name
erral Oct 25, 2024
53cb2c3
remove unneeded strings
erral Oct 25, 2024
3b80078
update po files
erral Oct 25, 2024
d3a8e77
Merge branch 'main' into erral-registration-form-with-userschema
erral Oct 25, 2024
c1b8552
Update packages/volto/src/components/theme/Register/__snapshots__/Reg…
erral Oct 27, 2024
3d80440
Merge branch 'main' into erral-registration-form-with-userschema
erral Oct 27, 2024
2c288ee
Merge branch 'main' into erral-registration-form-with-userschema
erral Oct 27, 2024
84b98fa
update Register test snapshot
ionlizarazu Oct 28, 2024
8c9b3c5
fix: Register.jsx file test and snapshot
ionlizarazu Oct 28, 2024
8a5ef06
Merge branch 'main' into erral-registration-form-with-userschema
erral Oct 29, 2024
67b7f5f
add cypress test
erral Oct 30, 2024
7372fa1
send all the data in the form to the backend
erral Oct 30, 2024
76eda12
Merge branch 'main' into erral-registration-form-with-userschema
erral Oct 30, 2024
53d588f
Merge branch 'main' into erral-registration-form-with-userschema
ionlizarazu Nov 4, 2024
911ccfe
Merge branch 'main' into erral-registration-form-with-userschema
ionlizarazu Nov 5, 2024
8207472
Merge branch 'main' into erral-registration-form-with-userschema
ionlizarazu Nov 5, 2024
903aa91
Merge branch 'main' into erral-registration-form-with-userschema
ionlizarazu Nov 6, 2024
c3dd62d
Merge branch 'main' into erral-registration-form-with-userschema
ionlizarazu Nov 8, 2024
166fa73
remove unused translations
ionlizarazu Nov 8, 2024
3f6c741
Merge branch 'main' into erral-registration-form-with-userschema
erral Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/volto/news/6434.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Build the registration form with the information of the backend (provided by the @userschema endpoint) @erral
erral marked this conversation as resolved.
Show resolved Hide resolved
38 changes: 15 additions & 23 deletions packages/volto/src/components/theme/Register/Register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { toast } from 'react-toastify';
import { Helmet, usePrevious } from '@plone/volto/helpers';
import { Toast } from '@plone/volto/components';
import { Form } from '@plone/volto/components/manage/Form';
import { createUser } from '@plone/volto/actions';
import { createUser, getUserSchema } from '@plone/volto/actions';

const messages = defineMessages({
title: {
Expand Down Expand Up @@ -64,6 +64,13 @@ const Register = () => {
const { loaded, loading, error } = useUsers();

const prevloading = usePrevious(loading);
const userschema = useSelector((state) => state.userschema);

useEffect(() => {
if (!userschema.loading && !userschema.loaded) {
dispatch(getUserSchema());
}
}, [userschema, dispatch]);

useEffect(() => {
if (prevloading && loaded) {
Expand All @@ -90,6 +97,12 @@ const Register = () => {
setError(null);
};

const emptySchema = {
fieldsets: [],
properties: {},
required: [],
};

return (
<div id="page-register">
<Helmet title={intl.formatMessage(messages.register)} />
Expand All @@ -99,28 +112,7 @@ const Register = () => {
error={errors || error}
loading={loading}
submitLabel={intl.formatMessage(messages.register)}
schema={{
fieldsets: [
{
id: 'default',
title: intl.formatMessage(messages.default),
fields: ['fullname', 'email'],
},
],
properties: {
fullname: {
type: 'string',
title: intl.formatMessage(messages.fullnameTitle),
description: intl.formatMessage(messages.fullnameDescription),
},
email: {
type: 'string',
title: intl.formatMessage(messages.emailTitle),
description: intl.formatMessage(messages.emailDescription),
},
},
required: ['fullname', 'email'],
}}
schema={userschema.loaded ? userschema.userschema : emptySchema}
/>
</div>
);
Expand Down
26 changes: 26 additions & 0 deletions packages/volto/src/components/theme/Register/Register.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@ function StoryComponent(args) {
locale: 'en',
messages: {},
},
userschema: {
loaded: true,
loading: false,
userschema: {
fieldsets: [
{
id: 'default',
title: 'default',
fields: ['fullname', 'email'],
},
],
properties: {
fullname: {
type: 'string',
title: 'Fullname',
erral marked this conversation as resolved.
Show resolved Hide resolved
description: 'Enter your fullname',
erral marked this conversation as resolved.
Show resolved Hide resolved
},
email: {
type: 'string',
title: 'email',
description: 'Enter your email address',
},
},
required: ['fullname', 'email'],
},
},
}}
>
<div id="toolbar" style={{ display: 'none' }} />
Expand Down
26 changes: 26 additions & 0 deletions packages/volto/src/components/theme/Register/Register.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ describe('Register', () => {
loaded: true,
},
},
userschema: {
loaded: true,
loading: false,
userschema: {
fieldsets: [
{
id: 'default',
title: 'default',
fields: ['fullname', 'email'],
},
],
properties: {
fullname: {
type: 'string',
title: 'Fullname',
description: 'Enter your fullname',
},
email: {
type: 'string',
title: 'email',
description: 'Enter your email address',
},
},
required: ['fullname', 'email'],
},
},
});
const component = renderer.create(
<Provider store={store}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`Register renders a register component 1`] = `
\\"fieldsets\\": [
{
\\"id\\": \\"default\\",
\\"title\\": \\"Default\\",
\\"title\\": \\"default\\",
\\"fields\\": [
\\"fullname\\",
\\"email\\"
Expand All @@ -19,13 +19,13 @@ exports[`Register renders a register component 1`] = `
\\"properties\\": {
\\"fullname\\": {
\\"type\\": \\"string\\",
\\"title\\": \\"Full Name\\",
\\"description\\": \\"Enter full name, e.g. John Smith.\\"
\\"title\\": \\"Fullname\\",
erral marked this conversation as resolved.
Show resolved Hide resolved
\\"description\\": \\"Enter your fullname\\"
},
\\"email\\": {
\\"type\\": \\"string\\",
\\"title\\": \\"E-mail\\",
\\"description\\": \\"Enter an email address. This will be your login name. We respect your privacy, and will not give the address away to any third parties or expose it anywhere.\\"
\\"title\\": \\"email\\",
\\"description\\": \\"Enter your email address\\"
}
},
\\"required\\": [
Expand Down
Loading