Skip to content

Commit

Permalink
Merge pull request #90 from SilverCareOrg/main
Browse files Browse the repository at this point in the history
pull from main
  • Loading branch information
Ion-Stefan authored Jan 11, 2024
2 parents dbf0bfc + 46867d8 commit 290fbfd
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions src/pages/AdminUpdateServiceProduct.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,33 @@ function AdminUpdateServiceProduct() {
if (response.status === 200) {
const json = response.data;
const currentService = json.service[0][0];
let x = [];

for (let i = 0; i< currentService.options.length; i++)
{
handleAddServiceOption(currentService.options[i]);
}
console.log(currentService.options)

if(options.length === currentService.options.length)

for (let i = 0; i< currentService.sections.length; i++)
{
setFormData(() => ({
name: currentService?.name,

organiser: currentService?.organiser,
category: currentService?.category,
description: currentService?.description,
iban: currentService?.iban,
city: currentService?.city,
common_location: currentService?.common_location,
county: currentService?.county,
options_common_city: currentService?.options_common_city,
img_path: currentService?.img_path,
image: currentService?.image,
map_location: currentService?.map_location,
options: options,
has_more_options: currentService?.has_more_options,
location: currentService?.location,
}));
handleSectionsInit(currentService.sections[i]);
}



setFormData(() => ({
name: currentService?.name,
organiser: currentService?.organiser,
category: currentService?.category,
description: currentService?.description,
iban: currentService?.iban,
city: currentService?.city,
common_location: currentService?.common_location,
county: currentService?.county,
options_common_city: currentService?.options_common_city,
img_path: currentService?.img_path,
image: currentService?.image,
map_location: currentService?.map_location,
has_more_options: currentService?.has_more_options,
location: currentService?.location,
}));
}

})
Expand All @@ -127,6 +124,15 @@ function AdminUpdateServiceProduct() {
get_all_services();
}, []);

const handleSectionsInit = (section) => {
var existingSections = sectionText;
console.log(existingSections);
console.log(section);
existingSections[section.question] = section.answer;

setSectionText(existingSections);
};

const handleSectionSelect = (section) => {
setSelectedSection(section);
if (!sectionText[section]) {
Expand Down Expand Up @@ -244,8 +250,9 @@ function AdminUpdateServiceProduct() {
city: option?.city,
county: option?.county,
};
setOptions([...options, newOption]);
console.log(options);
var existingOptions = options;
existingOptions.push(newOption);
setOptions(existingOptions);
};

const handleOptionMarkerClick = (e, index) => {
Expand Down

0 comments on commit 290fbfd

Please sign in to comment.