major claude changes
This commit is contained in:
@@ -110,200 +110,185 @@
|
||||
</div>
|
||||
<Footer />
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
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'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Home',
|
||||
// Props
|
||||
const props = defineProps<{
|
||||
clickCount?: number
|
||||
}>()
|
||||
|
||||
components: {
|
||||
Header,
|
||||
SideBar,
|
||||
Footer,
|
||||
},
|
||||
props: {
|
||||
clickCount: Number
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
token: null,
|
||||
call_count:0,
|
||||
delivery_count: 0,
|
||||
delivery_count_delivered: 0,
|
||||
price_from_supplier: 0,
|
||||
today_oil_price: 0,
|
||||
price_for_employee: 0,
|
||||
price_same_day: 0,
|
||||
price_prime: 0,
|
||||
price_emergency: 0,
|
||||
user: {
|
||||
user_id: 0,
|
||||
user_name: '',
|
||||
},
|
||||
employee: {
|
||||
id: '',
|
||||
user_id: '',
|
||||
employee_last_name: "",
|
||||
employee_first_name: "",
|
||||
employee_town: "",
|
||||
employee_address: "",
|
||||
employee_apt: "",
|
||||
employee_zip: "",
|
||||
employee_birthday: "",
|
||||
employee_phone_number: "",
|
||||
employee_start_date: "",
|
||||
employee_end_date: "",
|
||||
employee_type: '',
|
||||
employee_state: '',
|
||||
},
|
||||
total_gallons_past_week: 0,
|
||||
total_profit_past_week: 0,
|
||||
total_deliveries: 0,
|
||||
// Router
|
||||
const router = useRouter()
|
||||
|
||||
|
||||
loaded: false,
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
this.userStatus()
|
||||
this.today_delivery_count()
|
||||
this.today_delivery_delivered()
|
||||
this.today_price_oil()
|
||||
this.totalgallonsweek()
|
||||
this.totalprofitweek()
|
||||
|
||||
|
||||
|
||||
},
|
||||
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.employeeStatus()
|
||||
} else {
|
||||
|
||||
localStorage.removeItem('user');
|
||||
this.$router.push('/login');
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
totalgallonsweek() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/stats/gallons/week';
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.total_gallons_past_week = response.data.total;
|
||||
|
||||
})
|
||||
},
|
||||
totalprofitweek() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/money/profit/week';
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.total_profit_past_week = response.data.total_profit;
|
||||
this.total_deliveries = response.data.total_deliveries;
|
||||
|
||||
})
|
||||
},
|
||||
employeeStatus() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/employee/userid/' + this.user.user_id;
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.employee = response.data;
|
||||
this.loaded = true;
|
||||
|
||||
})
|
||||
},
|
||||
total_calls() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/stats/call/count/today'
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.call_count = response.data.data;
|
||||
})
|
||||
},
|
||||
today_delivery_count() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/stats/delivery/count/today'
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.delivery_count = response.data.data;
|
||||
})
|
||||
},
|
||||
today_delivery_delivered() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/stats/delivery/count/delivered/today'
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
console.log(response.data)
|
||||
this.delivery_count_delivered = response.data.data;
|
||||
})
|
||||
},
|
||||
today_price_oil() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/info/price/oil'
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.price_from_supplier = response.data.price_from_supplier;
|
||||
this.today_oil_price = response.data.price_for_customer;
|
||||
this.price_for_employee = response.data.price_for_employee;
|
||||
this.price_same_day = response.data.price_same_day;
|
||||
this.price_prime = response.data.price_prime;
|
||||
this.price_emergency = response.data.price_emergency;
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
// Reactive data
|
||||
const token = ref(null)
|
||||
const call_count = ref(0)
|
||||
const delivery_count = ref(0)
|
||||
const delivery_count_delivered = ref(0)
|
||||
const price_from_supplier = ref(0)
|
||||
const today_oil_price = ref(0)
|
||||
const price_for_employee = ref(0)
|
||||
const price_same_day = ref(0)
|
||||
const price_prime = ref(0)
|
||||
const price_emergency = ref(0)
|
||||
const user = ref({
|
||||
user_id: 0,
|
||||
user_name: '',
|
||||
})
|
||||
</script>
|
||||
const employee = ref({
|
||||
id: '',
|
||||
user_id: '',
|
||||
employee_last_name: "",
|
||||
employee_first_name: "",
|
||||
employee_town: "",
|
||||
employee_address: "",
|
||||
employee_apt: "",
|
||||
employee_zip: "",
|
||||
employee_birthday: "",
|
||||
employee_phone_number: "",
|
||||
employee_start_date: "",
|
||||
employee_end_date: "",
|
||||
employee_type: '',
|
||||
employee_state: '',
|
||||
})
|
||||
const total_gallons_past_week = ref(0)
|
||||
const total_profit_past_week = ref(0)
|
||||
const total_deliveries = ref(0)
|
||||
const loaded = ref(false)
|
||||
|
||||
<style scoped></style>
|
||||
<script setup lang="ts">
|
||||
// Lifecycle
|
||||
onMounted(() => {
|
||||
userStatus()
|
||||
today_delivery_count()
|
||||
today_delivery_delivered()
|
||||
today_price_oil()
|
||||
totalgallonsweek()
|
||||
totalprofitweek()
|
||||
})
|
||||
|
||||
// Functions
|
||||
const 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) {
|
||||
user.value = response.data.user;
|
||||
employeeStatus()
|
||||
} else {
|
||||
localStorage.removeItem('user');
|
||||
router.push('/login');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const totalgallonsweek = () => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/stats/gallons/week';
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
total_gallons_past_week.value = response.data.total;
|
||||
})
|
||||
}
|
||||
|
||||
const totalprofitweek = () => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/money/profit/week';
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
total_profit_past_week.value = response.data.total_profit;
|
||||
total_deliveries.value = response.data.total_deliveries;
|
||||
})
|
||||
}
|
||||
|
||||
const employeeStatus = () => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/employee/userid/' + user.value.user_id;
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
employee.value = response.data;
|
||||
loaded.value = true;
|
||||
})
|
||||
}
|
||||
|
||||
const total_calls = () => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/stats/call/count/today'
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
call_count.value = response.data.data;
|
||||
})
|
||||
}
|
||||
|
||||
const today_delivery_count = () => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/stats/delivery/count/today'
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
delivery_count.value = response.data.data;
|
||||
})
|
||||
}
|
||||
|
||||
const today_delivery_delivered = () => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/stats/delivery/count/delivered/today'
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
console.log(response.data)
|
||||
delivery_count_delivered.value = response.data.data;
|
||||
})
|
||||
}
|
||||
|
||||
const today_price_oil = () => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/info/price/oil'
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
price_from_supplier.value = response.data.price_from_supplier;
|
||||
today_oil_price.value = response.data.price_for_customer;
|
||||
price_for_employee.value = response.data.price_for_employee;
|
||||
price_same_day.value = response.data.price_same_day;
|
||||
price_prime.value = response.data.price_prime;
|
||||
price_emergency.value = response.data.price_emergency;
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user