feat: avatar upload for profile/chats, fix session persistence on refresh

- Profile modal: upload/remove user avatar, edit name/bio/phone, change password
- Chat info panel: upload/remove chat photo (owner/admin only)
- Avatar component: render photo when available, fallback to initials
- Session fix: initialize Zustand store from localStorage to prevent redirect on refresh
- Backend: avatar upload endpoints for users and chats, migration adds avatar columns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ai
2026-05-22 11:55:11 +03:00
parent 01331d0263
commit 3f54dbf375
9 changed files with 421 additions and 45 deletions

View File

@@ -26,8 +26,15 @@ interface AppStore {
logout: () => void;
}
function loadUser(): User | null {
try {
const s = localStorage.getItem('jc_user');
return s ? JSON.parse(s) : null;
} catch { return null; }
}
export const useStore = create<AppStore>((set, get) => ({
user: null,
user: loadUser(),
chats: [],
activeChat: null,
messages: {},