fixed type errors

This commit is contained in:
2024-03-22 19:06:49 -04:00
parent eef26b4951
commit e53ce70c17
7 changed files with 73 additions and 50 deletions

2
.npmrc Executable file
View File

@@ -0,0 +1,2 @@
engine-strict=true
resolution-mode=highest

13
src/lib/types/types.ts Normal file
View File

@@ -0,0 +1,13 @@
export type oilprice = {
ok: boolean
price: string;
}
export type company = {
ok: boolean
name: string;
telephone: string;
}

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"];
}
});

View File

@@ -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.