|
|
@ -1,20 +1,22 @@ |
|
|
|
<script> |
|
|
|
<script> |
|
|
|
import Icon from '@iconify/svelte'; |
|
|
|
import Icon from '@iconify/svelte'; |
|
|
|
import CardBG from "./CardBG.svelte"; |
|
|
|
import CardBG from "./CardBG.svelte"; |
|
|
|
import {createEventDispatcher, onMount} from 'svelte'; |
|
|
|
import {createEventDispatcher, onMount, getContext} from 'svelte'; |
|
|
|
import AccountCard from './AccountCard.svelte'; |
|
|
|
import AccountCard from './AccountCard.svelte'; |
|
|
|
import GreenButton from './GreenButton.svelte'; |
|
|
|
import GreenButton from './GreenButton.svelte'; |
|
|
|
import { fade, fly, slide } from 'svelte/transition'; |
|
|
|
import { fade, fly, slide } from 'svelte/transition'; |
|
|
|
import { flip } from 'svelte/animate'; |
|
|
|
import { flip } from 'svelte/animate'; |
|
|
|
import { logout, whoami } from './api'; |
|
|
|
import { logout, whoami, getaccountlist } from './api'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const token = getContext("token"); |
|
|
|
|
|
|
|
const user = getContext("user"); |
|
|
|
|
|
|
|
const accountsStore = getContext("accounts"); |
|
|
|
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher(); |
|
|
|
const dispatch = createEventDispatcher(); |
|
|
|
|
|
|
|
|
|
|
|
let fullname = ""; |
|
|
|
$: fullname = $user.user.fullname; |
|
|
|
let username = ""; |
|
|
|
$: username = $user.user.username; |
|
|
|
let email = ""; |
|
|
|
$: email = $user.user.email; |
|
|
|
let code = ""; |
|
|
|
|
|
|
|
let totalbalance = "2455.22"; |
|
|
|
let totalbalance = "2455.22"; |
|
|
|
let maincurrency = "RON"; |
|
|
|
let maincurrency = "RON"; |
|
|
|
let expandedAccount = null; |
|
|
|
let expandedAccount = null; |
|
|
@ -28,34 +30,45 @@ |
|
|
|
|
|
|
|
|
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
let accounts = [ |
|
|
|
$: accounts = $accountsStore ? $accountsStore.accounts.map(account => { |
|
|
|
{type:"RON Account", currency:"RON", balance:"420.42", iban:"RONFOX62188921", |
|
|
|
return { |
|
|
|
|
|
|
|
name: account.customName ? account.customName : `${account.accountType} Account`, |
|
|
|
|
|
|
|
currency: account.currency, |
|
|
|
|
|
|
|
balance: "123.12", |
|
|
|
|
|
|
|
iban: account.iban.replace(/(.{4})/g, "$1 "), |
|
|
|
transactions: [ |
|
|
|
transactions: [ |
|
|
|
{title:"Transaction Name#1", status:"PROCESSED", amount:"-45.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
{title:"Transaction Name#1", status:"PROCESSED", amount:"-45.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
{title:"Transaction Name#2", status:"PENDING", amount:"+25.00", time:"15:38 27/11/2021", type:"received"}, |
|
|
|
{title:"Transaction Name#2", status:"PENDING", amount:"+25.00", time:"15:38 27/11/2021", type:"received"}, |
|
|
|
{title:"Transaction Name#3", status:"CANCELLED", amount:"-469.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
], |
|
|
|
{title:"Transaction Name#1", status:"PROCESSED", amount:"-45.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
} |
|
|
|
{title:"Transaction Name#2", status:"PENDING", amount:"+25.00", time:"15:38 27/11/2021", type:"received"}, |
|
|
|
}) : []; |
|
|
|
{title:"Transaction Name#3", status:"CANCELLED", amount:"-469.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
// let accounts = [ |
|
|
|
{title:"Transaction Name#1", status:"PROCESSED", amount:"-45.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
// {type:"RON Account", currency:"RON", balance:"420.42", iban:"RONFOX62188921", |
|
|
|
{title:"Transaction Name#2", status:"PENDING", amount:"+25.00", time:"15:38 27/11/2021", type:"received"}, |
|
|
|
// transactions: [ |
|
|
|
{title:"Transaction Name#3", status:"CANCELLED", amount:"-469.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
// {title:"Transaction Name#1", status:"PROCESSED", amount:"-45.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
] |
|
|
|
// {title:"Transaction Name#2", status:"PENDING", amount:"+25.00", time:"15:38 27/11/2021", type:"received"}, |
|
|
|
}, |
|
|
|
// {title:"Transaction Name#3", status:"CANCELLED", amount:"-469.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
{type:"EUR Account", currency:"EUR", balance:"620,42", iban:"EURFOX62188921", |
|
|
|
// {title:"Transaction Name#1", status:"PROCESSED", amount:"-45.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
transactions: [ |
|
|
|
// {title:"Transaction Name#2", status:"PENDING", amount:"+25.00", time:"15:38 27/11/2021", type:"received"}, |
|
|
|
{title:"Transaction Name#2", status:"PENDING", amount:"+25.00", time:"15:38 27/11/2021", type:"received"}, |
|
|
|
// {title:"Transaction Name#3", status:"CANCELLED", amount:"-469.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
{title:"Transaction Name#1", status:"PROCESSED", amount:"-45.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
// {title:"Transaction Name#1", status:"PROCESSED", amount:"-45.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
{title:"Transaction Name#3", status:"CANCELLED", amount:"-469.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
// {title:"Transaction Name#2", status:"PENDING", amount:"+25.00", time:"15:38 27/11/2021", type:"received"}, |
|
|
|
] |
|
|
|
// {title:"Transaction Name#3", status:"CANCELLED", amount:"-469.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
}, |
|
|
|
// ] |
|
|
|
]; |
|
|
|
// }, |
|
|
|
|
|
|
|
// {type:"EUR Account", currency:"EUR", balance:"620,42", iban:"EURFOX62188921", |
|
|
|
|
|
|
|
// transactions: [ |
|
|
|
|
|
|
|
// {title:"Transaction Name#2", status:"PENDING", amount:"+25.00", time:"15:38 27/11/2021", type:"received"}, |
|
|
|
|
|
|
|
// {title:"Transaction Name#1", status:"PROCESSED", amount:"-45.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
|
|
|
|
// {title:"Transaction Name#3", status:"CANCELLED", amount:"-469.09", time:"15:38 27/11/2021", type:"send"}, |
|
|
|
|
|
|
|
// ] |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// ]; |
|
|
|
|
|
|
|
|
|
|
|
function dispatchLogout(){ |
|
|
|
function dispatchLogout(){ |
|
|
|
//todo: CHeck here |
|
|
|
//todo: CHeck here |
|
|
|
if (confirm("Log out?")) { |
|
|
|
if (confirm("Log out?")) { |
|
|
|
logout(sessionStorage.getItem("token")); |
|
|
|
logout($token); |
|
|
|
sessionStorage.removeItem("token"); |
|
|
|
|
|
|
|
dispatch("logOut",null); |
|
|
|
dispatch("logOut",null); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -92,27 +105,17 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMount( async function() { |
|
|
|
|
|
|
|
const token = sessionStorage.getItem("token"); |
|
|
|
|
|
|
|
const result = await whoami(token); |
|
|
|
|
|
|
|
if(result.status == "success") { |
|
|
|
|
|
|
|
fullname = result.user.fullname; |
|
|
|
|
|
|
|
email = result.user.email; |
|
|
|
|
|
|
|
username = result.user.username; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<main class="h-full flex flex-col items-stretch md:flex-row"> |
|
|
|
<main class="h-full flex flex-col items-stretch md:flex-row"> |
|
|
|
<div class="flex flex-col items-stretch max-h-full"> |
|
|
|
<div class="flex flex-col items-stretch max-h-full"> |
|
|
|
{#if expandedAccount || expandedAccount === 0} |
|
|
|
{#if expandedAccount || expandedAccount === 0} |
|
|
|
<AccountCard type={accounts[expandedAccount].type} currency={accounts[expandedAccount].currency} balance={accounts[expandedAccount].balance} iban={accounts[expandedAccount].iban} transactions={accounts[expandedAccount].transactions} isExpanded={true} on:expanded={() => expanded(null)}></AccountCard> |
|
|
|
<AccountCard name={accounts[expandedAccount].name} currency={accounts[expandedAccount].currency} balance={accounts[expandedAccount].balance} iban={accounts[expandedAccount].iban} transactions={accounts[expandedAccount].transactions} isExpanded={true} on:expanded={() => expanded(null)}></AccountCard> |
|
|
|
{:else} |
|
|
|
{:else} |
|
|
|
{#if showAllAccounts} |
|
|
|
{#if showAllAccounts} |
|
|
|
{#each accounts as account,i} |
|
|
|
{#each accounts as account,i} |
|
|
|
<div in:slide={{delay:500*i, duration:250*(i==0 ? 1 : i) }}> |
|
|
|
<div in:slide={{delay:500*i, duration:250*(i==0 ? 1 : i) }}> |
|
|
|
<AccountCard type={account.type} currency={account.currency} balance={account.balance} iban={account.iban} transactions={account.transactions} isExpanded={false} on:expanded={() => expanded(i)} on:createPopup></AccountCard> |
|
|
|
<AccountCard name={account.name} currency={account.currency} balance={account.balance} iban={account.iban} transactions={account.transactions} isExpanded={false} on:expanded={() => expanded(i)} on:createPopup></AccountCard> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{/each} |
|
|
|
{/each} |
|
|
|
{/if} |
|
|
|
{/if} |
|
|
|