Skip to content

Commit 1fa3f53

Browse files
committed
Error nos validator
1 parent deebb3e commit 1fa3f53

File tree

14 files changed

+214
-19
lines changed

14 files changed

+214
-19
lines changed

client/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</a>
2222
</li>
2323
<li>
24-
<a href="/list">
24+
<a href="/lists">
2525
<i class="material-icons">supervisor_account</i>
2626
</a>
2727
</li>

client/src/components/email/email-edit.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<h5>Editando campanha</h5>
55
</div>
66
<div class="col s12">
7-
<a href="'#/emails/view/' + email._id" class="btn">ver</a>
7+
<a :href="'#/emails/view/' + email._id" class="btn">ver</a>
88
</div>
99
<div class="col s12">
1010
<div class="card grey lighten-4">
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<template>
2+
<div class="row">
3+
<div class="col s12">
4+
<h5>Remoção de campanha</h5>
5+
</div>
6+
<div class="col s12">
7+
<a :href="'#/emails/view/' + email._id" class="btn blue">ver</a>
8+
</div>
9+
<div class="col s12">
10+
<div class="card red white-text">
11+
<div class="card-content">
12+
<span class="card-title">Confirmação</span>
13+
<p>Você confirma a remoção deste registro? Você não poderá desfazer essa operação</p>
14+
<a href="" class="btn white black-text" @click.prevent="remove">Sim</a>
15+
<a href="#/email" class="btn black">Não</a>
16+
</div>
17+
</div>
18+
</div>
19+
</div>
20+
</template>
21+
22+
<script>
23+
export default {
24+
computed: {
25+
email: function () {
26+
return this.$store.state.email.email
27+
}
28+
},
29+
methods: {
30+
remove: function () {
31+
if (confirm('Tem certeza?')) {
32+
this.$store.dispatch('remove', this.email._id).then(() => {
33+
this.$router.push('/email/')
34+
})
35+
}
36+
}
37+
},
38+
mounted () {
39+
this.$store.dispatch('getOne', this.$route.params.id)
40+
}
41+
}
42+
</script>
Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,45 @@
11
<template>
2-
<div>
3-
<h1>Listas de disparo</h1>
2+
<div class="row">
3+
<div class="col s12">
4+
<h5>Lista de disparo</h5>
5+
</div>
6+
<div class="col s12">
7+
<div class="card">
8+
<div class="card-content">
9+
<table>
10+
<thead>
11+
<tr>
12+
<th>#</th>
13+
<th>titulo</th>
14+
<th>quantidade</th>
15+
<th></th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
<tr v-for="(list, index) in lists">
20+
<td>{{index + 1}}</td>
21+
<td>{{list.title}}</td>
22+
<td>{{list.quantity}}</td>
23+
<td>
24+
<a :href="'#/lists/' + list._id" class="btn">ver</a>
25+
</td>
26+
</tr>
27+
</tbody>
28+
</table>
29+
</div>
30+
</div>
31+
</div>
432
</div>
533
</template>
634
<script>
735
export default {
8-
36+
computed: {
37+
lists: function () {
38+
return this.$store.state.list.lists
39+
}
40+
},
41+
mounted: function () {
42+
this.$store.dispatch('getAllList')
43+
}
944
}
1045
</script>

client/src/router/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import EmailList from '@/components/email/email-list'
88
import EmailNew from '@/components/email/email-new'
99
import EmailView from '@/components/email/email-view'
1010
import EmailEdit from '@/components/email/email-edit'
11+
import EmailRemove from '@/components/email/email-remove'
1112
import ListsList from '@/components/lists/lists-list'
1213

1314
Vue.use(Router)
@@ -44,6 +45,12 @@ let router = new Router({
4445
component: EmailEdit,
4546
meta: {requiresAuth: true}
4647
},
48+
{
49+
path: '/emails/remove/:id',
50+
name: 'EmailRemove',
51+
component: EmailRemove,
52+
meta: {requiresAuth: true}
53+
},
4754
{
4855
path: '/lists',
4956
name: 'ListsList',

client/src/states/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Vuex from 'vuex'
33

44
import user from './modules/user'
55
import email from './modules/email'
6+
import list from './modules/list'
67

78
window.axios = require('axios')
89
window.axios.defaults.baseURL = process.env.SERVER
@@ -11,7 +12,8 @@ window.axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-url
1112
let config = {
1213
modules: {
1314
user: user,
14-
email: email
15+
email: email,
16+
list: list
1517
}
1618
}
1719

client/src/states/modules/email.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ export default {
3232
})
3333
},
3434
update (context, data) {
35-
console.log('data', data)
3635
return window.axios.put('/api/campaigns/' + data._id, qs.stringify(data)).then((response) => {
3736
return response
3837
})
38+
},
39+
remove (context, id) {
40+
return window.axios.delete('/api/campaigns/' + id).then((response) => {
41+
return response
42+
})
3943
}
4044
}
4145
}

client/src/states/modules/list.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export default {
2+
state: {
3+
lists: [],
4+
list: {}
5+
},
6+
mutations: {
7+
updateLists (state, data) {
8+
state.lists = data
9+
},
10+
updateList (state, data) {
11+
state.list = data
12+
}
13+
},
14+
actions: {
15+
getAllList (context) {
16+
return window.axios.get('/api/lists').then((response) => {
17+
context.commit('updateLists', response.data.data)
18+
return response
19+
})
20+
}
21+
}
22+
}

server/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const logger = require('morgan');
66
const mongoose = require('./src/db/connection');
77
const cors = require('cors');
88
const routes = require('./src/routes');
9+
const validator = require('express-validator');
910

1011
// let indexRouter = require('./routes/index');
1112
// let usersRouter = require('./routes/users');
@@ -22,6 +23,8 @@ app.use(express.json());
2223
app.use(express.urlencoded({ extended: false }));
2324
app.use(cookieParser());
2425
app.use(express.static(path.join(__dirname, 'public')));
26+
app.use(validator());
27+
2528

2629
// app.use('/', indexRouter);
2730
// app.use('/users', usersRouter);

server/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)