-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { ExitIcon } from "@radix-ui/react-icons"; | ||
import { ExternalLinkIcon } from "lucide-react"; | ||
|
||
import ExternalLink from "src/components/ExternalLink"; | ||
import SettingsHeader from "src/components/SettingsHeader"; | ||
import { | ||
Card, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "src/components/ui/card"; | ||
import { useToast } from "src/components/ui/use-toast"; | ||
import { useCSRF } from "src/hooks/useCSRF"; | ||
import { useInfo } from "src/hooks/useInfo"; | ||
import { request } from "src/utils/request"; | ||
|
||
export function AlbyAccount() { | ||
const { data: csrf } = useCSRF(); | ||
const { toast } = useToast(); | ||
const { mutate: refetchInfo } = useInfo(); | ||
|
||
const unlink = async () => { | ||
if ( | ||
!confirm( | ||
"Please log out at https://getalby.com, then click ok to continue." | ||
) | ||
) { | ||
return; | ||
} | ||
|
||
if ( | ||
!confirm("Are you sure you want to change the Alby Account for your hub?") | ||
) { | ||
return; | ||
} | ||
|
||
try { | ||
if (!csrf) { | ||
throw new Error("No CSRF token"); | ||
} | ||
await request("/api/alby/unlink-account", { | ||
method: "POST", | ||
headers: { | ||
"X-CSRF-Token": csrf, | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
await refetchInfo(); | ||
toast({ | ||
title: "Alby Account Unlinked", | ||
description: "Please login with another Alby Account", | ||
}); | ||
} catch (error) { | ||
toast({ | ||
title: "Unlink account failed", | ||
description: (error as Error).message, | ||
variant: "destructive", | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<SettingsHeader | ||
title="Alby Account" | ||
description="Manage your Alby Account" | ||
/> | ||
<ExternalLink | ||
to="https://getalby.com/settings" | ||
className="w-full flex flex-row items-center gap-2" | ||
> | ||
<Card className="w-full"> | ||
<CardHeader> | ||
<CardTitle>Your Alby Account</CardTitle> | ||
<CardDescription className="flex gap-2 items-center"> | ||
<ExternalLinkIcon className="w-4 h-4" /> Manage your Alby Account | ||
Settings | ||
</CardDescription> | ||
</CardHeader> | ||
</Card> | ||
</ExternalLink> | ||
<Card className="w-full cursor-pointer" onClick={unlink}> | ||
<CardHeader> | ||
<CardTitle>Change Alby Account</CardTitle> | ||
<CardDescription className="flex gap-2 items-center"> | ||
<ExitIcon className="w-4 h-4" /> Link your Hub to a different Alby | ||
Account | ||
</CardDescription> | ||
</CardHeader> | ||
</Card> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters