diff --git a/imports/ui/App.jsx b/imports/ui/App.jsx
index c01e3d7..2f33e31 100644
--- a/imports/ui/App.jsx
+++ b/imports/ui/App.jsx
@@ -16,38 +16,44 @@ const Pobles = () => {
const QuadreInfo_Poble = () => {
return <>
-
{pobleSeleccionat._id}
+ {pobleSeleccionat && {pobleSeleccionat._id}
}
+
>;
};
return Carregant...>} >
- {pobleSeleccionat && }
+
+
{
pobles
- .sort((a,b) => a.nomPoble.toLowerCase() > b.nomPoble.toLowerCase())
+ .sort((a,b) => a.nomPoble?.toLowerCase() > b.nomPoble?.toLowerCase())
.map(pob => - {pob.nomPoble}
)
}
;
diff --git a/server/main.js b/server/main.js
index c1c935d..5fbbf2d 100644
--- a/server/main.js
+++ b/server/main.js
@@ -185,11 +185,17 @@ Meteor.startup(async () => {
'editaOAfigPoble': async function (poble) {
try {
if (poble.nomPoble) {
- return await PoblesCollection.insertAsync({
- ...poble,
- usuari: Meteor.userId(),
- createdAt: new Date()
- });
+ return await PoblesCollection.upsertAsync(
+ {
+ _id: poble._id
+ }, {
+ $set: {
+ ...poble,
+ usuari: Meteor.userId(),
+ editedAt: new Date()
+ }
+ }
+ );
} else {
throw new Error("El nom del poble no és vàlid");
}