bugfix: appointment hours now use the client timezone on UTC servers.

Logical API errors throw stable codes so users see translated messages instead of a generic bad request.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-19 01:43:50 +03:30
parent d6958b2e48
commit 80167c622c
38 changed files with 833 additions and 392 deletions

View File

@@ -7,16 +7,16 @@ description: Adds or migrates Dyolink API error codes with frontend translations
## Backend
1. Add to `ErrorCode` in `backend/src/common/errors/error-codes.ts`.
1. Add code to `ErrorCode` in `backend/src/common/errors/error-codes.ts`.
2. Throw with `AppException`:
```typescript
throw new AppException(ErrorCode.MY_CODE, HttpStatus.BAD_REQUEST, [
{ field: 'email', code: ErrorCode.VALIDATION_EMAIL_INVALID },
]);
throw new AppException(ErrorCode.MY_CODE, HttpStatus.BAD_REQUEST);
```
3. DTOs: `@IsEmail({}, { message: ErrorCode.VALIDATION_EMAIL_INVALID })`
3. DTOs: always `{ message: ErrorCode.X }` on class-validator decorators (do not rely on constraint-key fallbacks — e.g. `@Matches` is not always a mobile number).
4. Do **not** throw Nest `BadRequestException('English…')` — unmapped Nest exceptions fall back to HTTP status only (`BAD_REQUEST`, `AUTH_UNAUTHORIZED`, …).
5. Wall-clock rules (working hours, weekday): pass the client **IANA** `timeZone` and use `zoned-civil-time.ts`. Never `Date#getHours()` / `getDay()` on the UTC server.
## Frontend