diff --git a/front/packages/ui/src/settings/account.tsx b/front/packages/ui/src/settings/account.tsx new file mode 100644 index 00000000..da33ea8d --- /dev/null +++ b/front/packages/ui/src/settings/account.tsx @@ -0,0 +1,276 @@ +/* + * Kyoo - A portable and vast media library solution. + * Copyright (c) Kyoo. + * + * See AUTHORS.md and LICENSE file in the project root for full license information. + * + * Kyoo is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * Kyoo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Kyoo. If not, see . + */ + +import { Account, KyooErrors, deleteAccount, logout, queryFn, useAccount } from "@kyoo/models"; +import { Alert, Button, H1, Icon, Input, P, Popup, ts, usePopup } from "@kyoo/primitives"; +import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { ComponentProps, useState } from "react"; +import { useTranslation } from "react-i18next"; +import { View } from "react-native"; +import { rem, useYoshiki } from "yoshiki/native"; +import { PasswordInput } from "../login/password-input"; +import { Preference, SettingsContainer } from "./base"; + +import Username from "@material-symbols/svg-400/outlined/badge.svg"; +import Mail from "@material-symbols/svg-400/outlined/mail.svg"; +import Password from "@material-symbols/svg-400/outlined/password.svg"; +import Delete from "@material-symbols/svg-400/rounded/delete.svg"; +import Logout from "@material-symbols/svg-400/rounded/logout.svg"; + +export const AccountSettings = () => { + const account = useAccount()!; + const { css, theme } = useYoshiki(); + const { t } = useTranslation(); + const [setPopup, close] = usePopup(); + + const queryClient = useQueryClient(); + const { mutateAsync } = useMutation({ + mutationFn: async (update: Partial) => + await queryFn({ + path: ["auth", "me"], + method: "PATCH", + body: update, + }), + onSettled: async () => await queryClient.invalidateQueries({ queryKey: ["auth", "me"] }), + }); + const { mutateAsync: editPassword } = useMutation({ + mutationFn: async (request: { newPassword: string; oldPassword: string }) => + await queryFn({ + path: ["auth", "password-reset"], + method: "POST", + body: request, + }), + }); + + return ( + +