Files
auburnoil_frontend/src/routes/ticket/[id]/+page.svelte
2024-06-20 10:43:30 -04:00

179 lines
7.0 KiB
Svelte

<!-- <script lang="ts">
import "../../../app.postcss";
import { onMount } from "svelte";
import { PUBLIC_BASE_URL } from "$env/static/public";
import type {
deliverytype,
customertype,
} from "$lib/types/types";
export let delivery_data: deliverytype;
export let customer_data: customertype;
let datatickets: any[] = [];
let user_id: string = "";
let dispatcher_notes: string = '';
onMount(async () => {
await fetch(PUBLIC_BASE_URL + "/delivery/" + data.ticketid, {
method: "get",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.json())
.then((result) => (delivery_data = result));
if (delivery_data["ok"] == true) {
let dispatcher_notes = delivery_data["dispatcher_notes"];
delivery_data.payment_type = delivery_data["payment_type"];
delivery_data.customer_address = delivery_data["customer_address"];
delivery_data.customer_town = delivery_data["customer_town"];
delivery_data.customer_state = delivery_data["customer_state"];
delivery_data.customer_zip = delivery_data["customer_zip"];
delivery_data.when_ordered = delivery_data["when_ordered"];
delivery_data.when_delivered = delivery_data["when_delivered"];
delivery_data.gallons_delivered = delivery_data["gallons_delivered"];
delivery_data.expected_delivery_date = delivery_data["expected_delivery_date"];
delivery_data.customer_price = delivery_data["customer_price"];
delivery_data.driver_employee_id = delivery_data["driver_employee_id"];
user_id = delivery_data["customer_id"];
console.log("going ...")
fetchCustomer(delivery_data["customer_id"]);
fetchData(delivery_data["customer_id"]);
}
});
// user info
async function fetchCustomer(user_id:string) {
console.log("fetching customer");
console.log(PUBLIC_BASE_URL + "/customer/" + user_id,)
const response = await fetch(PUBLIC_BASE_URL + "/customer/" + user_id, {
method: "get",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
})
const customer_data = await response.json();
console.log("poop")
};
// past deliveries
async function fetchData(user_id:string) {
const response = await fetch(PUBLIC_BASE_URL + "/delivery/past/" + user_id, {
method: "get",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
})
const jsonData = await response.json();
datatickets = jsonData;
}
</script>
<template>
{dispatcher_notes}
<div class="absolute" id="page">
<div class="p-10 max-w-5xl bg-white text-black">
<div class="grid grid-cols-12">
<div class="col-span-9">
<div class="grid grid-cols-12 pb-10">
<div class="col-span-2">#2 Heating</div>
<div class="col-span-2"></div>
<div class="col-span-2">0</div>
<div class="col-span-2">275</div>
<div class="col-span-2">
{customer_data.customer_phone_number}
</div>
</div>
<div class="grid grid-cols-12 pl-5 pb-10">
<div class="col-span-8">
{customer_data.customer_first_name}
{customer_data.customer_last_name}
</div>
<div class="col-span-4">
{customer_data.account_number}
</div>
<div class="col-span-12">
{customer_data.customer_address}
{customer_data.customer_apt}
</div>
<div class="col-span-3">
<div class="grid grid-cols-12">
<div class="col-span-5">
{delivery_data.customer_town}
</div>
<div class="col-span-3">
{delivery_data.customer_state}
</div>
<div class="col-span-4">
{delivery_data.customer_zip}
</div>
</div>
</div>
</div>
<div class="grid grid-cols-12 pl-5 pb-10">
<div class="col-span-12 pb-5">
{delivery_data.dispatcher_notes}
</div>
{#if delivery_data.payment_type == 0}
<div class="col-span-12">CASH</div>
{:else if delivery_data.payment_type == 1}
<div class="col-span-12">Credit Card</div>
{:else if delivery_data.payment_type == 2}
<div class="col-span-12">Credit Card/Cash</div>
{:else}{/if}
</div>
<div class="grid grid-cols-12">
{#each datatickets as item}
<div class="col-span-6 flex">
<div>
{item.when_delivered} - {item.gallons_delivered}
</div>
</div>
{/each}
</div>
</div>
<div class="col-span-3">
<div class="grid grid-cols-12">
<div class="col-span-12 h-7">
{delivery_data.when_ordered}
</div>
<div class="col-span-12 h-7">
{delivery_data.expected_delivery_date}
</div>
<div class="col-span-12 h-7"></div>
<div class="col-span-12 h-7">
{delivery_data.customer_price}
</div>
<div class="col-span-12 h-7">
{delivery_data.when_ordered}
</div>
<div class="col-span-12 h-7"></div>
<div class="col-span-12 h-7"></div>
<div class="col-span-12 h-7">
{delivery_data.driver_employee_id}
</div>
</div>
</div>
</div>
</div>
</div>
</template> -->