Skip to content

Commit ed4162f

Browse files
committed
allow profile updates
1 parent 42ee7b5 commit ed4162f

5 files changed

Lines changed: 9 additions & 33 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "https://foerderfunke.org/",
66
"dependencies": {
7-
"@foerderfunke/matching-engine": "1.5.5",
7+
"@foerderfunke/matching-engine": "1.5.8",
88
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
99
"@babel/plugin-transform-private-property-in-object": "^7.24.7",
1010
"@emotion/react": "^11.11.4",

src/ui/screens/profile-screen/components/ProfileUpdateInputSwitch.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import ProfileInputInteger from "../../question-pages/components/input-types/Pro
44
import ProfileInputDate from "../../question-pages/components/input-types/ProfileInputDate";
55
import ProfileInputBoolean from "../../question-pages/components/input-types/ProfileInputBoolean";
66
import ProfileInputMultiSelection from "../../question-pages/components/input-types/ProfileInputMultiSelection";
7-
import { shrink } from "@foerderfunke/sem-ops-utils";
87

98

109
const ProfileUpdateInputSwitch = ({ t, value, setValue, datafieldDetails, error }) => {
11-
const shortenedUri = shrink(datafieldDetails?.datatype);
12-
switch (shortenedUri) {
10+
switch (datafieldDetails?.datatype) {
1311
case 'ff:selection':
1412
return <ProfileInputSelection
1513
value={value}

src/ui/screens/profile-screen/hooks/useSetupProfileUpdate.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useState, useEffect } from 'react';
22
import matchingEngineManager from "@/core/managers/matchingEngineManager";
3-
import { expand } from "@foerderfunke/sem-ops-utils";
43
import userManager from '@/core/managers/userManager';
54
import { useUserStore } from '@/ui/storage/zustand';
65

@@ -10,14 +9,12 @@ export default function useSetupProfileUpdate(datafield) {
109

1110
useEffect(() => {
1211
if (!datafield) return;
13-
14-
const expanded = expand(datafield);
1512
let active = true;
1613

1714
(async () => {
1815
try {
1916
// 1) fetch details
20-
const details = await matchingEngineManager.fetchDetailsForDatafield(expanded);
17+
const details = await matchingEngineManager.fetchDetailsForDatafield(datafield);
2118
if (!active) return;
2219
setDatafieldDetails(details);
2320

src/ui/screens/profile-screen/hooks/useUpdateDatafield.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ export default function useUpdateDatafield(datafield, datafieldDetails, setOpen)
1515
const handleUpdateClick = useCallback(
1616
async (value) => {
1717
if (!datafield) return;
18-
console.log('Updating datafield:', datafield, 'with value:', value);
1918
try {
20-
const shrunkValue = shrink(value);
21-
await validateValue(shrunkValue);
22-
await addProfileData(shrunkValue);
19+
await validateValue(value);
20+
await addProfileData(value);
2321
setOpen(false);
2422
} catch (err) {
2523
console.error('Error handling update click:', err);

src/ui/screens/question-pages/components/input-types/ProfileInputMultiSelection.js

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useMemo } from 'react';
22
import { Checkbox, FormControlLabel, FormGroup, FormLabel, Typography } from '@mui/material';
33
import useTranslation from "@/ui/language/useTranslation";
4-
import { expand } from "@foerderfunke/sem-ops-utils";
54

65
const ProfileInputMultiSelection = ({
76
value,
@@ -33,32 +32,16 @@ const ProfileInputMultiSelection = ({
3332
return map;
3433
}, [answerOptions, optionsFormat]);
3534

36-
const normalizedValue = useMemo(() => {
37-
if (!Array.isArray(value)) return [];
38-
if (optionsFormat === "flat") {
39-
return value.map((v) => expand(v));
40-
}
41-
return value;
42-
}, [value, optionsFormat]);
43-
4435
const handleChange = (event) => {
4536
const selectedValue = event.target.name;
4637
const isChecked = event.target.checked;
4738

4839
if (isChecked) {
49-
setValue((prevValue = []) => {
50-
const toStore = optionsFormat === "flat" ? expand(selectedValue) : selectedValue;
51-
if (prevValue.includes(toStore)) return prevValue;
52-
return [...prevValue, toStore];
40+
setValue((prevValue) => {
41+
return prevValue ? [...prevValue, selectedValue] : [selectedValue];
5342
});
5443
} else {
55-
setValue((prevValue = []) => {
56-
const expandedToRemove = optionsFormat === "flat" ? expand(selectedValue) : selectedValue;
57-
// remove both the expanded and the raw form to be safe
58-
return prevValue.filter(
59-
(item) => item !== expandedToRemove && item !== selectedValue
60-
);
61-
});
44+
setValue(value.filter((item) => item !== selectedValue));
6245
}
6346
};
6447

@@ -72,7 +55,7 @@ const ProfileInputMultiSelection = ({
7255
sx={{ mb: 2 }}
7356
control={
7457
<Checkbox
75-
checked={normalizedValue.includes(key)}
58+
checked={value.includes(key)}
7659
onChange={handleChange}
7760
name={key}
7861
/>

0 commit comments

Comments
 (0)