diff --git a/imports/ui/Codis.jsx b/imports/ui/Codis.jsx index 8f9ed70..f2b1c12 100644 --- a/imports/ui/Codis.jsx +++ b/imports/ui/Codis.jsx @@ -7,6 +7,8 @@ import { CodisCollection } from '../api/codis'; // import { TipusCollection } from '../api/tipus'; import { useSubscribe, useTracker, useFind } from 'meteor/react-meteor-data/suspense'; import { Roles } from 'meteor/roles'; +// import { useNavigate } from 'react-router-dom'; + // import { useUserId } from 'meteor/react-meteor-accounts'; import Select from 'react-select'; @@ -112,10 +114,73 @@ export const Codis = () => { >; } + function handleToggleAbsActiu(ev) { + ev.preventDefault(); + ev.stopPropagation(); + + if (codiSeleccionat) { + Meteor.callAsync('modCodiDocToggleAbsActiu', codiSeleccionat); + setCodiSeleccionat({ + ...codiSeleccionat, + absActiu: !codiSeleccionat.absActiu + }); + } else { + setConfecCodObj({ + ...confecCodObj, + absActiu: !confecCodObj.absActiu + }); + } + } + + function handleSetCondIni(v) { + + console.log("h") + + Meteor.callAsync('modCodiDocSetCondIni', { + ...codiSeleccionat, + condIni: v.currentTarget.value + }); + + if (codiSeleccionat) { + setCodiSeleccionat({ + ...codiSeleccionat, + condIni: v.currentTarget.value + }); + } else { + setConfecCodObj({ + ...confecCodObj, + condIni: v.currentTarget.value + }); + } + } + + function handleSetCondFi(v) { + + Meteor.callAsync('modCodiDocSetCondFi', { + ...codiSeleccionat, + condFi: v.currentTarget.value + }); + + if (codiSeleccionat) { + setCodiSeleccionat({ + ...codiSeleccionat, + condFi: v.currentTarget.value + }); + } else { + setConfecCodObj({ + ...confecCodObj, + condFi: v.currentTarget.value + }); + } + } + const QuadreInfo_Codis = () => { + // const navigate = useNavigate(); + + const [actCond, setActCond] = useState(true); - const [codiGenerat, setCodiGenerat] = useState(generaCodi()); + // const [codiGenerat, setCodiGenerat] = useState(generaCodi()); const [absCond, setAbsCond] = useState('cond'); @@ -135,7 +200,6 @@ export const Codis = () => {
{
name="condIni"
onChange={v => {
- // console.log("dataIni: ", v.currentTarget.value);
- setConfecCodObj({
- ...confecCodObj,
- condIni: v.currentTarget.value
- })
+ // // console.log("dataIni: ", v.currentTarget.value);
+ // setConfecCodObj({
+ // ...confecCodObj,
+ // condIni: v.currentTarget.value
+ // })
+
+ handleSetCondIni(v);
}}
- defaultValue={confecCodObj.condIni}
+ defaultValue={codiSeleccionat?.condIni || confecCodObj.condIni}
/>
Fins a: {
// console.log("dataFi: ", v.currentTarget.value);
- setConfecCodObj({
- ...confecCodObj,
- condFi: v.currentTarget.value
- })
+ // setConfecCodObj({
+ // ...confecCodObj,
+ // condFi: v.currentTarget.value
+ // })
+
+ handleSetCondFi(v);
}}
- defaultValue={confecCodObj.condFi}
+ defaultValue={codiSeleccionat?.condFi || confecCodObj.condFi}
/>
>
@@ -416,7 +476,7 @@ export const Codis = () => {