feat: handle agree ('allow') button click to select account for oauth auth
This commit is contained in:
@ -1,13 +1,24 @@
|
|||||||
import { type FC } from "react";
|
import { useCallback, type FC } from "react";
|
||||||
|
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
import { ArrowLeftRight, ChevronDown } from "lucide-react";
|
import { ArrowLeftRight, ChevronDown } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import Avatar from "@/feature/Avatar";
|
import Avatar from "@/feature/Avatar";
|
||||||
import { useAuth } from "@/store/auth";
|
import { useAuth } from "@/store/auth";
|
||||||
|
import { useOAuthContext } from "@/context/oauth";
|
||||||
|
|
||||||
const AuthorizePage: FC = () => {
|
const AuthorizePage: FC = () => {
|
||||||
const promptAccountSelection = useAuth((state) => state.deleteActiveAccount);
|
const promptAccountSelection = useAuth((state) => state.deleteActiveAccount);
|
||||||
|
const activeAccount = useAuth((state) => state.activeAccount);
|
||||||
|
|
||||||
|
const oauth = useOAuthContext();
|
||||||
|
|
||||||
|
const profile = useAuth((state) => state.profile);
|
||||||
|
|
||||||
|
const handleAgree = useCallback(() => {
|
||||||
|
if (!activeAccount) return;
|
||||||
|
oauth.selectSession(activeAccount.access);
|
||||||
|
}, [activeAccount, oauth]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -49,7 +60,7 @@ const AuthorizePage: FC = () => {
|
|||||||
<div className="flex flex-row items-center justify-center mb-6 gap-2">
|
<div className="flex flex-row items-center justify-center mb-6 gap-2">
|
||||||
<Avatar iconSize={28} className="w-9 h-9" />
|
<Avatar iconSize={28} className="w-9 h-9" />
|
||||||
<p className="text-sm text-gray-500 dark:text-gray-500">
|
<p className="text-sm text-gray-500 dark:text-gray-500">
|
||||||
qwer.009771@gmail.com
|
{profile?.email}
|
||||||
</p>
|
</p>
|
||||||
<Button
|
<Button
|
||||||
variant="icon"
|
variant="icon"
|
||||||
@ -101,7 +112,7 @@ const AuthorizePage: FC = () => {
|
|||||||
<div className="flex flex-row justify-between items-center">
|
<div className="flex flex-row justify-between items-center">
|
||||||
<Button variant="text">Cancel</Button>
|
<Button variant="text">Cancel</Button>
|
||||||
|
|
||||||
<Button>Allow</Button>
|
<Button onClick={handleAgree}>Allow</Button>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user