Add profile

This commit is contained in:
2025-08-22 15:51:32 +03:00
Unverified
parent 803f685180
commit deb02a5e95
25 changed files with 885 additions and 116 deletions
+28 -60
View File
@@ -1,63 +1,31 @@
// const fileInput = document.getElementById('fileInput') as HTMLInputElement;
// const preview = document.getElementById('preview') as HTMLImageElement;
// const preview1 = document.getElementById('preview1') as HTMLImageElement;
// const button = document.getElementById('uploadButton')!;
import type { Dialog } from "mdui/components/dialog";
import { loadProfileData } from './profile/editor';
import { loadProfilePicture, initializeProfileUpload } from "./profile/upload";
import { initializeProfileEditor } from './profile/editor';
// if (fileInput && preview && button) {
// // при клике по кнопке откроем диалог выбора файла
// button.addEventListener('click', () => {
// fileInput.click();
// });
// Handle profile form submission
const form = document.getElementById("profile-form")!;
const dialog = document.getElementById("profile-dialog") as Dialog;
// // при выборе файла — показываем его
// fileInput.addEventListener('change', () => {
// const file: File | null = fileInput.files ? fileInput.files[0] : null;
// if (file) {
// const reader: FileReader = new FileReader();
// reader.onload = (e: ProgressEvent<FileReader>) => {
// if (e.target && typeof e.target.result === 'string') {
// preview.src = e.target.result;
// preview1.src = e.target.result;
// preview.style.display = 'block';
// }
// };
// reader.readAsDataURL(file);
// }
// });
// }
form.addEventListener("submit", async (e) => {
e.preventDefault();
// TODO: Process form data if needed
// For now, just close the dialog
dialog.open = false;
});
// const textDiv = document.getElementById('text-nik')!;
// const input = document.getElementById('nik') as HTMLInputElement;
// const button1 = document.getElementById('change-name')!;
// button1.addEventListener('click', () => {
// if (input.style.display === 'none') {
// // Переводим в режим редактирования
// input.value = textDiv.textContent || '';
// textDiv.style.display = 'none';
// input.style.display = 'flex';
// } else {
// // Сохраняем изменения
// textDiv.textContent = input.value;
// textDiv.style.display = 'flex';
// input.style.display = 'none';
// }
// });
// const textDiv2 = document.getElementById('text-discr')!;
// const input2 = document.getElementById('discr') as HTMLInputElement;
// const button2 = document.getElementById('change-discription')!;
// button2.addEventListener('click', () => {
// if (input2.style.display === 'none') {
// // Переводим в режим редактирования
// input2.value = textDiv2.textContent || '';
// textDiv2.style.display = 'none';
// input2.style.display = 'flex';
// } else {
// // Сохраняем изменения
// textDiv2.textContent = input2.value;
// textDiv2.style.display = 'flex';
// input2.style.display = 'none';
// }
// });
// Initialize profile functionality after login
export function initializeProfile(): void {
// Initialize profile modules
initializeProfileUpload();
initializeProfileEditor();
// Load profile data
Promise.all([
loadProfilePicture(),
loadProfileData()
]).catch(error => {
console.error('Error initializing profile:', error);
});
}