Skip to content

Commit

Permalink
fix: send metadata upon updating profile info
Browse files Browse the repository at this point in the history
  • Loading branch information
mirovladimitrovski committed Oct 20, 2023
1 parent c2915d7 commit 0328c2d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/components/Account/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Checkbox from '#components/Checkbox/Checkbox';
import HelperText from '#components/HelperText/HelperText';
import CustomRegisterField from '#components/CustomRegisterField/CustomRegisterField';
import useToggle from '#src/hooks/useToggle';
import { formatConsentsFromValues, formatConsents, formatConsentValues } from '#src/utils/collection';
import { formatConsentsFromValues, formatConsents, formatConsentValues, formatConsentsToRegisterFields } from '#src/utils/collection';
import { addQueryParam } from '#src/utils/location';
import { useAccountStore } from '#src/stores/AccountStore';
import { exportAccountData, updateConsents, updateUser } from '#src/stores/AccountController';
Expand Down Expand Up @@ -185,7 +185,19 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true }
formSection({
label: t('account.about_you'),
editButton: t('account.edit_information'),
onSubmit: (values) => updateUser({ firstName: values.firstName || '', lastName: values.lastName || '' }),
onSubmit: (values) => {
const consents = formatConsentsFromValues(publisherConsents, { ...values.metadata, ...values.consentsValues });

return updateUser({
firstName: values.firstName || '',
lastName: values.lastName || '',
metadata: {
...values.metadata,
...formatConsentsToRegisterFields(consents),
consents: JSON.stringify(consents),
},
});
},
content: (section) => (
<>
<TextField
Expand Down Expand Up @@ -262,7 +274,7 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true }
formSection({
label: t('account.terms_and_tracking'),
saveButton: t('account.update_consents'),
onSubmit: (values) => updateConsents(formatConsentsFromValues(publisherConsents, { ...values.consentsValues, terms: true })),
onSubmit: (values) => updateConsents(formatConsentsFromValues(publisherConsents, values.consentsValues)),
content: (section) => (
<>
{termsConsents?.map((consent, index) => (
Expand Down
2 changes: 1 addition & 1 deletion types/account.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export type ListProfilesResponse = {
export type FirstLastNameInput = {
firstName: string;
lastName: string;
metadata?: Record<string, string>;
metadata?: Record<string, string | boolean>;
};

export type EmailConfirmPasswordInput = {
Expand Down

0 comments on commit 0328c2d

Please sign in to comment.