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