web: add 500x500 avatar cropper for profile and chat uploads
All checks were successful
CI / test (push) Successful in 28s

This commit is contained in:
2026-03-08 14:17:19 +03:00
parent 07e970e81f
commit 528778238b
3 changed files with 264 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import type { AuthSession, AuthUser } from "../chat/types";
import { useAuthStore } from "../store/authStore";
import { useUiStore } from "../store/uiStore";
import { AppPreferences, getAppPreferences, updateAppPreferences } from "../utils/preferences";
import { AvatarCropModal } from "./AvatarCropModal";
type SettingsPage = "main" | "general" | "notifications" | "privacy";
@@ -45,6 +46,7 @@ export function SettingsPanel({ open, onClose }: Props) {
avatarUrl: "",
});
const [profileAvatarUploading, setProfileAvatarUploading] = useState(false);
const [avatarCropFile, setAvatarCropFile] = useState<File | null>(null);
useEffect(() => {
if (!me) {
@@ -244,7 +246,7 @@ export function SettingsPanel({ open, onClose }: Props) {
if (!file) {
return;
}
void uploadAvatar(file);
setAvatarCropFile(file);
}}
type="file"
/>
@@ -605,6 +607,15 @@ export function SettingsPanel({ open, onClose }: Props) {
) : null}
</div>
</aside>
<AvatarCropModal
file={avatarCropFile}
onApply={(processedFile) => {
setAvatarCropFile(null);
void uploadAvatar(processedFile);
}}
onCancel={() => setAvatarCropFile(null)}
open={Boolean(avatarCropFile)}
/>
</div>,
document.body
);