|
|
@@ -11,6 +11,7 @@
|
|
|
let isLoading = true;
|
|
|
let showModal = false;
|
|
|
let searchStockResult = [];
|
|
|
+ let orderBy = "total";
|
|
|
|
|
|
onMount(() => {
|
|
|
const unsubscribe = authentication.subscribe(value => {
|
|
|
@@ -53,7 +54,14 @@
|
|
|
async function update(response) {
|
|
|
const portfolio = await response;
|
|
|
if (portfolio?.length > 0) {
|
|
|
- result = portfolio[0].stocks.sort((a, b) => a.code.localeCompare(b.code));
|
|
|
+ if (orderBy === "code") {
|
|
|
+ result = portfolio[0].stocks.sort((a, b) => a.code.localeCompare(b.code));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (orderBy === "total") {
|
|
|
+ result = portfolio[0].stocks.sort((a, b) => a.total - b.total);
|
|
|
+ }
|
|
|
+
|
|
|
totalValue = portfolio[0].totalValue;
|
|
|
totalAssets = portfolio[0].totalAssets;
|
|
|
portfolioId = portfolio[0].id;
|