Skip to content

Commit afa40b5

Browse files
authored
Feat: Add toggle switch to enable/disable accounts from main screen (#728)
## Summary - Adds a hover-visible toggle switch to each importer and exporter card on the main screen - Users can quickly include/exclude accounts from scraping without opening the settings dialog - Toggle is hidden during scraping, matching the behavior of other action buttons - Widened account cards (200px → 260px) and container (260px → 300px) to accommodate the new toggle Closes #713 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents 2f85ace + 4752542 commit afa40b5

8 files changed

Lines changed: 52 additions & 6 deletions

File tree

packages/renderer/src/components/accounts/Account.module.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
display: flex;
33
align-items: center;
44
height: 40px;
5-
width: 200px;
5+
width: 260px;
66
padding: 4px 12px;
77
border: 1px solid #ddcfcf;
88
box-sizing: border-box;
@@ -14,6 +14,16 @@
1414
cursor: pointer;
1515
}
1616

17+
.activeToggle {
18+
margin-left: 5px;
19+
display: none;
20+
cursor: pointer;
21+
}
22+
23+
.container:hover .activeToggle {
24+
display: block;
25+
}
26+
1727
.nameWrapper {
1828
display: flex;
1929
justify-content: flex-start;

packages/renderer/src/components/accounts/Account.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useMemo } from 'react';
22
import Badge from 'react-bootstrap/Badge';
3+
import Form from 'react-bootstrap/Form';
34
import piggyBank from '../../assets/piggy-bank.svg';
45
import { type Account as AccountType, type ExporterEndEvent } from '../../types';
56
import styles from './Account.module.css';
@@ -14,9 +15,11 @@ export interface ActionButton {
1415
interface AccountProps {
1516
account: AccountType;
1617
actionButtons?: ActionButton[];
18+
onToggleActive?: () => void;
19+
disabled?: boolean;
1720
}
1821

19-
export default function Account({ account, actionButtons }: AccountProps) {
22+
export default function Account({ account, actionButtons, onToggleActive, disabled }: AccountProps) {
2023
const containerStyles = useMemo(() => {
2124
const s = [styles.container];
2225
if (!account.active) s.push(styles.notActive);
@@ -48,6 +51,17 @@ export default function Account({ account, actionButtons }: AccountProps) {
4851
title={tooltipText}
4952
/>
5053
))}
54+
{onToggleActive && (
55+
<Form.Check
56+
className={styles.activeToggle}
57+
type="switch"
58+
checked={account.active}
59+
onChange={onToggleActive}
60+
disabled={disabled}
61+
title={account.active ? 'פעיל' : 'לא פעיל'}
62+
aria-label={account.active ? 'פעיל' : 'לא פעיל'}
63+
/>
64+
)}
5165
<StatusIndicator status={account.status} />
5266
{badgeNumberLog?.originalEvent && (
5367
<Badge className={styles.newTxnsIndicator} bg={'success'}>

packages/renderer/src/components/accounts/AccountsContainer.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.container {
22
height: 344px;
3-
width: 260px;
3+
width: 300px;
44
}
55

66
.title {

packages/renderer/src/components/accounts/Importers.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ function Importers({ accounts, isScraping, showModal, handleNewAccountClicked }:
2828
<Account
2929
key={account.id}
3030
account={account}
31+
onToggleActive={() => configStore.toggleImporterActive(account.id)}
32+
disabled={isScraping}
3133
actionButtons={getActionButtons(showModal, account, isScraping, () => {
3234
configStore.openResults(account.companyId as OutputVendorName);
3335
})}

packages/renderer/src/components/accounts/NewAccount.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
display: flex;
33
align-items: center;
44
height: 40px;
5-
width: 200px;
5+
width: 260px;
66
padding: 4px 12px;
77
border: 1px dashed #DDCFCF;
88
box-sizing: border-box;

packages/renderer/src/components/exporters/Exporters.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
import { type Account as AccountType, type ModalStatus } from '../../types';
1+
import { useConfigStore } from '../../store/ConfigStore';
2+
import { type Account as AccountType, type Exporter, type ModalStatus } from '../../types';
23
import Account from '../accounts/Account';
34
import { getActionButtons } from '../accounts/Importers';
45

56
interface ExporterProps {
6-
exporters: AccountType[];
7+
exporters: Exporter[];
78
isScraping: boolean;
89
showModal: (arg0: AccountType, arg1: ModalStatus) => void;
910
}
1011

1112
function Exporters({ exporters, isScraping, showModal }: ExporterProps) {
13+
const configStore = useConfigStore();
1214
return (
1315
<>
1416
{exporters.map((exporter) => (
1517
<Account
1618
key={exporter.id}
1719
account={exporter}
20+
onToggleActive={() => configStore.toggleExporterActive(exporter.companyId)}
21+
disabled={isScraping}
1822
actionButtons={getActionButtons(showModal, exporter, isScraping)}
1923
/>
2024
))}

packages/renderer/src/store/ConfigStore.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export class ConfigStore {
111111
!!exporter?.active,
112112
this.accountScrapingData.get(exporterKey as OutputVendorName),
113113
),
114+
companyId: exporterKey as OutputVendorName,
114115
options: exporter?.options || {},
115116
};
116117
});
@@ -211,6 +212,20 @@ export class ConfigStore {
211212
createOutputVendorConfigFromExporter(updatedExporterConfig);
212213
}
213214

215+
toggleImporterActive(id: string) {
216+
const account = this.config.scraping.accountsToScrape.find((a) => a.id === id);
217+
if (account) {
218+
account.active = !account.active;
219+
}
220+
}
221+
222+
toggleExporterActive(exporterName: OutputVendorName) {
223+
const exporter = this.config.outputVendors[exporterName];
224+
if (exporter) {
225+
exporter.active = !exporter.active;
226+
}
227+
}
228+
214229
async toggleShowBrowser() {
215230
this.config.scraping.showBrowser = !this.config.scraping.showBrowser;
216231
}

packages/renderer/src/types.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ export interface Importer extends Account {
192192
}
193193

194194
export interface Exporter extends Account {
195+
companyId: OutputVendorName;
195196
options: object;
196197
}
197198

0 commit comments

Comments
 (0)