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