|
@@ -2,6 +2,7 @@
|
|
|
import { onMount } from 'svelte';
|
|
import { onMount } from 'svelte';
|
|
|
import { fade } from 'svelte/transition';
|
|
import { fade } from 'svelte/transition';
|
|
|
import { goto } from '$app/navigation';
|
|
import { goto } from '$app/navigation';
|
|
|
|
|
+ import { getRequest } from '../../utils/api.js';
|
|
|
|
|
|
|
|
let result = [];
|
|
let result = [];
|
|
|
let stockQuery = '';
|
|
let stockQuery = '';
|
|
@@ -19,9 +20,8 @@
|
|
|
let query = stock === undefined ? '/api/stocks' : '/api/stocks?q=' + stock;
|
|
let query = stock === undefined ? '/api/stocks' : '/api/stocks?q=' + stock;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- const response = await fetch(import.meta.env.VITE_STOCKS_HOST + query, {
|
|
|
|
|
- method: 'GET'
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const response = await getRequest(import.meta.env.VITE_STOCKS_HOST + query, {}, null);
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
if (response.ok) {
|
|
|
return await response.json();
|
|
return await response.json();
|
|
@@ -87,108 +87,108 @@
|
|
|
{/if}
|
|
{/if}
|
|
|
|
|
|
|
|
<style>
|
|
<style>
|
|
|
- .filter-card {
|
|
|
|
|
- margin: 1rem 0;
|
|
|
|
|
- padding: 20px;
|
|
|
|
|
- background-color: #fafafa;
|
|
|
|
|
- border-radius: 12px;
|
|
|
|
|
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
|
|
|
|
|
- display: flex;
|
|
|
|
|
- justify-content: center;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .input-field {
|
|
|
|
|
- width: 100%;
|
|
|
|
|
- max-width: 100%;
|
|
|
|
|
- padding: 10px 15px;
|
|
|
|
|
- font-size: 1rem;
|
|
|
|
|
- border: 1px solid #ddd;
|
|
|
|
|
- border-radius: 8px;
|
|
|
|
|
- outline: none;
|
|
|
|
|
- transition: box-shadow 0.2s;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .input-field:focus {
|
|
|
|
|
- box-shadow: 0 0 0 2px #27ae60;
|
|
|
|
|
- border-color: #27ae60;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .result {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- flex-wrap: wrap;
|
|
|
|
|
- gap: 2rem;
|
|
|
|
|
- justify-content: center;
|
|
|
|
|
- padding-bottom: 2rem;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .card {
|
|
|
|
|
- background-color: #fafafa;
|
|
|
|
|
- border: 1px solid #eee;
|
|
|
|
|
- border-radius: 12px;
|
|
|
|
|
- width: 275px;
|
|
|
|
|
- height: 115px;
|
|
|
|
|
- padding: 1rem;
|
|
|
|
|
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
|
|
|
|
|
- transition: transform 0.2s ease;
|
|
|
|
|
- display: flex;
|
|
|
|
|
- flex-direction: column;
|
|
|
|
|
- justify-content: space-between;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .card:hover {
|
|
|
|
|
- transform: translateY(-8px);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .stock-info {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- justify-content: space-between;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- margin-bottom: 10px;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .stock-code {
|
|
|
|
|
- font-size: 1.5rem;
|
|
|
|
|
- font-weight: bold;
|
|
|
|
|
- color: #333;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .stock-name {
|
|
|
|
|
- font-size: 1.1rem;
|
|
|
|
|
- color: #555;
|
|
|
|
|
- text-align: right;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .stock-info:after {
|
|
|
|
|
- content: '';
|
|
|
|
|
- display: block;
|
|
|
|
|
- width: 100%;
|
|
|
|
|
- height: 1px;
|
|
|
|
|
- background-color: #ddd;
|
|
|
|
|
- margin-top: 10px;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .stock-details {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- justify-content: space-between;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- margin-top: 15px;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .stock-currency {
|
|
|
|
|
- font-size: 1rem;
|
|
|
|
|
- color: #888;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .stock-price {
|
|
|
|
|
- font-size: 1.5rem;
|
|
|
|
|
- font-weight: bold;
|
|
|
|
|
- color: #27ae60;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- p {
|
|
|
|
|
- text-align: center;
|
|
|
|
|
- color: #999;
|
|
|
|
|
- font-size: 1rem;
|
|
|
|
|
- margin-top: 2rem;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ .filter-card {
|
|
|
|
|
+ margin: 1rem 0;
|
|
|
|
|
+ padding: 20px;
|
|
|
|
|
+ background-color: #fafafa;
|
|
|
|
|
+ border-radius: 12px;
|
|
|
|
|
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .input-field {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ max-width: 100%;
|
|
|
|
|
+ padding: 10px 15px;
|
|
|
|
|
+ font-size: 1rem;
|
|
|
|
|
+ border: 1px solid #ddd;
|
|
|
|
|
+ border-radius: 8px;
|
|
|
|
|
+ outline: none;
|
|
|
|
|
+ transition: box-shadow 0.2s;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .input-field:focus {
|
|
|
|
|
+ box-shadow: 0 0 0 2px #27ae60;
|
|
|
|
|
+ border-color: #27ae60;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .result {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-wrap: wrap;
|
|
|
|
|
+ gap: 2rem;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ padding-bottom: 2rem;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .card {
|
|
|
|
|
+ background-color: #fafafa;
|
|
|
|
|
+ border: 1px solid #eee;
|
|
|
|
|
+ border-radius: 12px;
|
|
|
|
|
+ width: 275px;
|
|
|
|
|
+ height: 115px;
|
|
|
|
|
+ padding: 1rem;
|
|
|
|
|
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
|
|
|
|
|
+ transition: transform 0.2s ease;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .card:hover {
|
|
|
|
|
+ transform: translateY(-8px);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .stock-info {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ margin-bottom: 10px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .stock-code {
|
|
|
|
|
+ font-size: 1.5rem;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ color: #333;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .stock-name {
|
|
|
|
|
+ font-size: 1.1rem;
|
|
|
|
|
+ color: #555;
|
|
|
|
|
+ text-align: right;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .stock-info:after {
|
|
|
|
|
+ content: '';
|
|
|
|
|
+ display: block;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 1px;
|
|
|
|
|
+ background-color: #ddd;
|
|
|
|
|
+ margin-top: 10px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .stock-details {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ margin-top: 15px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .stock-currency {
|
|
|
|
|
+ font-size: 1rem;
|
|
|
|
|
+ color: #888;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .stock-price {
|
|
|
|
|
+ font-size: 1.5rem;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ color: #27ae60;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ p {
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+ color: #999;
|
|
|
|
|
+ font-size: 1rem;
|
|
|
|
|
+ margin-top: 2rem;
|
|
|
|
|
+ }
|
|
|
</style>
|
|
</style>
|