From 4030d27a09042b850c0eadb5fa78943beb6cf053 Mon Sep 17 00:00:00 2001 From: Pasq G Date: Thu, 21 Nov 2024 14:00:52 +0100 Subject: [PATCH] Pobles --- imports/api/links.js | 3 - imports/api/pobles.js | 3 + imports/ui/App.jsx | 42 +++++++++- server/main.js | 183 +++++++++++++++++++++++++++++++++++++----- 4 files changed, 205 insertions(+), 26 deletions(-) delete mode 100644 imports/api/links.js create mode 100644 imports/api/pobles.js diff --git a/imports/api/links.js b/imports/api/links.js deleted file mode 100644 index 050c508..0000000 --- a/imports/api/links.js +++ /dev/null @@ -1,3 +0,0 @@ -import { Mongo } from 'meteor/mongo'; - -export const LinksCollection = new Mongo.Collection('links'); diff --git a/imports/api/pobles.js b/imports/api/pobles.js new file mode 100644 index 0000000..96f6834 --- /dev/null +++ b/imports/api/pobles.js @@ -0,0 +1,3 @@ +import { Mongo } from 'meteor/mongo'; + +export const PoblesCollection = new Mongo.Collection('pobles'); diff --git a/imports/ui/App.jsx b/imports/ui/App.jsx index bd1adca..2758c7c 100644 --- a/imports/ui/App.jsx +++ b/imports/ui/App.jsx @@ -1,29 +1,64 @@ -import React from 'react'; +import React, { Suspense } from 'react'; import { Meteor } from 'meteor/meteor'; import { BrowserRouter, Routes, Route, Link } from 'react-router-dom'; import { Login } from './Login'; import { useUserId } from 'meteor/react-meteor-accounts'; +import { PoblesCollection } from '/imports/api/pobles.js'; +import { useSubscribe, useTracker, useFind } from 'meteor/react-meteor-data/suspense'; +const AfegirPoblacio = () => { + useSubscribe('pobles'); + + const pobles = useTracker("pobles", () => PoblesCollection.find().fetchAsync()); + + return Carregant...} > +
{ + Meteor.callAsync('user.addToDataDay', + { + date: new Date(), + memo: d.get('memo'), + longmemo: d.get('longmemo') + } + ).catch(err => console.error(err)) + }}> +
+
+
+ +
+ + +
; +}; + const Loguejat = () => { const userId = useUserId(); // const user = await Meteor.userAsync(); return userId ?
+ + Afegir Població + +

- poble (que cada poble només tinga accés a lo del seu poble, la resta de pobles no els han de poder tocar): Alaquàs / Albal / Aldaia / Alfafar / Algemesí / Alginet / Alcàsser / Benetússer / Beniparrell / Carlet / Catarroja / Dosaigües / Godelleta / Guadassuar / Iàtova / L'Alcúdia / Llocnou de la Corona / Massanassa / Paiporta / Parke Alkosa / Picanya / Sedaví / Setaigües / Utiel / València-Castellar Oliveral / València-Forn d'Alcedo / València-La Torre / Xest / Xiva / Llombai / Tremolar

- estat: impossible de trobar / disponible / pendent / enviada / ha arribat (que cada poble puga tocar aquestes opcions dels subministres per al seu poble)

- tipus de subministre: maquinària / menjar i beguda / productes infantils / higiene i neteja / sanitari / roba i calçat / ferramentes / necessitats especials / EPIs / electrònica / per a animals / roba de llit, mantes, cortines i mantells / vaixella i utensilis de cuina / papereria i material escolar / mobiliari i electrodomèstics /altres

- necessitat (que la plataforma et dóne un desplegable amb totes les necessitats que s'han demanat fins ara en eixa categoria i pugues buscar, però també afegir-ne coses noves) - que la plataforma demane en aquest punt que siguen tant específiques com puguen (que no em fiquen com a necessitat "mobles" sinó per exemple "rentadora")

-

- NOMÉS EN CAS DE MOBILIARI I ELECTRODOMÈSTICS: +

- NOMÉS EN CAS DE MOBILIARI I ELECTRODOMÈSTICS: ---- adreça de la casa o lloc on s'ha de dur (tenda, casa, baix...) ---- que afegisquen dies i horaris en què estaran a eixa adreça ---- especificar que el contacte que afegisquen ha de ser necessàriament de la persona que ho va a rebre en la casa o espai

- - que la plataforma recullga la data en la que es fa una petició de subministres + - que la plataforma recullga la data en la que es fa una petició de subministres - que la plataforma recullga la data en la que el subministre es canvia a l'estat "ha arribat) @@ -45,6 +80,7 @@ export const App = () => ( } /> + } /> } /> diff --git a/server/main.js b/server/main.js index 0198535..307c4c2 100644 --- a/server/main.js +++ b/server/main.js @@ -1,37 +1,180 @@ import { Meteor } from 'meteor/meteor'; -import { LinksCollection } from '/imports/api/links'; +import { PoblesCollection } from '/imports/api/pobles.js'; -async function insertLink({ title, url }) { - await LinksCollection.insertAsync({ title, url, createdAt: new Date() }); +async function insertPoble({ nomPoble, cp, comarca }) { + await PoblesCollection.insertAsync({ nomPoble, cp, comarca, createdAt: new Date() }); } Meteor.startup(async () => { - // If the Links collection is empty, add some data. - if (await LinksCollection.find().countAsync() === 0) { - await insertLink({ - title: 'Do the Tutorial', - url: 'https://www.meteor.com/tutorials/react/creating-an-app', + // If the Pobles collection is empty, add some data. + if (await PoblesCollection.find().countAsync() === 0) { + await insertPoble({ + nomPoble: "Alaquàs", + cp: "", + comarca: "" }); - await insertLink({ - title: 'Follow the Guide', - url: 'https://guide.meteor.com', + await insertPoble({ + nomPoble: "Albal", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Aldaia", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Alfafar", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Algemesí", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Alginet", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Alcàsser", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Benetússer", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Beniparrell", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Carlet", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Catarroja", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Dosaigües", + cp: "", + comarca: "" }); - await insertLink({ - title: 'Read the Docs', - url: 'https://docs.meteor.com', + await insertPoble({ + nomPoble: "Godelleta", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Guadassuar", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Iàtova", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "L'Alcúdia", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Llocnou de la Corona", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Massanassa", + cp: "", + comarca: "" }); - await insertLink({ - title: 'Discussions', - url: 'https://forums.meteor.com', + + + await insertPoble({ + nomPoble: "Paiporta", + cp: "", + comarca: "" }); + await insertPoble({ + nomPoble: "Parke Alkosa", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Picanya", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Sedaví", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Setaigües", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Utiel", + cp: "", + comarca: "" + }); + + await insertPoble({ + nomPoble: "València-Castellar Oliveral", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "València-Forn d'Alcedo", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "València-La Torre", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Xest", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Xiva", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Llombai", + cp: "", + comarca: "" + }); + await insertPoble({ + nomPoble: "Tremolar", + cp: "", + comarca: "" + }); + } - // We publish the entire Links collection to all clients. + // We publish the entire Pobles collection to all clients. // In order to be fetched in real-time to the clients - Meteor.publish("links", function () { - return LinksCollection.find(); + Meteor.publish("pobles", function () { + return PoblesCollection.find(); }); });