/
EditCustomer.vue
191 lines (177 loc) · 5.36 KB
/
EditCustomer.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<template>
<v-app>
<Navbar/>
<v-content>
<form @submit.prevent="editCustomer">
<v-card>
<v-container grid-list-sm class="pa-4">
<v-layout row wrap>
<v-flex xs10 align-center justify-space-between>
<v-layout align-center>
<v-text-field
prepend-icon="face"
placeholder="Customer Name"
required
v-model="customer.customer_name"
></v-text-field>
</v-layout>
</v-flex>
<v-flex xs10>
<v-text-field
type="email"
prepend-icon="mail"
placeholder="Email"
v-model="customer.email"
></v-text-field>
</v-flex>
<v-flex xs10>
<v-text-field
type="number"
prepend-icon="phone"
placeholder="(000) 000 - 0000"
v-model="customer.phone"
></v-text-field>
</v-flex>
<v-flex xs10>
<v-text-field
prepend-icon="business"
placeholder="Company"
v-model="customer.company"
></v-text-field>
</v-flex>
<v-flex xs10>
<v-text-field
prepend-icon="work"
placeholder="Designation"
v-model="customer.designation"
></v-text-field>
</v-flex>
<v-flex xs10>
<v-text-field
prepend-icon="language"
placeholder="Country"
v-model="customer.country"
></v-text-field>
</v-flex>
<v-flex xs10>
<v-text-field
prepend-icon="home"
placeholder="City"
v-model="customer.city"
></v-text-field>
</v-flex>
<v-flex xs10>
<v-text-field
prepend-icon="tv"
placeholder="Website"
v-model="customer.website"
></v-text-field>
</v-flex>
<v-flex xs10>
<h4 v-if="customer.source">Source: {{customer.source.text}}</h4>
<v-select
prepend-icon="group"
v-bind:items="sources"
v-model="customer.source"
label="Sources"
single-line
></v-select>
</v-flex>
<v-flex xs10>
<h4 v-if="customer.rating"> Current Rating: {{customer.rating.text}}</h4>
<v-select
:items="ratings"
v-model="customer.rating"
label="Ratings"
single-line
></v-select>
</v-flex>
<v-flex xs10>
<v-text-field
v-model="customer.details"
label="Buesiness history with this customer....."
multi-line
></v-text-field>
</v-flex>
<v-flex xs10>
<v-btn type="submit" block color="primary" dark>Update Customer</v-btn>
</v-flex>
</v-layout>
</v-container>
</v-card>
</form>
</v-content>
</v-app>
</template>
<script>
import Navbar from '@/components/navbar/Navbar'
import db from '@/firebase/init'
export default {
name:'EditCustomer',
components:{
Navbar
},
data(){
return{
dialog:null,
customer:[],
sources: [
{ id: 1, text: 'Facebook' },
{ id: 2, text: 'Website' },
{ id: 3, text: 'Networks' },
{ id: 4, text: 'Direct Marketing' },
{ id: 5, text: 'Others' },
],
ratings: [
{ id: 1, text: "Bad" },
{ id: 2, text: "Not Good" },
{ id: 3, text: "Good" },
{ id: 4, text: "Very Good" },
{ id: 5, text: "Excellent" },
],
customer_name:null,
email:null,
phone:null,
country:null,
city:null,
website:null,
company:null,
designation:null,
source:null,
rating:null,
details:null,
feedback:null
}
},
methods:{
editCustomer(){
if(this.customer.customer_name){
let ref = db.collection('customers').doc(this.$route.params.id)
ref.update({
customer_name:this.customer.customer_name,
email:this.customer.email,
phone:this.customer.phone,
country:this.customer.country,
city:this.customer.city,
website:this.customer.website,
company:this.customer.company,
designation:this.customer.designation,
source:this.customer.source,
rating:this.customer.rating,
details:this.customer.details,
})
}
this.$router.push({ name: 'Customers'})
}
},
created(){
// Customers Data
db.collection("customers").doc(this.$route.params.id).onSnapshot(doc =>{
this.customer = doc.data()
this.customer.id = doc.id
})
}
}
</script>
<style>
</style>