Working calender/service

This commit is contained in:
2025-08-22 14:48:28 -04:00
parent 7eed45ab32
commit 4bcff598e6
9 changed files with 629 additions and 466 deletions

View File

@@ -234,13 +234,10 @@
</div>
</div>
<div class="col-span-12 ">
<hr class=" h-1 mx-auto my-4 bg-gray-800 border-0 rounded dark:bg-gray-400">
</div>
<div class="col-span-6 ">
<div class="grid grid-cols-12">
<div class="col-span-6 font-bold flex text-2xl">
@@ -269,7 +266,6 @@
Inspected
</div>
<div class="col-span-12 py-2 font-bold">Inside/Outside </div>
<div class="col-span-12 py-2 px-2 " v-if="customer_tank.outside_or_inside == true">
Inside
@@ -277,10 +273,8 @@
<div class="col-span-12 py-2 px-2 text-orange-600" v-else>
Outside
</div>
</div>
<div class="col-span-6 ">
<div class="grid grid-cols-12">
<div class="col-span-12 py-2 font-bold">Fill Location</div>
@@ -291,7 +285,6 @@
<div class="col-span-12 py-2 px-2">
{{ customer_tank.tank_size }}
</div>
</div>
</div>
</div>
@@ -344,13 +337,9 @@
<div v-if="card.expiration_month == 10">10</div>
<div v-if="card.expiration_month == 11">11</div>
<div v-if="card.expiration_month == 12">12</div>
<div class=" pl-1 pr-1">/ </div>
<div class=""> {{ card.expiration_year }} </div>
</div>
<div class="flex p-1 pl-4">
{{ card.zip_code }}
</div>
@@ -358,7 +347,6 @@
{{ card.security_number }}
</div>
<div class="flex justify-between">
<a @click.prevent="editCard(card.id)" class="cursor-pointer underline hover:text-blue-300">
Edit Card
</a>
@@ -393,11 +381,8 @@
<div v-if="card.expiration_month == 10">10</div>
<div v-if="card.expiration_month == 11">11</div>
<div v-if="card.expiration_month == 12">12</div>
<div class=" pl-1 pr-1">/ </div>
<div class=""> {{ card.expiration_year }} </div>
</div>
<div class="flex p-1 pl-4">
{{ card.zip_code }}
@@ -416,27 +401,22 @@
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- ====================================================== -->
<!-- ============== COMMENTS SECTION (FIXED LAYOUT) ============== -->
<!-- ====================================================== -->
<div class="col-span-6 px-4">
<div class="grid grid-cols-12">
<form class="rounded-md col-span-12" enctype="multipart/form-data" @submit.prevent="onSubmitSocial">
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Customer Comment</label>
<textarea v-model="CreateSocialForm.basicInfo.comment" rows="4"
class="textarea block p-2.5 w-full input-bordered " id="description" type="text"
placeholder="Leave a Customer Comment" />
</div>
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
<button class="btn btn-sm btn-secondary">
@@ -445,7 +425,6 @@
</div>
</form>
<div class="col-span-12">
<div v-for="comment in comments" :key="comment['id']">
<div class="grid grid-cols-12 bg-neutral my-5">
@@ -455,20 +434,16 @@
<div class="col-span-8">
</div>
<div class="col-span-1">
</div>
<div class="col-span-1">
<a href="" @click.prevent="deleteCustomerSocial(comment.id)" class="hover:text-blue-300">
Delete
</a>
</div>
<div class="col-span-12 p-5">
{{ comment.comment }}
</div>
</div>
</div>
</div>
</div>
@@ -478,67 +453,103 @@
<hr class=" h-1 mx-auto my-4 bg-gray-800 border-0 rounded dark:bg-gray-400">
</div>
<div class="col-span-12 p-5">
<div class="grid grid-cols-12">
<div class="col-span-12 font-bold flex text-2xl">Automatic Deliveries</div>
<div class="col-span-12 font-bold flex text-2xl mb-5">
Service Call History
</div>
</div>
<div class="grid grid-cols-12 bg-neutral">
<table class="table col-span-12">
<!-- head -->
<thead>
<div v-if="!serviceCalls || serviceCalls.length === 0" class="text-center p-10 bg-base-200 rounded-md">
<p>No service call history found for this customer.</p>
</div>
<div v-else class="overflow-x-auto rounded-lg">
<table class="min-w-full divide-y divide-gray-700">
<thead class="bg-base-200">
<tr>
<th>id</th>
<th>Name</th>
<th>Address</th>
<th>Town</th>
<th>Gallons</th>
<th>Date</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Date</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Time</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Service Type</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Description</th>
</tr>
</thead>
<tbody>
<!-- row 1 -->
<tr v-for="auto in autodeliveries" :key="auto['id']">
<td>{{ auto['id'] }}</td>
<td>{{ auto['customer_full_name'] }}</td>
<td>{{ auto['customer_address'] }}</td>
<td>{{ auto['customer_town'] }}</td>
<td>{{ auto['gallons_delivered'] }}</td>
<td>{{ auto['fill_date'] }}</td>
<tbody class="bg-base-100 divide-y divide-gray-700">
<tr v-for="service in serviceCalls" :key="service.id" @click="openEditModal(service)" class="hover:bg-base-300 cursor-pointer">
<td class="px-6 py-4 whitespace-nowrap">{{ formatDate(service.scheduled_date) }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ formatTime(service.scheduled_date) }}</td>
<td class="px-6 py-4 whitespace-nowrap font-medium" :style="{ color: getServiceTypeColor(service.type_service_call) }">
{{ getServiceTypeName(service.type_service_call) }}
</td>
<td class="px-6 py-4 whitespace-normal text-sm">{{ service.description }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- ====================================================== -->
<!-- ============== AUTOMATIC DELIVERIES (FIXED) ============== -->
<!-- ====================================================== -->
<div class="col-span-12 p-5">
<div class="grid grid-cols-12">
<div class="col-span-12 font-bold flex text-2xl">Orders</div>
<div class="col-span-12 font-bold flex text-2xl mb-5">Automatic Deliveries</div>
</div>
<div class="grid grid-cols-12 bg-neutral">
<table class="table col-span-12">
<!-- head -->
<thead>
<div v-if="!autodeliveries || autodeliveries.length === 0" class="text-center p-10 bg-base-200 rounded-md">
<p>No automatic delivery history found.</p>
</div>
<div v-else class="overflow-x-auto rounded-lg">
<table class="min-w-full divide-y divide-gray-700">
<thead class="bg-base-200">
<tr>
<th>id</th>
<th>Status</th>
<th>Name</th>
<th>Address</th>
<th>Town</th>
<th>Gallons</th>
<th>Date</th>
<th></th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">id</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Address</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Town</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Gallons</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Date</th>
</tr>
</thead>
<tbody>
<!-- row 1 -->
<tr v-for="oil in deliveries" :key="oil['id']">
<td>{{ oil['id'] }}</td>
<td>
<tbody class="bg-base-100 divide-y divide-gray-700">
<tr v-for="auto in autodeliveries" :key="auto['id']" class="hover:bg-base-300">
<td class="px-6 py-4 whitespace-nowrap">{{ auto['id'] }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ auto['customer_full_name'] }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ auto['customer_address'] }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ auto['customer_town'] }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ auto['gallons_delivered'] }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ auto['fill_date'] }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- ====================================================== -->
<!-- ============== ORDERS TABLE (FIXED) ============== -->
<!-- ====================================================== -->
<div class="col-span-12 p-5">
<div class="grid grid-cols-12">
<div class="col-span-12 font-bold flex text-2xl mb-5">Orders</div>
</div>
<div v-if="!deliveries || deliveries.length === 0" class="text-center p-10 bg-base-200 rounded-md">
<p>No order history found.</p>
</div>
<div v-else class="overflow-x-auto rounded-lg">
<table class="min-w-full divide-y divide-gray-700">
<thead class="bg-base-200">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">id</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Status</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Address</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Town</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Gallons</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider">Date</th>
<th class="px-6 py-3 text-left text-xs font-medium text-base-content uppercase tracking-wider"></th>
</tr>
</thead>
<tbody class="bg-base-100 divide-y divide-gray-700">
<tr v-for="oil in deliveries" :key="oil['id']" class="hover:bg-base-300">
<td class="px-6 py-4 whitespace-nowrap">{{ oil['id'] }}</td>
<td class="px-6 py-4 whitespace-nowrap">
<div v-if="oil['delivery_status'] == 0">Waiting</div>
<div v-else-if="oil['delivery_status'] == 1">cancelled</div>
<div v-else-if="oil['delivery_status'] == 2">Out for Delivery</div>
@@ -547,55 +558,53 @@
<div v-else-if="oil['delivery_status'] == 10">Finalized</div>
<div v-else></div>
</td>
<td>{{ oil['customer_name'] }}</td>
<td>{{ oil['customer_address'] }}</td>
<td>{{ oil['customer_town'] }}</td>
<td v-if="oil['delivery_status'] != 10">
<td class="px-6 py-4 whitespace-nowrap">{{ oil['customer_name'] }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ oil['customer_address'] }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ oil['customer_town'] }}</td>
<td class="px-6 py-4 whitespace-nowrap" v-if="oil['delivery_status'] != 10">
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
<div v-else> {{ oil['gallons_ordered'] }}</div>
</td>
<td v-else>
<td class="px-6 py-4 whitespace-nowrap" v-else>
{{ oil['gallons_delivered'] }}
</td>
<td>{{ oil['expected_delivery_date'] }}</td>
<td class="flex gap-5 ">
<router-link :to="{ name: 'deliveryOrder', params: { id: oil['id'] } }">
<button class="btn btn-secondary btn-sm">View</button>
</router-link>
<router-link :to="{ name: 'deliveryEdit', params: { id: oil['id'] } }">
<button class="btn btn-sm btn-secondary">Edit</button>
</router-link>
<router-link :to="{ name: 'finalizeTicket', params: { id: oil['id'] } }"
v-if="oil['delivery_status'] != 10">
<button class="btn btn-secondary btn-sm">Finalize</button>
</router-link>
<router-link :to="{ name: 'Ticket', params: { id: oil['id'] } }">
<button class="btn btn-success btn-sm">Print Ticket</button>
</router-link>
<!--
<a @click.prevent="deleteCall(oil['id'])">
<button class="btn btn-sm btn-error">Delete</button>
</a> -->
<td class="px-6 py-4 whitespace-nowrap">{{ oil['expected_delivery_date'] }}</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<div class="flex gap-2">
<router-link :to="{ name: 'deliveryOrder', params: { id: oil['id'] } }">
<button class="btn btn-secondary btn-sm">View</button>
</router-link>
<router-link :to="{ name: 'deliveryEdit', params: { id: oil['id'] } }">
<button class="btn btn-sm btn-secondary">Edit</button>
</router-link>
<router-link :to="{ name: 'finalizeTicket', params: { id: oil['id'] } }"
v-if="oil['delivery_status'] != 10">
<button class="btn btn-secondary btn-sm">Finalize</button>
</router-link>
<router-link :to="{ name: 'Ticket', params: { id: oil['id'] } }">
<button class="btn btn-success btn-sm">Print Ticket</button>
</router-link>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<Footer />
<ServiceEditModal
v-if="selectedServiceForEdit"
:service="selectedServiceForEdit"
@close-modal="closeEditModal"
@save-changes="handleSaveChanges"
@delete-service="handleDeleteService"
/>
</template>
<script lang="ts">
@@ -609,120 +618,54 @@ import PaginationComp from "../../../components/pagination.vue";
import { notify } from "@kyvg/vue3-notification";
import "leaflet/dist/leaflet.css";
import { LMap, LTileLayer } from "@vue-leaflet/vue-leaflet";
import dayjs from 'dayjs';
import ServiceEditModal from '../../service/ServiceEditModal.vue';
interface ServiceCall {
id: number;
scheduled_date: string;
customer_name: string;
customer_address: string;
customer_town: string;
type_service_call: number;
description: string;
}
export default defineComponent({
name: 'CustomerProfile',
components: {
Header,
SideBar,
Footer,
LMap,
LTileLayer,
ServiceEditModal,
},
data() {
return {
zoom: 14,
token: null,
user: {
user_id: 0,
user_name: '',
confirmed: '',
},
user: { user_id: 0, user_name: '', confirmed: '' },
isTrue: true,
automatic_status: 0,
automatic_response: 0,
customer_last_delivery: '',
comments: [
{
id: 0,
created: '',
customer_id: 0,
poster_employee_id: 0,
comment: '',
}
],
CreateSocialForm: {
basicInfo: {
comment: '',
},
},
credit_cards: [
{
id: 0,
name_on_card: '',
main_card: false,
card_number: '',
expiration_month: 0,
type_of_card: '',
last_four_digits: '',
expiration_year: '',
zip_code: '',
security_number: '',
}
],
comments: [ { id: 0, created: '', customer_id: 0, poster_employee_id: 0, comment: '' } ],
CreateSocialForm: { basicInfo: { comment: '' } },
credit_cards: [ { id: 0, name_on_card: '', main_card: false, card_number: '', expiration_month: 0, type_of_card: '', last_four_digits: '', expiration_year: '', zip_code: '', security_number: '' } ],
credit_cards_count: 0,
customer: {
id: 0,
user_id: 0,
customer_first_name: '',
customer_last_name: '',
customer_town: '',
customer_address: '',
customer_state: 0,
customer_zip: '',
customer_apt: '',
customer_home_type: 0,
customer_phone_number: '',
customer_latitude: 0,
customer_longitude: 0,
correct_address: true,
account_number: '',
},
customer_description: {
id: 0,
customer_id: 0,
account_number: '',
company_id: '',
fill_location: 0,
description: '',
},
customer_tank: {
id: 0,
last_tank_inspection: null,
tank_status: false,
outside_or_inside: false,
tank_size: 0,
},
customer_stats: {
id: 0,
customer_id: 0,
total_calls: 0,
service_calls_total: 0,
service_calls_total_spent: 0,
service_calls_total_profit: 0,
oil_deliveries: 0,
oil_total_gallons: 0,
oil_total_spent: 0,
oil_total_profit: 0,
},
customer: { id: 0, user_id: 0, customer_first_name: '', customer_last_name: '', customer_town: '', customer_address: '', customer_state: 0, customer_zip: '', customer_apt: '', customer_home_type: 0, customer_phone_number: '', customer_latitude: 0, customer_longitude: 0, correct_address: true, account_number: '' },
customer_description: { id: 0, customer_id: 0, account_number: '', company_id: '', fill_location: 0, description: '' },
customer_tank: { id: 0, last_tank_inspection: null, tank_status: false, outside_or_inside: false, tank_size: 0 },
customer_stats: { id: 0, customer_id: 0, total_calls: 0, service_calls_total: 0, service_calls_total_spent: 0, service_calls_total_profit: 0, oil_deliveries: 0, oil_total_gallons: 0, oil_total_spent: 0, oil_total_profit: 0 },
deliveries: [],
autodeliveries: [],
delivery_page: 1,
delivery_perPage: 50,
delivery_recordsLength: 0,
delivery_options: {
delivery_edgeNavigation: false,
delivery_format: false,
delivery_template: PaginationComp
},
delivery_options: { delivery_edgeNavigation: false, delivery_format: false, delivery_template: PaginationComp },
serviceCalls: [] as ServiceCall[],
selectedServiceForEdit: null as ServiceCall | null,
}
},
created() {
@@ -735,7 +678,6 @@ export default defineComponent({
mounted() {
this.getPage(this.delivery_page)
},
watch: {
$route() {
this.getCustomer(this.$route.params.id);
@@ -743,7 +685,6 @@ export default defineComponent({
},
methods: {
getPage: function (page: any) {
// we simulate an api call that fetch the records from a backend
this.getCustomerDelivery(this.$route.params.id, page)
},
userStatus() {
@@ -759,11 +700,8 @@ export default defineComponent({
this.user = response.data.user;
}
})
.catch(() => {
})
.catch(() => { })
},
userAutomaticStatus(userid: any) {
let path = import.meta.env.VITE_BASE_URL + '/customer/automatic/status/' + userid;
axios({
@@ -773,17 +711,11 @@ export default defineComponent({
}).then((response: any) => {
this.automatic_status = response.data.status
if (this.automatic_status === 1){
this.getCustomerAutoDelivery(this.customer.id)
}
this.checktotalOil(this.customer.id)
})
},
userAutomatic(userid: any) {
let path = import.meta.env.VITE_BASE_URL + '/customer/automatic/assign/' + userid;
axios({
@@ -792,39 +724,20 @@ export default defineComponent({
headers: authHeader(),
}).then((response: any) => {
this.automatic_response = response.data.status
if (this.automatic_response == 1) {
this.$notify({
title: "Automatic Status",
text: 'Customer is now Automatic Customer',
type: 'Success'
});
this.$notify({ title: "Automatic Status", text: 'Customer is now Automatic Customer', type: 'Success' });
} else if (this.automatic_response == 2) {
this.$notify({
title: "Automatic Status",
text: 'Customer does not have a main credit card. Can not make automatic.',
type: 'Error'
});
this.$notify({ title: "Automatic Status", text: 'Customer does not have a main credit card. Can not make automatic.', type: 'Error' });
} else if (this.automatic_response == 3) {
this.$notify({
title: "Automatic Status",
text: 'Customer is now a Call in ',
type: 'Info' // Adjust type if needed
});
this.$notify({ title: "Automatic Status", text: 'Customer is now a Call in ', type: 'Info' });
} else {
this.$notify({
title: "Automatic Status",
text: 'Customer is now Manual Customer',
type: 'Warning' // Adjust type if needed
});
this.$notify({ title: "Automatic Status", text: 'Customer is now Manual Customer', type: 'Warning' });
}
this.getCustomer(this.$route.params.id);
this.getCreditCards(this.$route.params.id)
this.getCreditCardsCount(this.$route.params.id)
})
},
getCustomer(userid: any) {
let path = import.meta.env.VITE_BASE_URL + '/customer/' + userid;
axios({
@@ -832,7 +745,6 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.customer = response.data
this.checktotalOil(this.customer.id)
this.getCustomerTank(this.customer.id)
@@ -840,7 +752,7 @@ export default defineComponent({
this.getCustomerDescription(this.customer.id);
this.getCustomerStats(this.customer.id);
this.getCustomerLastDelivery(this.customer.id);
this.getServiceCalls(this.customer.id);
})
},
getCustomerLastDelivery(userid: any) {
@@ -850,9 +762,7 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.customer_last_delivery = response.data.date
})
},
getCustomerStats(userid: any) {
@@ -862,9 +772,7 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.customer_stats = response.data
})
},
checktotalOil(userid: any) {
@@ -874,7 +782,6 @@ export default defineComponent({
url: path,
headers: authHeader(),
})
},
getCustomerDescription(userid: any) {
let path = import.meta.env.VITE_BASE_URL + '/customer/description/' + userid;
@@ -883,7 +790,6 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.customer_description = response.data
})
},
@@ -895,10 +801,8 @@ export default defineComponent({
headers: authHeader(),
}).then((response: any) => {
this.customer_tank = response.data
})
},
getCreditCards(user_id: any) {
let path = import.meta.env.VITE_BASE_URL + '/payment/cards/' + user_id;
axios({
@@ -906,11 +810,9 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.credit_cards = response.data
})
},
getCreditCardsCount(user_id: any) {
let path = import.meta.env.VITE_BASE_URL + '/payment/cards/onfile/' + user_id;
axios({
@@ -918,11 +820,9 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.credit_cards_count = response.data.cards
})
},
getCustomerAutoDelivery(userid: any) {
let path = import.meta.env.VITE_AUTO_URL + '/delivery/all/profile/' + userid ;
axios({
@@ -933,7 +833,6 @@ export default defineComponent({
this.autodeliveries = response.data
})
},
getCustomerDelivery(userid: any, delivery_page: any) {
let path = import.meta.env.VITE_BASE_URL + '/delivery/customer/' + userid + '/' + delivery_page;
axios({
@@ -944,11 +843,9 @@ export default defineComponent({
this.deliveries = response.data
})
},
editCard(card_id: any) {
this.$router.push({ name: "cardedit", params: { id: card_id } });
},
removeCard(card_id: any) {
let path = import.meta.env.VITE_BASE_URL + '/payment/card/remove/' + card_id;
axios({
@@ -958,14 +855,9 @@ export default defineComponent({
}).then(() => {
this.getCreditCards(this.$route.params.id)
this.getCreditCardsCount(this.$route.params.id)
notify({
title: "Card Status",
text: "Card Removed",
type: "Success",
});
notify({ title: "Card Status", text: "Card Removed", type: "Success" });
})
},
deleteCall(delivery_id: any) {
let path = import.meta.env.VITE_BASE_URL + '/delivery/delete/' + delivery_id;
axios({
@@ -974,23 +866,13 @@ export default defineComponent({
headers: authHeader(),
}).then((response: any) => {
if (response.data.ok) {
notify({
title: "Success",
text: "deleted delivery",
type: "success",
});
notify({ title: "Success", text: "deleted delivery", type: "success" });
this.getPage(1)
} else {
notify({
title: "Failure",
text: "error deleting delivery",
type: "success",
});
notify({ title: "Failure", text: "error deleting delivery", type: "success" });
}
})
},
deleteCustomerSocial(comment_id: number) {
let path = import.meta.env.VITE_BASE_URL + '/social/delete/' + comment_id;
axios({
@@ -1002,8 +884,6 @@ export default defineComponent({
this.getCustomerSocial(this.customer.id, 1)
})
},
getCustomerSocial(userid: any, delivery_page: any) {
let path = import.meta.env.VITE_BASE_URL + '/social/posts/' + userid + '/' + delivery_page;
axios({
@@ -1014,13 +894,7 @@ export default defineComponent({
this.comments = response.data
})
},
CreateSocialComment(payload: {
comment: string;
poster_employee_id: number
}) {
CreateSocialComment(payload: { comment: string; poster_employee_id: number }) {
let path = import.meta.env.VITE_BASE_URL + "/social/create/" + this.customer.id;
axios({
method: "post",
@@ -1031,7 +905,6 @@ export default defineComponent({
})
.then((response: any) => {
if (response.data.ok) {
this.getCustomerSocial(this.customer.id, 1)
}
if (response.data.error) {
@@ -1040,14 +913,64 @@ export default defineComponent({
})
},
onSubmitSocial() {
let payload = {
comment: this.CreateSocialForm.basicInfo.comment,
poster_employee_id: this.user.user_id
};
let payload = { comment: this.CreateSocialForm.basicInfo.comment, poster_employee_id: this.user.user_id };
this.CreateSocialComment(payload);
},
getServiceCalls(customerId: number) {
let path = `${import.meta.env.VITE_BASE_URL}/service/for-customer/${customerId}`;
axios({
method: 'get',
url: path,
headers: authHeader(),
withCredentials: true,
}).then((response: any) => {
this.serviceCalls = response.data;
}).catch((error: any) => {
console.error("Failed to get customer service calls:", error);
});
},
openEditModal(service: ServiceCall) {
this.selectedServiceForEdit = service;
},
closeEditModal() {
this.selectedServiceForEdit = null;
},
async handleSaveChanges(updatedService: ServiceCall) {
try {
const path = `${import.meta.env.VITE_BASE_URL}/service/update/${updatedService.id}`;
await axios.put(path, updatedService, { headers: authHeader(), withCredentials: true });
this.getServiceCalls(this.customer.id);
this.closeEditModal();
} catch (error) {
console.error("Failed to save service call changes:", error);
}
},
async handleDeleteService(serviceId: number) {
try {
const path = `${import.meta.env.VITE_BASE_URL}/service/delete/${serviceId}`;
await axios.delete(path, { headers: authHeader(), withCredentials: true });
this.getServiceCalls(this.customer.id);
this.closeEditModal();
} catch (error) {
console.error("Failed to delete service call:", error);
}
},
formatDate(dateString: string): string {
if (!dateString) return 'N/A';
return dayjs(dateString).format('MMMM D, YYYY');
},
formatTime(dateString: string): string {
if (!dateString) return 'N/A';
return dayjs(dateString).format('h:mm A');
},
getServiceTypeName(typeId: number): string {
const typeMap: { [key: number]: string } = { 0: 'Tune-up', 1: 'No Heat', 2: 'Fix', 3: 'Tank Install', 4: 'Other' };
return typeMap[typeId] || 'Unknown Service';
},
getServiceTypeColor(typeId: number): string {
const colorMap: { [key: number]: string } = { 0: 'blue', 1: 'red', 2: 'green', 3: '#B58900', 4: 'black' };
return colorMap[typeId] || 'gray';
}
},
})
</script>