TASKS-1823 WebManager module

This commit is contained in:
Igor Martyniuk
2026-08-28 08:35:58 +00:00
parent fdb2cf3837
commit c93d8c025b
654 changed files with 26232 additions and 6075 deletions
+36
View File
@@ -0,0 +1,36 @@
# Account Settings Module
The Account Settings module provides the current admin user's profile settings screen. It lets the signed-in admin update profile fields and password, and view assigned roles.
## Source Map
| Area | Path |
| ------------------------- | ---------------------------------------------------------------------------------- |
| Frontend module | `apps/admin/src/core/AccountSettings/` |
| Frontend routes | `apps/admin/src/core/AccountSettings/config/routing.tsx` |
| Frontend translations | `apps/admin/src/core/AccountSettings/config/translation/` |
| Auth provider dependency | `apps/admin/src/core/Auth/providers/AuthProvider/` |
| Backend profile endpoint | `apps/backend/app/base_modules/Admin/controller/admin_controller.ts` |
| Backend profile validator | `apps/backend/app/base_modules/Admin/validators/admin_update_profile_validator.ts` |
## Documentation
| Page | Purpose |
| ------------------------- | --------------------------------------------------------- |
| [Frontend](./frontend.md) | Route, page, form, profile update flow, and translations. |
| [Backend](./backend.md) | Current-user profile endpoint and validation. |
## Main Capabilities
- Display current authenticated admin profile.
- Update first name, last name, email, status, and optional password.
- Show assigned roles.
- Crop and stage an avatar image in the form UI.
- Use module-local translations through `ACCOUNT.*` keys.
## Ownership Rules
- AccountSettings owns the current-user profile UI.
- Auth owns current-user state, token storage, and API calls used by the profile page.
- Backend Admin owns profile persistence and validation.
- AccountSettings should not manage other admins; that belongs to AccessControl.
+69
View File
@@ -0,0 +1,69 @@
# Account Settings Backend
Account Settings does not have a separate backend base module. It uses the Admin backend module's current-user profile endpoint.
## Route
| Method | Route | Controller | Purpose |
| ------ | ----------------------- | ------------------------------- | ----------------------------------------- |
| `PUT` | `/admin/update-profile` | `AdminController.updateProfile` | Update the currently authenticated admin. |
Source:
```txt
apps/backend/app/base_modules/Admin/routes.ts
apps/backend/app/base_modules/Admin/controller/admin_controller.ts
```
The route uses `middleware.auth()`.
## Request Flow
```txt
PUT /admin/update-profile
-> auth middleware
-> AdminController.updateProfile
-> admin_update_profile_validator
-> current auth user merge/save
-> reload roles
-> query role_permissions
-> return { user, permissions }
```
## Validation
Validator:
```txt
apps/backend/app/base_modules/Admin/validators/admin_update_profile_validator.ts
```
Keep frontend validation compatible with this validator. Backend validation is authoritative.
## Response Contract
The endpoint returns the same shape consumed by Auth:
```ts
type GetUserResponse = {
user: {
id: number;
email: string;
firstName: string;
lastName: string;
status: string;
createdAt: string;
roles: Array<{ id: number; name: string }>;
};
permissions: string[];
};
```
AuthProvider maps this response into `AuthUser` and updates current user state.
## Ownership Rules
- AccountSettings owns the UI and form behavior.
- Auth owns `updateUser` and current user state updates.
- Backend Admin owns profile persistence and response shape.
- AccessControl owns managing other admin accounts.
+99
View File
@@ -0,0 +1,99 @@
# Account Settings Frontend
The frontend module implements the current admin profile settings page.
Source: `apps/admin/src/core/AccountSettings/`
## Directory Structure
```txt
AccountSettings/
config/ Routes, messages, translations.
pages/ Profile route page.
view/
forms/ Profile form and form fields.
layouts/ Account layout.
```
## Routes
Frontend route config:
```txt
config/routing.tsx
```
Mounted module path:
```txt
/account/*
```
| Route | Page | Purpose |
| ------------------ | ------------- | ------------------------------- |
| `/account/profile` | `ProfilePage` | Current admin profile settings. |
The index route redirects to `/account/profile`.
## Profile Page
Main file:
```txt
pages/Profile/index.tsx
```
Responsibilities:
- Read the current user from `useAuth()`.
- Submit profile updates through `updateUser`.
- Map backend validation errors into form fields.
- Render assigned roles.
## Form
Profile form files:
```txt
view/forms/ProfileForm/Component.tsx
view/forms/ProfileForm/form.ts
view/forms/ProfileForm/fields/PasswordField.tsx
view/forms/ProfileForm/fields/AvatarCropperField.tsx
```
Password behavior:
- Password fields are hidden until toggled open.
- Password is optional.
- If provided, password must be at least 8 characters.
- If provided, confirmation must match.
Avatar behavior:
- The field supports local crop/preview UI.
- The form currently stages avatar data in the form value.
- Profile update payload strips avatar before calling `updateUser`.
## Auth Dependency
## Translations
Translations are module-local:
```txt
config/messages.ts
config/translation/en.json
config/translation/uk.json
```
Use only `ACCOUNT.*` keys inside this module.
## Common Change Guide
| Change | Start Here |
| ---------------------------- | ----------------------------------------------------------------------------- |
| Add a profile field | `ProfileForm/form.ts`, `ProfileForm/Component.tsx`, backend profile validator |
| Change password validation | `ProfileForm/form.ts` |
| Change avatar UI | `ProfileForm/fields/AvatarCropperField.tsx` |
| Change profile save behavior | `pages/Profile/index.tsx` and AuthProvider `updateUser` |
| Change translations | `config/translation/en.json` and `config/translation/uk.json` |