bugfixing
This commit is contained in:
parent
8972c0ecc2
commit
ce6733d1f9
@ -21,7 +21,7 @@ const transactionTypeMap = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const load = async ({ locals, params }) => {
|
export const load = async ({ locals, params }) => {
|
||||||
const { apiURL, apiKey } = locals;
|
const { apiURL, apiKey, user } = locals;
|
||||||
|
|
||||||
const getInsiderTrading = async () => {
|
const getInsiderTrading = async () => {
|
||||||
const postData = {
|
const postData = {
|
||||||
@ -40,6 +40,8 @@ export const load = async ({ locals, params }) => {
|
|||||||
|
|
||||||
let output = await response.json();
|
let output = await response.json();
|
||||||
|
|
||||||
|
output = user?.tier !== "Pro" ? output?.slice(0, 6) : output;
|
||||||
|
|
||||||
output = output?.reduce((acc, item) => {
|
output = output?.reduce((acc, item) => {
|
||||||
const newTransactionType =
|
const newTransactionType =
|
||||||
typeof transactionTypeMap[item?.transactionType] === "function"
|
typeof transactionTypeMap[item?.transactionType] === "function"
|
||||||
@ -48,11 +50,14 @@ export const load = async ({ locals, params }) => {
|
|||||||
|
|
||||||
// Only include items with 'Bought' or 'Sold'
|
// Only include items with 'Bought' or 'Sold'
|
||||||
if (newTransactionType === "Bought" || newTransactionType === "Sold") {
|
if (newTransactionType === "Bought" || newTransactionType === "Sold") {
|
||||||
acc.push({
|
const value = item?.securitiesTransacted * item?.price;
|
||||||
...item,
|
if (value > 0) {
|
||||||
transactionType: newTransactionType,
|
acc.push({
|
||||||
value: item?.securitiesTransacted * item?.price, // new key 'value'
|
...item,
|
||||||
});
|
transactionType: newTransactionType,
|
||||||
|
value: value, // new key 'value'
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
|
|||||||
@ -596,11 +596,11 @@
|
|||||||
<TableHeader {columns} {sortOrders} {sortData} />
|
<TableHeader {columns} {sortOrders} {sortData} />
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each data?.user?.tier === "Pro" ? insiderTradingList : insiderTradingList?.slice(0, 3) as item, index}
|
{#each insiderTradingList as item, index}
|
||||||
{#if item?.price > 0}
|
{#if item?.price > 0}
|
||||||
<tr
|
<tr
|
||||||
class="text-white odd:bg-[#27272A] {index + 1 ===
|
class="text-white odd:bg-[#27272A] {index + 1 ===
|
||||||
insiderTradingList?.slice(0, 3)?.length &&
|
insiderTradingList?.slice(0, 6)?.length &&
|
||||||
data?.user?.tier !== 'Pro'
|
data?.user?.tier !== 'Pro'
|
||||||
? 'opacity-[0.1]'
|
? 'opacity-[0.1]'
|
||||||
: ''}"
|
: ''}"
|
||||||
@ -677,7 +677,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if rawData?.length === insiderTradingList?.length}
|
{#if rawData?.length === insiderTradingList?.length && data?.user?.tier === "Pro"}
|
||||||
<label
|
<label
|
||||||
on:click={backToTop}
|
on:click={backToTop}
|
||||||
class="w-32 py-1.5 mt-10 hover:bg-white hover:bg-opacity-[0.05] cursor-pointer m-auto flex justify-center items-center border border-slate-800 rounded-full"
|
class="w-32 py-1.5 mt-10 hover:bg-white hover:bg-opacity-[0.05] cursor-pointer m-auto flex justify-center items-center border border-slate-800 rounded-full"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user