Skip to content

Commit

Permalink
fix: combine metadata when sending personal details
Browse files Browse the repository at this point in the history
  • Loading branch information
mirovladimitrovski committed Oct 3, 2023
1 parent 4fd8bf7 commit b1273ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/containers/AccountModal/forms/PersonalDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { mixed, object, string } from 'yup';
import { useQuery } from 'react-query';

import { useConfigStore } from '#src/stores/ConfigStore';
import { useAccountStore } from '#src/stores/AccountStore';
import useForm, { UseFormOnSubmitHandler } from '#src/hooks/useForm';
import PersonalDetailsForm from '#components/PersonalDetailsForm/PersonalDetailsForm';
import LoadingOverlay from '#components/LoadingOverlay/LoadingOverlay';
Expand All @@ -23,6 +24,7 @@ const PersonalDetails = () => {
const { t } = useTranslation('account');
const accessModel = useConfigStore((s) => s.accessModel);
const { data, isLoading } = useQuery('captureStatus', () => getCaptureStatus());
const { user } = useAccountStore();
const { hasTVODOffers } = useOffers();
const [questionValues, setQuestionValues] = useState<Record<string, string>>({});
const [questionErrors, setQuestionErrors] = useState<Record<string, string>>({});
Expand Down Expand Up @@ -117,7 +119,10 @@ const PersonalDetails = () => {
value: questionValues[question.key],
} as CaptureCustomAnswer),
);
await updateCaptureAnswers(removeEmpty({ ...formData, customAnswers }));

const metadata = removeEmpty({ ...user?.metadata });

await updateCaptureAnswers(removeEmpty({ ...formData, customAnswers, metadata }));

nextStep();
} catch (error: unknown) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/inplayer.account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@ function formatUpdateAccount(customer: UpdateCustomerArgs) {
const firstName = customer.firstName?.trim() || '';
const lastName = customer.lastName?.trim() || '';
const fullName = `${firstName} ${lastName}`.trim() || (customer.email as string);
const metadata: { [key: string]: string } = {
const metadata: Record<string, string> = {
...customer.metadata,
first_name: firstName,
surname: lastName,
...customer.metadata,
};
const data: UpdateAccountData = {
fullName,
Expand Down

0 comments on commit b1273ca

Please sign in to comment.