Skip to content
Snippets Groups Projects
Commit c55002f5 authored by CL's avatar CL
Browse files

[event] adding data numeric type support (seb-models!1)

parent c65cd6b8
1 merge request!1[event] adding data numeric type support
......@@ -18,6 +18,7 @@ import {
Labeled,
List,
Loading,
NumberInput,
ReferenceField,
ReferenceInput,
ShowButton,
......@@ -160,6 +161,8 @@ const eventPrice = (event, person, data) => {
if (data[dat.name] === true) {
price += member ? dat.price_member : dat.price;
}
} else if (dat.type === 'numeric') {
price += (member ? dat.price_member : dat.price) * data[dat.name];
} else if (dat.type === 'select') {
for (let val of dat.values) {
if (data[dat.name] === val.name) {
......@@ -219,6 +222,8 @@ const EventDataInput = ({ eventId, personId, priceChanged, ...props }) => {
if (v.name in val) return;
if (v.type === 'boolean') {
val[v.name] = false;
} else if (v.type === 'numeric') {
val[v.name] = 0;
} else if (v.type === 'select') {
val[v.name] = v.values[0]?.name;
} else {
......@@ -243,6 +248,12 @@ const EventDataInput = ({ eventId, personId, priceChanged, ...props }) => {
label={capitalize(structure.name)}
/>
);
} else if (structure.type === 'numeric') {
return (
<FormControl key={index} variant="filled" margin="normal">
<NumberInput label={capitalize(structure.name)} onChange={onChangeWrapper(structure.name)} name={structure.name} />
</FormControl>
);
} else if (structure.type === 'select') {
return (
<FormControl key={index} variant="filled" margin="normal">
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment