diff --git a/APP/components/Formularios/Fcompras.vue b/APP/components/Formularios/Fcompras.vue
index eb9b2c5..0c22464 100644
--- a/APP/components/Formularios/Fcompras.vue
+++ b/APP/components/Formularios/Fcompras.vue
@@ -25,14 +25,14 @@
diff --git a/APP/layouts/default.vue b/APP/layouts/default.vue
index cf89550..5c5e391 100644
--- a/APP/layouts/default.vue
+++ b/APP/layouts/default.vue
@@ -1,12 +1,13 @@
-
+
+
+
+
+
diff --git a/APP/pages/compras.vue b/APP/pages/compras.vue
index b901746..7ec3010 100644
--- a/APP/pages/compras.vue
+++ b/APP/pages/compras.vue
@@ -105,21 +105,13 @@ export default {
metodo: "Tarjeta Debito",
},
],
- categorias: [
- {
- ctg: "Restaurante",
- },
- {
- ctg: "Servicios",
- },
- {
- ctg: "Transporte",
- },
- ],
+ categorias: [],
};
},
mounted() {
this.newCompra.fecha = this.$store.state.fecha;
+ this.categorias = this.$store.state.categorias;
+ this.metodos_pago = this.$store.state.metodos_de_pago;
this.getCompras();
},
methods: {
@@ -155,20 +147,21 @@ export default {
.catch((e) => console.log(e));
},
deleteCompra(id) {
- const axiosHeader={
- headers:{
+ const axiosHeader = {
+ headers: {
token: this.$store.state.auth.token,
-
},
- params:{
- id:id
- }
- }
- this.$axios.delete("/compra",axiosHeader).then(res=>{
-
- console.log(res.data);
- this.getCompras();
- }).catch(e => console.log(e))
+ params: {
+ id: id,
+ },
+ };
+ this.$axios
+ .delete("/compra", axiosHeader)
+ .then((res) => {
+ console.log(res.data);
+ this.getCompras();
+ })
+ .catch((e) => console.log(e));
},
clearFormCompra() {
this.newCompra.detalle = "";
@@ -176,6 +169,10 @@ export default {
this.newCompra.metodopago = "";
this.newCompra.categoria = "";
},
+ getIcon(name) {
+ const found = this.$store.state.categorias.find((ic) => ic.name === name);
+ console.log(found);
+ },
},
};
diff --git a/APP/pages/configuracion.vue b/APP/pages/configuracion.vue
new file mode 100644
index 0000000..0672d06
--- /dev/null
+++ b/APP/pages/configuracion.vue
@@ -0,0 +1,305 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/APP/store/index.js b/APP/store/index.js
index fc04ede..1436091 100644
--- a/APP/store/index.js
+++ b/APP/store/index.js
@@ -19,6 +19,10 @@ export const state = () => ({
setCategorias(state, categorias) {
state.categorias = categorias;
},
+
+ setMetodos(state, metodos) {
+ state.metodos_de_pago = metodos;
+ },
diff --git a/index.js b/index.js
index 88da67b..6447467 100644
--- a/index.js
+++ b/index.js
@@ -26,6 +26,8 @@ app.use(cors());
//Rutas
app.use('/api',require('./routes/users'));
app.use('/api',require('./routes/compras'))
+app.use('/api',require('./routes/categorias'))
+app.use('/api',require('./routes/metodos_pago'))
module.exports = app;
app.listen(app.get('port') ,() => console.log("service startes, listening on the port: ",app.get('port')))
diff --git a/models/categorias.js b/models/categoria.js
similarity index 50%
rename from models/categorias.js
rename to models/categoria.js
index 7406f3d..47a0a76 100755
--- a/models/categorias.js
+++ b/models/categoria.js
@@ -2,7 +2,8 @@ const mongoose = require('mongoose');
const {Schema} =mongoose;
const categoriaShema=new Schema({
- categoria:{type:String,required:true},
+ name:{type:String,required:true},
+ icon:{type:String,default:"fa-circle-o "},
user:{type:String, required:true}
});
diff --git a/models/metodo.js b/models/metodo.js
new file mode 100755
index 0000000..5cf8050
--- /dev/null
+++ b/models/metodo.js
@@ -0,0 +1,10 @@
+const mongoose = require('mongoose');
+const {Schema} =mongoose;
+
+const metodoShema=new Schema({
+ name:{type:String,required:true},
+ icon:{type:String,default:"fa-circle-o "},
+ user:{type:String, required:true}
+
+});
+module.exports=mongoose.model('metodo',metodoShema);
\ No newline at end of file
diff --git a/routes/categorias.js b/routes/categorias.js
new file mode 100644
index 0000000..74d1530
--- /dev/null
+++ b/routes/categorias.js
@@ -0,0 +1,64 @@
+const router = require("express").Router();
+const Categoria = require("../models/categoria");
+const { checkAuth } = require("../middlewares/authentication");
+
+
+router.get("/categoria", checkAuth, async (req, res) => {
+ var categorias;
+
+ categorias = await Categoria.find({ user: req.userData._id });
+
+ return res.send(
+ {
+ status:"ok",
+ data:categorias
+
+ }
+ )
+ });
+
+
+ router.post("/categoria", checkAuth, async (req, res) => {
+ const {name, icon} = req.body;
+ const user= req.userData._id;
+
+ var categoria = await Categoria.findOne({ name: name });
+ if (categoria) {
+ return res.status(500).json({ status: "fail", error: "Categoria existente" });
+
+ }
+
+ const newCategoria = new Categoria({
+ user,
+ name,
+ icon,
+ });
+
+ await newCategoria.save();
+
+ res.json({
+ status:"ok"
+ })
+
+
+ });
+
+ router.delete("/categoria", checkAuth, async (req, res) => {
+
+ try{
+ const userId = req.userData._id;
+ const id = req.query.id;
+
+ const resultado = await Categoria.deleteOne({user:userId,_id:id});
+
+ return res.json({status:"ok",data: resultado})
+
+ }
+ catch(error){
+ console.log(error);
+ return res.status(500).json({status:"fail",error:error})
+ }
+ });
+
+
+ module.exports = router;
\ No newline at end of file
diff --git a/routes/metodos_pago.js b/routes/metodos_pago.js
new file mode 100644
index 0000000..09be709
--- /dev/null
+++ b/routes/metodos_pago.js
@@ -0,0 +1,64 @@
+const router = require("express").Router();
+const Metodo = require("../models/metodo");
+const { checkAuth } = require("../middlewares/authentication");
+
+
+router.get("/metodo", checkAuth, async (req, res) => {
+ var metodos;
+
+ metodos = await Metodo.find({ user: req.userData._id });
+
+ return res.send(
+ {
+ status:"ok",
+ data:metodos
+
+ }
+ )
+ });
+
+
+ router.post("/metodo", checkAuth, async (req, res) => {
+ const {name, icon} = req.body;
+ const user= req.userData._id;
+
+ var metodo = await Metodo.findOne({ name: name });
+ if (metodo) {
+ return res.status(500).json({ status: "fail", error: "Método de pago existente" });
+
+ }
+
+ const newMetodo = new Metodo({
+ user,
+ name,
+ icon,
+ });
+
+ await newMetodo.save();
+
+ res.json({
+ status:"ok"
+ })
+
+
+ });
+
+ router.delete("/metodo", checkAuth, async (req, res) => {
+
+ try{
+ const userId = req.userData._id;
+ const id = req.query.id;
+
+ const resultado = await Metodo.deleteOne({user:userId,_id:id});
+
+ return res.json({status:"ok",data: resultado})
+
+ }
+ catch(error){
+ console.log(error);
+ return res.status(500).json({status:"fail",error:error})
+ }
+ });
+
+
+ module.exports = router;
\ No newline at end of file