fixed type errors
This commit is contained in:
13
src/lib/types/types.ts
Normal file
13
src/lib/types/types.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
export type oilprice = {
|
||||
ok: boolean
|
||||
price: string;
|
||||
}
|
||||
|
||||
export type company = {
|
||||
ok: boolean
|
||||
name: string;
|
||||
telephone: string;
|
||||
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import "../app.postcss";
|
||||
import { onMount } from "svelte";
|
||||
import { PUBLIC_BASE_URL } from "$env/static/public";
|
||||
import type { company, oilprice } from '$lib/types/types'
|
||||
|
||||
let oil_price = [];
|
||||
let price_of_oil = 0;
|
||||
let company = [];
|
||||
let tel_number = "";
|
||||
let company_name = "";
|
||||
export let company_data: company;
|
||||
export let oil_price_data: oilprice;
|
||||
|
||||
let price_of_oil: string = '';
|
||||
let company_name: string = '';
|
||||
let tel_number: string = '';
|
||||
|
||||
onMount(async () => {
|
||||
await fetch(PUBLIC_BASE_URL + "/info/price/oil", {
|
||||
@@ -18,10 +20,10 @@
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((result) => (oil_price = result));
|
||||
.then((result) => (oil_price_data = result));
|
||||
|
||||
if (oil_price["ok"] == true) {
|
||||
price_of_oil = oil_price["price"];
|
||||
if (oil_price_data["ok"] == true) {
|
||||
price_of_oil = oil_price_data["price"];
|
||||
}
|
||||
});
|
||||
onMount(async () => {
|
||||
@@ -33,11 +35,11 @@
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((result) => (company = result));
|
||||
.then((result) => (company_data = result));
|
||||
|
||||
if (company["ok"] == true) {
|
||||
company_name = company["name"];
|
||||
tel_number = company["telephone"];
|
||||
if (company_data["ok"] == true) {
|
||||
company_name = company_data["name"];
|
||||
tel_number = company_data["telephone"];
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import "../app.postcss";
|
||||
import { onMount } from "svelte";
|
||||
import { PUBLIC_BASE_URL } from "$env/static/public";
|
||||
import type { company, oilprice } from '$lib/types/types'
|
||||
|
||||
let oil_price = [];
|
||||
let price_of_oil = 0;
|
||||
let company = [];
|
||||
let tel_number = "";
|
||||
let company_name = "";
|
||||
export let company_data: company;
|
||||
export let oil_price_data: oilprice;
|
||||
|
||||
let price_of_oil: string = '';
|
||||
let company_name: string = '';
|
||||
let tel_number: string = '';
|
||||
|
||||
onMount(async () => {
|
||||
await fetch(PUBLIC_BASE_URL + "/info/price/oil", {
|
||||
@@ -18,11 +20,10 @@
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((result) => (oil_price = result));
|
||||
.then((result) => (oil_price_data = result));
|
||||
|
||||
if (oil_price["ok"] == true) {
|
||||
price_of_oil = oil_price["price"];
|
||||
console.log(price_of_oil);
|
||||
if (oil_price_data["ok"] == true) {
|
||||
price_of_oil = oil_price_data["price"];
|
||||
}
|
||||
});
|
||||
onMount(async () => {
|
||||
@@ -34,11 +35,11 @@
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((result) => (company = result));
|
||||
.then((result) => (company_data = result));
|
||||
|
||||
if (company["ok"] == true) {
|
||||
company_name = company["name"];
|
||||
tel_number = company["telephone"];
|
||||
if (company_data["ok"] == true) {
|
||||
company_name = company_data["name"];
|
||||
tel_number = company_data["telephone"];
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import "../../app.postcss";
|
||||
import { onMount } from "svelte";
|
||||
import { PUBLIC_BASE_URL } from "$env/static/public";
|
||||
import type { company, oilprice } from '$lib/types/types'
|
||||
|
||||
let oil_price = [];
|
||||
let price_of_oil = 0;
|
||||
let company = [];
|
||||
let tel_number = "";
|
||||
let company_name = "";
|
||||
export let company_data: company;
|
||||
export let oil_price_data: oilprice;
|
||||
|
||||
let price_of_oil: string = '';
|
||||
let company_name: string = '';
|
||||
let tel_number: string = '';
|
||||
|
||||
onMount(async () => {
|
||||
await fetch(PUBLIC_BASE_URL + "/info/price/oil", {
|
||||
@@ -18,10 +20,10 @@
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((result) => (oil_price = result));
|
||||
.then((result) => (oil_price_data = result));
|
||||
|
||||
if (oil_price["ok"] == true) {
|
||||
price_of_oil = oil_price["price"];
|
||||
if (oil_price_data["ok"] == true) {
|
||||
price_of_oil = oil_price_data["price"];
|
||||
}
|
||||
});
|
||||
onMount(async () => {
|
||||
@@ -33,11 +35,11 @@
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((result) => (company = result));
|
||||
.then((result) => (company_data = result));
|
||||
|
||||
if (company["ok"] == true) {
|
||||
company_name = company["name"];
|
||||
tel_number = company["telephone"];
|
||||
if (company_data["ok"] == true) {
|
||||
company_name = company_data["name"];
|
||||
tel_number = company_data["telephone"];
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
import "../../app.postcss";
|
||||
import { onMount } from "svelte";
|
||||
import { PUBLIC_BASE_URL } from "$env/static/public";
|
||||
|
||||
let company= [];
|
||||
let tel_number = "";
|
||||
let company_name = "";
|
||||
|
||||
import type { company, oilprice } from '$lib/types/types'
|
||||
|
||||
export let company_data: company;
|
||||
export let oil_price_data: oilprice;
|
||||
|
||||
let company_name: string = '';
|
||||
let tel_number: string = '';
|
||||
|
||||
onMount(async () => {
|
||||
await fetch(PUBLIC_BASE_URL + "/info/company", {
|
||||
method: "get",
|
||||
@@ -16,11 +19,11 @@
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((result) => (company = result));
|
||||
.then((result) => (company_data = result));
|
||||
|
||||
if (company["ok"] == true) {
|
||||
company_name = company["name"];
|
||||
tel_number = company["telephone"];
|
||||
if (company_data["ok"] == true) {
|
||||
company_name = company_data["name"];
|
||||
tel_number = company_data["telephone"];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { vitePreprocess } from "@sveltejs/kit/vite";
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
|
||||
|
||||
preprocess: [vitePreprocess()],
|
||||
kit: {
|
||||
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
|
||||
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
|
||||
|
||||
Reference in New Issue
Block a user