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 AccountCircle from "@material-symbols/svg-400/rounded/account_circle-fill.svg"; import Delete from "@material-symbols/svg-400/rounded/delete.svg"; import Logout from "@material-symbols/svg-400/rounded/logout.svg"; // import * as ImagePicker from "expo-image-picker"; import { type ComponentProps, useState } from "react"; import { useTranslation } from "react-i18next"; import { View } from "react-native"; import { rem, useYoshiki } from "yoshiki/native"; import type { KyooError, User } from "~/models"; import { Alert, Button, H1, Icon, Input, P, Popup, ts, usePopup, } from "~/primitives"; import { useAccount } from "~/providers/account-context"; import { useMutation } from "~/query"; import { deleteAccount, logout } from "../login/logic"; import { PasswordInput } from "../login/password-input"; import { Preference, SettingsContainer } from "./base"; // function dataURItoBlob(dataURI: string) { // const byteString = atob(dataURI.split(",")[1]); // const ab = new ArrayBuffer(byteString.length); // const ia = new Uint8Array(ab); // for (let i = 0; i < byteString.length; i++) { // ia[i] = byteString.charCodeAt(i); // } // return new Blob([ab], { type: "image/jpeg" }); // } export const AccountSettings = () => { const account = useAccount()!; const { css, theme } = useYoshiki(); const [setPopup, close] = usePopup(); const { t } = useTranslation(); const { mutateAsync } = useMutation({ method: "PATCH", path: ["auth", "users", "me"], compute: (update: Partial) => ({ body: update }), optimistic: (update) => ({ ...account, ...update, claims: { ...account.claims, ...update.claims }, }), invalidate: ["auth", "users", "me"], }); const { mutateAsync: editPassword } = useMutation({ method: "PATCH", path: ["auth", "users", "me", "password"], compute: (body: { oldPassword: string; newPassword: string }) => ({ body, }), invalidate: null, }); return (