ui fix
This commit is contained in:
parent
8261e79d4f
commit
692e6fe237
@ -5,7 +5,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = { ticker: data?.ticker, timePeriod: data?.timePeriod };
|
||||
const response = await fetch(apiURL + "/export-price-data", {
|
||||
const response = await fetch(apiURL + "/historical-price", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -709,6 +709,48 @@
|
||||
|
||||
async function exportData(timePeriod: string) {
|
||||
let exportList = [];
|
||||
|
||||
const response = await fetch("/api/export-price-data", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ ticker: $stockTicker, timePeriod: timePeriod }),
|
||||
});
|
||||
|
||||
exportList = await response.json();
|
||||
|
||||
exportList = exportList?.map(({ time, open, high, low, close, date }) => ({
|
||||
date: timePeriod === "max" ? time : date, // Use 'time' if timePeriod is "max", otherwise use 'date'
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
}));
|
||||
|
||||
const csvRows = [];
|
||||
|
||||
// Add headers row
|
||||
csvRows.push("time,open,high,low,close");
|
||||
|
||||
// Add data rows
|
||||
for (const row of exportList) {
|
||||
const csvRow = `${row.date},${row.open},${row.high},${row.low},${row.close}`;
|
||||
csvRows.push(csvRow);
|
||||
}
|
||||
|
||||
// Create CSV blob and trigger download
|
||||
const csv = csvRows.join("\n");
|
||||
const blob = new Blob([csv], { type: "text/csv" });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.setAttribute("hidden", "");
|
||||
a.setAttribute("href", url);
|
||||
a.setAttribute("download", `${$stockTicker}_${timePeriod}.csv`);
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
/*
|
||||
if (data?.user) {
|
||||
const response = await fetch("/api/historical-price", {
|
||||
method: "POST",
|
||||
@ -757,6 +799,7 @@
|
||||
style: "border-radius: 200px; background: #333; color: #fff;",
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
function updateClosePrice(data, extendPriceChart) {
|
||||
@ -1097,37 +1140,38 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Trigger asChild let:builder>
|
||||
<Button
|
||||
builders={[builder]}
|
||||
class="ml-auto border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
||||
>
|
||||
<span class="truncate text-white">Export</span>
|
||||
<svg
|
||||
class="-mr-1 ml-1 h-5 w-5 xs:ml-2 inline-block"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
style="max-width:40px"
|
||||
aria-hidden="true"
|
||||
{#if !$stockTicker.includes(".")}
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Trigger asChild let:builder>
|
||||
<Button
|
||||
builders={[builder]}
|
||||
class="ml-auto border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
|
||||
clip-rule="evenodd"
|
||||
></path>
|
||||
</svg>
|
||||
</Button>
|
||||
</DropdownMenu.Trigger>
|
||||
<DropdownMenu.Content
|
||||
class="w-fit h-fit max-h-72 overflow-y-auto scroller"
|
||||
>
|
||||
<DropdownMenu.Label class="text-gray-400">
|
||||
Historical Stock Price
|
||||
</DropdownMenu.Label>
|
||||
<DropdownMenu.Separator />
|
||||
<DropdownMenu.Group>
|
||||
<!--
|
||||
<span class="truncate text-white">Export</span>
|
||||
<svg
|
||||
class="-mr-1 ml-1 h-5 w-5 xs:ml-2 inline-block"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
style="max-width:40px"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
|
||||
clip-rule="evenodd"
|
||||
></path>
|
||||
</svg>
|
||||
</Button>
|
||||
</DropdownMenu.Trigger>
|
||||
<DropdownMenu.Content
|
||||
class="w-fit h-fit max-h-72 overflow-y-auto scroller"
|
||||
>
|
||||
<DropdownMenu.Label class="text-gray-400">
|
||||
Historical Stock Price
|
||||
</DropdownMenu.Label>
|
||||
<DropdownMenu.Separator />
|
||||
<DropdownMenu.Group>
|
||||
<!--
|
||||
<DropdownMenu.Item on:click={exportData} class="cursor-pointer hover:bg-[#27272A]">
|
||||
<svg class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro' ? 'hidden' : ''}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#A3A3A3" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"/></svg>
|
||||
1 min
|
||||
@ -1141,11 +1185,11 @@
|
||||
15 min
|
||||
</DropdownMenu.Item>
|
||||
-->
|
||||
<DropdownMenu.Item
|
||||
on:click={() => exportData("30min")}
|
||||
class="cursor-pointer hover:bg-[#27272A]"
|
||||
>
|
||||
<!--<svg
|
||||
<DropdownMenu.Item
|
||||
on:click={() => exportData("30min")}
|
||||
class="cursor-pointer hover:bg-[#27272A]"
|
||||
>
|
||||
<!--<svg
|
||||
class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro'
|
||||
? 'hidden'
|
||||
: ''}"
|
||||
@ -1157,13 +1201,13 @@
|
||||
/></svg
|
||||
>
|
||||
-->
|
||||
30 min
|
||||
</DropdownMenu.Item>
|
||||
<DropdownMenu.Item
|
||||
on:click={() => exportData("1hour")}
|
||||
class="cursor-pointer hover:bg-[#27272A]"
|
||||
>
|
||||
<!--
|
||||
30 min
|
||||
</DropdownMenu.Item>
|
||||
<DropdownMenu.Item
|
||||
on:click={() => exportData("1hour")}
|
||||
class="cursor-pointer hover:bg-[#27272A]"
|
||||
>
|
||||
<!--
|
||||
<svg
|
||||
class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro'
|
||||
? 'hidden'
|
||||
@ -1176,17 +1220,18 @@
|
||||
/></svg
|
||||
>
|
||||
-->
|
||||
1 hour
|
||||
</DropdownMenu.Item>
|
||||
<DropdownMenu.Item
|
||||
on:click={() => exportData("max")}
|
||||
class="cursor-pointer hover:bg-[#27272A]"
|
||||
>
|
||||
1 day
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Group>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
1 hour
|
||||
</DropdownMenu.Item>
|
||||
<DropdownMenu.Item
|
||||
on:click={() => exportData("max")}
|
||||
class="cursor-pointer hover:bg-[#27272A]"
|
||||
>
|
||||
1 day
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Group>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
{/if}
|
||||
</div>
|
||||
<!--End Time Interval-->
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user