From 42665fffbb9b9cec7fc3f81a583767264aacb36a Mon Sep 17 00:00:00 2001 From: LandaMm Date: Sun, 25 May 2025 14:54:03 +0200 Subject: [PATCH] feat: handle account selection --- web/src/feature/AccountList/index.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/src/feature/AccountList/index.tsx b/web/src/feature/AccountList/index.tsx index 8bee291..9fc8820 100644 --- a/web/src/feature/AccountList/index.tsx +++ b/web/src/feature/AccountList/index.tsx @@ -1,7 +1,8 @@ import { useDbContext } from "@/context/db"; +import { useOAuthContext } from "@/context/oauth"; import { type LocalAccount, useAccountRepo } from "@/repository/account"; import { CirclePlus, User } from "lucide-react"; -import { useEffect, useState, type FC } from "react"; +import { useCallback, useEffect, useState, type FC } from "react"; import { Link } from "react-router-dom"; const AccountList: FC = () => { @@ -10,6 +11,15 @@ const AccountList: FC = () => { const repo = useAccountRepo(); const { connected } = useDbContext(); + const oauth = useOAuthContext(); + + const handleAccountSelect = useCallback( + (account: LocalAccount) => { + oauth.selectSession(account.access); + }, + [oauth] + ); + useEffect(() => { if (connected) repo.loadAll().then(setAccounts); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -46,6 +56,7 @@ const AccountList: FC = () => { {accounts.map((account) => (
handleAccountSelect(account)} className="flex flex-row items-center p-4 border-gray-200 dark:border-gray-700/65 border-b border-r-0 border-l-0 select-none cursor-pointer hover:bg-gray-50/50 dark:hover:bg-gray-800/10 transition-colors mb-0" >