diff --git a/front/apps/web/src/pages/_app.tsx b/front/apps/web/src/pages/_app.tsx index 640f3220..c91f1c33 100755 --- a/front/apps/web/src/pages/_app.tsx +++ b/front/apps/web/src/pages/_app.tsx @@ -56,7 +56,6 @@ import { Tooltip } from "react-tooltip"; import { getCurrentAccount, readCookie, updateAccount } from "@kyoo/models/src/account-internal"; import { PortalProvider } from "@gorhom/portal"; import { ConnectionError } from "@kyoo/ui"; -import { getDefaultStore } from "jotai"; const font = Poppins({ weight: ["300", "400", "900"], subsets: ["latin"], display: "swap" }); diff --git a/front/packages/ui/src/settings/oidc.tsx b/front/packages/ui/src/settings/oidc.tsx index 49850068..8ee5bbd0 100644 --- a/front/packages/ui/src/settings/oidc.tsx +++ b/front/packages/ui/src/settings/oidc.tsx @@ -18,7 +18,14 @@ * along with Kyoo. If not, see . */ -import { QueryIdentifier, ServerInfo, ServerInfoP, useAccount, useFetch } from "@kyoo/models"; +import { + QueryIdentifier, + ServerInfo, + ServerInfoP, + queryFn, + useAccount, + useFetch, +} from "@kyoo/models"; import { Button, IconButton, Link, Skeleton, tooltip, ts } from "@kyoo/primitives"; import { useTranslation } from "react-i18next"; import { ImageBackground } from "react-native"; @@ -29,12 +36,22 @@ import { Preference, SettingsContainer } from "./base"; import Badge from "@material-symbols/svg-400/outlined/badge.svg"; import OpenProfile from "@material-symbols/svg-400/outlined/open_in_new.svg"; import Remove from "@material-symbols/svg-400/outlined/close.svg"; +import { useMutation, useQueryClient } from "@tanstack/react-query"; export const OidcSettings = () => { const account = useAccount()!; const { css } = useYoshiki(); const { t } = useTranslation(); const { data, error } = useFetch(OidcSettings.query()); + const queryClient = useQueryClient(); + const { mutateAsync: unlinkAccount } = useMutation({ + mutationFn: async (provider: string) => + await queryFn({ + path: ["auth", "login", provider], + method: "DELETE", + }), + onSettled: async () => await queryClient.invalidateQueries({ queryKey: ["auth", "me"] }), + }); return ( @@ -75,7 +92,7 @@ export const OidcSettings = () => { )} {}} + onPress={() => unlinkAccount(id)} {...tooltip(t("settings.oidc.delete", { provider: x.displayName }))} />