From d635ae0cbfed58668d9c9d0900fdfe4ef8fb5e2c Mon Sep 17 00:00:00 2001 From: projectmoon Date: Wed, 22 Mar 2023 16:48:07 +0100 Subject: [PATCH] Fancy looking accout selection table --- src/content-scripts/statement-page.tsx | 102 ++++++++++++++++++------- 1 file changed, 74 insertions(+), 28 deletions(-) diff --git a/src/content-scripts/statement-page.tsx b/src/content-scripts/statement-page.tsx index 198f782..cb865cd 100644 --- a/src/content-scripts/statement-page.tsx +++ b/src/content-scripts/statement-page.tsx @@ -1,5 +1,4 @@ import React from 'jsx-dom'; // necessary for react to work -import { Actions, GetAccountsReply } from '../background/messages'; import { Event, ClientEvents } from './events'; import * as background from './background'; import { Account } from '../landsbankinn/models'; @@ -9,32 +8,90 @@ interface AccountListProps { accounts: Array; } +const formatAccountNumber = (accountNumber: string) => accountNumber.substring(0, 4) + '-' + accountNumber.substring(4, 6) + '-' + accountNumber.substring(6, 12); + function AccountList(props: AccountListProps) { + const boxStyle = { display: 'inline-block', width: "100%", cursor: 'pointer' }; + const selectAllHandler = () => { + $(`#check-all`).prop('checked', !$('#check-all').prop('checked')); const checked = $('#check-all').prop('checked'); $('#account-export-list input[type="checkbox"]').prop('checked', checked); }; + const selectAccountHandler = (accountNumber: string) => () => + $(`#export-${accountNumber}`) + .prop('checked', !$(`#export-${accountNumber}`).prop('checked')); + const accountList = props.accounts.map(acct => -
  • - -   - -
  • + + + + + + + {formatAccountNumber(acct.accountNumber)} + + + + + {acct.name} + + + ); return (
    -
      -
    • - -   - -
    • - {accountList} -
    + + + + + + + + + + + + + + + {accountList} + +
    SelectAccount NumberAccount Name
    + + + Select All + + + N/A (Selects all accounts below) + +
    +
    + ); +} + +function ExportDiv(props: AccountListProps) { + return ( +
    +

    Download Transaction Statements

    +

    + Here, you can export statements from one or more of your accounts + over a specified date range. +

    + + + + + + + +
    +
    + +
    +
    ); } @@ -44,18 +101,7 @@ window.addEventListener('DOMContentLoaded', async () => { const response = await background.getAccounts(); if (response.error == null) { - const exportDiv = ( -
    -

    Download Transaction Statements

    -

    - Here, you can export statements from one or more of your accounts - over a specified date range. -

    - - -
    - ); - + const exportDiv = ; const contentDiv = document.querySelector( 'div[class="table-data content-box fill shadow"]' );