first commit
This commit is contained in:
309
src/pages/card/addcard.vue
Normal file
309
src/pages/card/addcard.vue
Normal file
@@ -0,0 +1,309 @@
|
||||
<template>
|
||||
<Header/>
|
||||
<div class="flex">
|
||||
<div class="">
|
||||
<SideBar/>
|
||||
</div>
|
||||
<div class=" w-full px-10">
|
||||
<div class="text-sm breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link :to="{ name: 'home' }">
|
||||
Home
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'customer' }">
|
||||
Customers
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 rounded-md p-6 ">
|
||||
<div class="text-[24px]">
|
||||
Add Credit Card for {{ customer.customer_last_name }}
|
||||
</div>
|
||||
<form class="rounded-md px-8 pt-6 pb-8 mb-4 w-full"
|
||||
enctype="multipart/form-data"
|
||||
@submit.prevent="onSubmit">
|
||||
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
|
||||
<label class="block text-white text-sm font-bold cursor-pointer label">Main Card</label>
|
||||
<input v-model="CreateCardForm.basicInfo.main_card"
|
||||
class="checkbox"
|
||||
id="fill"
|
||||
type="checkbox"/>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Name on Card</label>
|
||||
<input v-model="CreateCardForm.basicInfo.card_name"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="Name on Card"/>
|
||||
<span v-if="v$.CreateCardForm.basicInfo.card_name.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.card_name.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Card Number</label>
|
||||
<input v-model="CreateCardForm.basicInfo.card_number"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="Card Number"/>
|
||||
<span v-if="v$.CreateCardForm.basicInfo.card_number.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.card_number.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Expiration Month</label>
|
||||
<select
|
||||
v-model="CreateCardForm.basicInfo.expiration_month"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="Month"
|
||||
>
|
||||
<option>01</option>
|
||||
<option>02</option>
|
||||
<option>03</option>
|
||||
<option>04</option>
|
||||
<option>05</option>
|
||||
<option>06</option>
|
||||
<option>07</option>
|
||||
<option>08</option>
|
||||
<option>09</option>
|
||||
<option>10</option>
|
||||
<option>11</option>
|
||||
<option>12</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Expiration Year</label>
|
||||
<select
|
||||
v-model="CreateCardForm.basicInfo.expiration_year"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="Month"
|
||||
>
|
||||
<option>2024</option>
|
||||
<option>2025</option>
|
||||
<option>2026</option>
|
||||
<option>2027</option>
|
||||
<option>2028</option>
|
||||
<option>2029</option>
|
||||
<option>2030</option>
|
||||
</select>
|
||||
|
||||
<span v-if="v$.CreateCardForm.basicInfo.expiration_year.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.expiration_year.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Type of Card</label>
|
||||
<select
|
||||
v-model="CreateCardForm.basicInfo.type_of_card"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="Month"
|
||||
>
|
||||
<option>Visa</option>
|
||||
<option>MasterCard</option>
|
||||
<option>Discover</option>
|
||||
<option>American Express</option>
|
||||
</select>
|
||||
|
||||
<span v-if="v$.CreateCardForm.basicInfo.type_of_card.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.type_of_card.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Security Number</label>
|
||||
<input v-model="CreateCardForm.basicInfo.security_number"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="Back of card"/>
|
||||
<span v-if="v$.CreateCardForm.basicInfo.security_number.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.security_number.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
|
||||
<button
|
||||
class="btn">
|
||||
Save Credit Card
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Footer/>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent} from 'vue'
|
||||
import axios from 'axios'
|
||||
import authHeader from '../../services/auth.header'
|
||||
import Header from '../../layouts/headers/headerauth.vue'
|
||||
import SideBar from '../../layouts/sidebar/sidebar.vue'
|
||||
import Footer from '../../layouts/footers/footer.vue'
|
||||
import useValidate from "@vuelidate/core";
|
||||
import {notify} from "@kyvg/vue3-notification"
|
||||
import {minLength, required} from "@vuelidate/validators";
|
||||
|
||||
export default defineComponent({
|
||||
name: 'AddCardCreate',
|
||||
|
||||
components: {
|
||||
Header,
|
||||
SideBar,
|
||||
Footer,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
v$: useValidate(),
|
||||
user: null,
|
||||
|
||||
customer: {
|
||||
id: 0,
|
||||
customer_first_name: '',
|
||||
customer_last_name: '',
|
||||
customer_town: '',
|
||||
customer_state: 0,
|
||||
customer_zip: '',
|
||||
customer_apt: '',
|
||||
customer_home_type: 0,
|
||||
customer_phone_number: '',
|
||||
},
|
||||
CreateCardForm: {
|
||||
basicInfo: {
|
||||
card_name: '',
|
||||
expiration_month: '',
|
||||
expiration_year: '',
|
||||
type_of_card: '',
|
||||
security_number: '',
|
||||
card_number:'',
|
||||
main_card: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
validations() {
|
||||
return {
|
||||
CreateCardForm: {
|
||||
basicInfo: {
|
||||
card_name: {required, minLength: minLength(1)},
|
||||
expiration_month: {required, minLength: minLength(1)},
|
||||
expiration_year: {required, minLength: minLength(1)},
|
||||
security_number: {required, minLength: minLength(1)},
|
||||
type_of_card: {required, minLength: minLength(1)},
|
||||
card_number: {required, minLength: minLength(1)},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.userStatus()
|
||||
},
|
||||
watch: {
|
||||
$route() {
|
||||
this.getCustomer(this.$route.params.id);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getCustomer(this.$route.params.id)
|
||||
},
|
||||
methods: {
|
||||
|
||||
userStatus() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.user = response.data.user;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.user = null
|
||||
})
|
||||
},
|
||||
getCustomer(user_id: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/customer/" + user_id;
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.customer = response.data;
|
||||
})
|
||||
.catch(() => {
|
||||
notify({
|
||||
title: "Error",
|
||||
text: "Could not find customer",
|
||||
type: "error",
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
CreateCard(payload: {
|
||||
card_name: string;
|
||||
expiration_month: string;
|
||||
expiration_year: string;
|
||||
type_of_card: string;
|
||||
security_number: string;
|
||||
card_number: string;
|
||||
main_card: boolean;
|
||||
}) {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/payment/card/create/" + this.customer.id;
|
||||
axios({
|
||||
method: "post",
|
||||
url: path,
|
||||
data: payload,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.$router.push({name: "customerProfile", params: { id: this.customer.id }});
|
||||
}
|
||||
if (response.data.error) {
|
||||
this.$router.push("/");
|
||||
}
|
||||
})
|
||||
},
|
||||
onSubmit() {
|
||||
let payload = {
|
||||
card_name: this.CreateCardForm.basicInfo.card_name,
|
||||
card_number: this.CreateCardForm.basicInfo.card_number,
|
||||
expiration_month: this.CreateCardForm.basicInfo.expiration_month,
|
||||
expiration_year: this.CreateCardForm.basicInfo.expiration_year,
|
||||
type_of_card: this.CreateCardForm.basicInfo.type_of_card,
|
||||
security_number: this.CreateCardForm.basicInfo.security_number,
|
||||
main_card: this.CreateCardForm.basicInfo.main_card,
|
||||
};
|
||||
this.CreateCard(payload);
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
382
src/pages/card/editcard.vue
Normal file
382
src/pages/card/editcard.vue
Normal file
@@ -0,0 +1,382 @@
|
||||
<template>
|
||||
<Header/>
|
||||
<div class="flex">
|
||||
<div class="">
|
||||
<SideBar/>
|
||||
</div>
|
||||
<div class=" w-full px-10">
|
||||
<div class="text-sm breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link :to="{ name: 'home' }">
|
||||
Home
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'customer' }">
|
||||
Customers
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 rounded-md p-6 ">
|
||||
<div class="text-[24px]">
|
||||
Credit Card Customer: {{ customer }}
|
||||
|
||||
</div>
|
||||
<div class="text-[20px]">
|
||||
Card Id: {{card.id}}
|
||||
</div>
|
||||
<form class="rounded-md px-8 pt-6 pb-8 mb-4 w-full"
|
||||
enctype="multipart/form-data"
|
||||
@submit.prevent="onSubmit">
|
||||
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
|
||||
<label class="block text-white text-sm font-bold cursor-pointer label">Main Card</label>
|
||||
<input v-model="CreateCardForm.basicInfo.main_card"
|
||||
class="checkbox"
|
||||
id="fill"
|
||||
type="checkbox"/>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Name on Card</label>
|
||||
<input v-model="CreateCardForm.basicInfo.card_name"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="Name on Card"/>
|
||||
<span v-if="v$.CreateCardForm.basicInfo.card_name.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.card_name.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Card Number</label>
|
||||
<input v-model="CreateCardForm.basicInfo.card_number"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="Card Number"/>
|
||||
<span v-if="v$.CreateCardForm.basicInfo.card_number.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.card_number.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Expiration Month</label>
|
||||
<select
|
||||
v-model="CreateCardForm.basicInfo.expiration_month"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="Month"
|
||||
>
|
||||
<option>01</option>
|
||||
<option>02</option>
|
||||
<option>03</option>
|
||||
<option>04</option>
|
||||
<option>05</option>
|
||||
<option>06</option>
|
||||
<option>07</option>
|
||||
<option>08</option>
|
||||
<option>09</option>
|
||||
<option>10</option>
|
||||
<option>11</option>
|
||||
<option>12</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Expiration Year</label>
|
||||
<select
|
||||
v-model="CreateCardForm.basicInfo.expiration_year"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="Month"
|
||||
>
|
||||
<option>2024</option>
|
||||
<option>2025</option>
|
||||
<option>2026</option>
|
||||
<option>2027</option>
|
||||
<option>2028</option>
|
||||
<option>2029</option>
|
||||
<option>2030</option>
|
||||
</select>
|
||||
|
||||
<span v-if="v$.CreateCardForm.basicInfo.expiration_year.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.expiration_year.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Type of Card</label>
|
||||
<select
|
||||
v-model="CreateCardForm.basicInfo.type_of_card"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="Month"
|
||||
>
|
||||
<option>Visa</option>
|
||||
<option>MasterCard</option>
|
||||
<option>Discover</option>
|
||||
<option>American Express</option>
|
||||
</select>
|
||||
|
||||
<span v-if="v$.CreateCardForm.basicInfo.type_of_card.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.type_of_card.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Security Number</label>
|
||||
<input v-model="CreateCardForm.basicInfo.security_number"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="Back of card"/>
|
||||
<span v-if="v$.CreateCardForm.basicInfo.security_number.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCardForm.basicInfo.security_number.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
|
||||
<button class="btn">
|
||||
Edit Card
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Footer/>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent} from 'vue'
|
||||
import axios from 'axios'
|
||||
import { notify } from "@kyvg/vue3-notification";
|
||||
import authHeader from '../../services/auth.header'
|
||||
import Header from '../../layouts/headers/headerauth.vue'
|
||||
import SideBar from '../../layouts/sidebar/sidebar.vue'
|
||||
import Footer from '../../layouts/footers/footer.vue'
|
||||
import useValidate from "@vuelidate/core";
|
||||
|
||||
import {minLength, required} from "@vuelidate/validators";
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EditCard',
|
||||
|
||||
components: {
|
||||
Header,
|
||||
SideBar,
|
||||
Footer,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
v$: useValidate(),
|
||||
user: {
|
||||
id: '',
|
||||
},
|
||||
customer: {
|
||||
id: 0,
|
||||
customer_last_name: '',
|
||||
customer_first_name: '',
|
||||
customer_town: '',
|
||||
customer_state: '',
|
||||
customer_zip: '',
|
||||
customer_first_call: '',
|
||||
customer_email: '',
|
||||
customer_automatic: '',
|
||||
customer_phone_number: '',
|
||||
customer_home_type: '',
|
||||
customer_apt: '',
|
||||
customer_address: '',
|
||||
},
|
||||
card: {
|
||||
id: '',
|
||||
card_name: '',
|
||||
expiration_month: '',
|
||||
expiration_year: '',
|
||||
type_of_card: '',
|
||||
security_number: '',
|
||||
main_card: '',
|
||||
user_id: '',
|
||||
},
|
||||
|
||||
card_id: null,
|
||||
customer_id: null,
|
||||
CreateCardForm: {
|
||||
basicInfo: {
|
||||
card_name: '',
|
||||
expiration_month: '',
|
||||
expiration_year: '',
|
||||
type_of_card: '',
|
||||
security_number: '',
|
||||
card_number: '',
|
||||
main_card: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
validations() {
|
||||
return {
|
||||
CreateCardForm: {
|
||||
basicInfo: {
|
||||
card_name: {required, minLength: minLength(1)},
|
||||
expiration_month: {required, minLength: minLength(1)},
|
||||
expiration_year: {required, minLength: minLength(1)},
|
||||
security_number: {required, minLength: minLength(1)},
|
||||
type_of_card: {required, minLength: minLength(1)},
|
||||
card_number: {required, minLength: minLength(1)},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
||||
this.userStatus()
|
||||
},
|
||||
watch: {
|
||||
$route() {
|
||||
this.getCard(this.$route.params.id);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getCard(this.$route.params.id)
|
||||
},
|
||||
methods: {
|
||||
userStatus() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.user = response.data.user;
|
||||
this.user.id = response.data.user.id;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.user.id = '';
|
||||
})
|
||||
},
|
||||
getCustomer(user_id: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/customer/" + user_id;
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((response: any) => {
|
||||
|
||||
this.customer_id = response.data.user_id;
|
||||
this.customer.customer_last_name= response.data.customer_last_name;
|
||||
this.customer.customer_first_name = response.data.customer_first_name;
|
||||
this.customer.customer_town = response.data.customer_town;
|
||||
this.customer.customer_state = response.data.customer_state;
|
||||
this.customer.customer_zip = response.data.customer_zip;
|
||||
this.customer.customer_first_call = response.data.customer_first_call;
|
||||
this.customer.customer_email = response.data.customer_email;
|
||||
this.customer.customer_automatic = response.data.customer_automatic;
|
||||
this.customer.customer_phone_number = response.data.customer_phone_number;
|
||||
this.customer.customer_home_type = response.data.customer_home_type;
|
||||
this.customer.customer_apt = response.data.customer_last_name;
|
||||
this.customer.customer_address = response.data.customer_last_name;
|
||||
|
||||
})
|
||||
.catch(() => {
|
||||
notify({
|
||||
title: "Error",
|
||||
text: "Could not find customer",
|
||||
type: "error",
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
getCard (card_id:any) {
|
||||
|
||||
let path = import.meta.env.VITE_BASE_URL + "/payment/card/" + card_id ;
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.CreateCardForm.basicInfo.card_name= response.data.card.card_name;
|
||||
this.CreateCardForm.basicInfo.expiration_month= response.data.card.expiration_month;
|
||||
this.CreateCardForm.basicInfo.expiration_year= response.data.card.expiration_year;
|
||||
this.CreateCardForm.basicInfo.type_of_card= response.data.card.type_of_card;
|
||||
this.CreateCardForm.basicInfo.security_number= response.data.card.security_number;
|
||||
this.CreateCardForm.basicInfo.main_card= response.data.card.main_card;
|
||||
this.CreateCardForm.basicInfo.card_number= response.data.card.card_number;
|
||||
|
||||
this.user.id = response.data.card.user_id
|
||||
|
||||
this.card.id=response.data.card.id;
|
||||
this.card.user_id=response.data.card.user_id;
|
||||
this.card.card_name= response.data.card.card_name
|
||||
this.card.expiration_month=response.data.card.expiration_month;
|
||||
this.card.expiration_year=response.data.card.expiration_year;
|
||||
this.card.type_of_card=response.data.card.type_of_card;
|
||||
this.card.security_number=response.data.card.security_number;
|
||||
this.card.main_card=response.data.card.main_card;
|
||||
|
||||
this.getCustomer(response.data.card.user_id)
|
||||
}
|
||||
})
|
||||
},
|
||||
editCard(payload: {
|
||||
|
||||
card_name: string;
|
||||
expiration_month: string;
|
||||
expiration_year: string;
|
||||
type_of_card: string;
|
||||
security_number: string;
|
||||
main_card: boolean;
|
||||
}) {
|
||||
|
||||
let path = import.meta.env.VITE_BASE_URL + "/payment/card/edit/" + this.$route.params.id ;
|
||||
axios({
|
||||
method: "put",
|
||||
url: path,
|
||||
data: payload,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
console.log(response.data)
|
||||
console.log(this.user.id)
|
||||
this.$router.push({name: "customerProfile", params: { id: this.card.user_id }});
|
||||
}
|
||||
if (response.data.error) {
|
||||
this.$router.push("/");
|
||||
}
|
||||
})
|
||||
},
|
||||
onSubmit() {
|
||||
let payload = {
|
||||
card_name: this.CreateCardForm.basicInfo.card_name,
|
||||
expiration_month: this.CreateCardForm.basicInfo.expiration_month,
|
||||
expiration_year: this.CreateCardForm.basicInfo.expiration_year,
|
||||
type_of_card: this.CreateCardForm.basicInfo.type_of_card,
|
||||
security_number: this.CreateCardForm.basicInfo.security_number,
|
||||
card_number: this.CreateCardForm.basicInfo.card_number,
|
||||
main_card: this.CreateCardForm.basicInfo.main_card,
|
||||
};
|
||||
this.editCard(payload);
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
207
src/pages/card/home.vue
Normal file
207
src/pages/card/home.vue
Normal file
@@ -0,0 +1,207 @@
|
||||
<template>
|
||||
<Header />
|
||||
<div class="flex">
|
||||
<div class="">
|
||||
<SideBar />
|
||||
</div>
|
||||
<div class=" w-full px-10 ">
|
||||
<div class="text-sm breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link :to="{ name: 'home' }">
|
||||
Home
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'customer' }">
|
||||
Customers
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<router-link :to="{ name: 'customerCreate' }">
|
||||
<button class="btn">Create Customer</button>
|
||||
</router-link>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Card Type</th>
|
||||
<th>Card Number</th>
|
||||
<th>Expiration</th>
|
||||
<th>Main Card</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- row 1 -->
|
||||
<tr v-for="card in cards" :key="card['id']">
|
||||
<td>
|
||||
<router-link :to="{ name: 'cardview', params: { id: card['id'] } }">
|
||||
{{ card['name_on_card'] }}
|
||||
</router-link>
|
||||
</td>
|
||||
<td>{{ card['type_of_card'] }}</td>
|
||||
<td>{{ card['name_on_card'] }}</td>
|
||||
<td>{{ card['expiration_month'] }} / {{ card['expiration_year'] }}</td>
|
||||
<td>{{ card['main_card'] }} </td>
|
||||
<td class="flex gap-5">
|
||||
<router-link :to="{ name: 'cardview', params: { id: card['id'] } }">
|
||||
Oil
|
||||
</router-link>
|
||||
<router-link :to="{ name: 'cardedit', params: { id: card['id'] } }">
|
||||
Service
|
||||
</router-link>
|
||||
|
||||
<div @click="removeCard(card['id'])">x
|
||||
Remove Card
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="flex justify-center" v-if="recordsLength > 9">
|
||||
<pagination @paginate="getPage" :records="recordsLength" v-model="page" :per-page="perPage" :options="options">
|
||||
</pagination>
|
||||
<div class="flex justify-center mb-10"> {{ recordsLength }} items Found</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Footer />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
import { defineComponent } from 'vue'
|
||||
import axios from 'axios'
|
||||
import { notify } from "@kyvg/vue3-notification";
|
||||
import authHeader from '../../services/auth.header'
|
||||
import Header from '../../layouts/headers/headerauth.vue'
|
||||
import PaginationComp from '../../components/pagination.vue'
|
||||
import SideBar from '../../layouts/sidebar/sidebar.vue'
|
||||
import Footer from '../../layouts/footers/footer.vue'
|
||||
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CardHome',
|
||||
|
||||
components: {
|
||||
Header,
|
||||
SideBar,
|
||||
Footer,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
token: null,
|
||||
user: null,
|
||||
customer: null,
|
||||
customer_id: null,
|
||||
cards: [],
|
||||
page: 1,
|
||||
perPage: 50,
|
||||
recordsLength: 0,
|
||||
options: {
|
||||
edgeNavigation: false,
|
||||
format: false,
|
||||
template: PaginationComp
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
$route() {
|
||||
this.getCustomer(this.$route.params.id);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.getPage(this.page)
|
||||
},
|
||||
methods: {
|
||||
getPage: function (page: any) {
|
||||
// we simulate an api call that fetch the records from a backend
|
||||
console.log("here")
|
||||
this.get_all_cards(page)
|
||||
},
|
||||
userStatus() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.user = response.data.user;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.user = null
|
||||
})
|
||||
},
|
||||
getCustomer(user_id: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/customer/" + user_id;
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.customer = response.data;
|
||||
this.customer_id = response.data.user_id;
|
||||
|
||||
})
|
||||
.catch(() => {
|
||||
notify({
|
||||
title: "Error",
|
||||
text: "Could not find customer",
|
||||
type: "error",
|
||||
});
|
||||
});
|
||||
},
|
||||
get_all_cards(page: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/payment/cards/all/' + page;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
this.cards = response.data
|
||||
console.log(response.data)
|
||||
})
|
||||
},
|
||||
|
||||
removeCard(card_id: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/payment/cards/remove/' + card_id;
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
|
||||
if (response.data.ok) {
|
||||
notify({
|
||||
title: "Deletion",
|
||||
text: "Card Removed",
|
||||
type: "success",
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
29
src/pages/card/routes.ts
Normal file
29
src/pages/card/routes.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
import CardHome from '../card/home.vue';
|
||||
import AddCardCreate from '../card/addcard.vue';
|
||||
import EditCard from "./editcard.vue";
|
||||
|
||||
|
||||
const cardRoutes = [
|
||||
{
|
||||
path: '/card',
|
||||
name: 'cardhome',
|
||||
component: CardHome,
|
||||
},
|
||||
|
||||
{
|
||||
path: '/card/add/:id',
|
||||
name: 'cardadd',
|
||||
component: AddCardCreate,
|
||||
},
|
||||
{
|
||||
path: '/card/edit/:id',
|
||||
name: 'cardedit',
|
||||
component: EditCard,
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
export default cardRoutes
|
||||
//sourceMappingURL=index.ts.map
|
||||
Reference in New Issue
Block a user