feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,112 @@
import * as zod from 'zod';
import { joinPath } from './utils/joinPath';
import { isNonEmptyArray } from './utils/NonEmptyArray';
const MAX_ISSUES_IN_MESSAGE = 99;
const ISSUE_SEPARATOR = '; ';
const UNION_SEPARATOR = ', or ';
const PREFIX = 'Validation error';
const PREFIX_SEPARATOR = ': ';
export class ValidationError extends Error {
details;
name;
constructor(message, details = []) {
super(message);
this.details = details;
this.name = 'ZodValidationError';
}
toString() {
return this.message;
}
}
function getMessageFromZodIssue(props) {
const { issue, issueSeparator, unionSeparator, includePath } = props;
if (issue.code === 'invalid_union') {
return issue.unionErrors
.reduce((acc, zodError) => {
const newIssues = zodError.issues
.map((issue) => getMessageFromZodIssue({
issue,
issueSeparator,
unionSeparator,
includePath,
}))
.join(issueSeparator);
if (!acc.includes(newIssues)) {
acc.push(newIssues);
}
return acc;
}, [])
.join(unionSeparator);
}
if (includePath && isNonEmptyArray(issue.path)) {
if (issue.path.length === 1) {
const identifier = issue.path[0];
if (typeof identifier === 'number') {
return `${issue.message} at index ${identifier}`;
}
}
return `${issue.message} at "${joinPath(issue.path)}"`;
}
return issue.message;
}
function conditionallyPrefixMessage(reason, prefix, prefixSeparator) {
if (prefix !== null) {
if (reason.length > 0) {
return [prefix, reason].join(prefixSeparator);
}
return prefix;
}
if (reason.length > 0) {
return reason;
}
return PREFIX;
}
export function fromZodIssue(issue, options = {}) {
const { issueSeparator = ISSUE_SEPARATOR, unionSeparator = UNION_SEPARATOR, prefixSeparator = PREFIX_SEPARATOR, prefix = PREFIX, includePath = true, } = options;
const reason = getMessageFromZodIssue({
issue,
issueSeparator,
unionSeparator,
includePath,
});
const message = conditionallyPrefixMessage(reason, prefix, prefixSeparator);
return new ValidationError(message, [issue]);
}
export function fromZodError(zodError, options = {}) {
const { maxIssuesInMessage = MAX_ISSUES_IN_MESSAGE, issueSeparator = ISSUE_SEPARATOR, unionSeparator = UNION_SEPARATOR, prefixSeparator = PREFIX_SEPARATOR, prefix = PREFIX, includePath = true, } = options;
const reason = zodError.errors
.slice(0, maxIssuesInMessage)
.map((issue) => getMessageFromZodIssue({
issue,
issueSeparator,
unionSeparator,
includePath,
}))
.join(issueSeparator);
const message = conditionallyPrefixMessage(reason, prefix, prefixSeparator);
return new ValidationError(message, zodError.errors);
}
export const toValidationError = (options = {}) => (err) => {
if (err instanceof zod.ZodError) {
return fromZodError(err, options);
}
if (err instanceof Error) {
return new ValidationError(err.message);
}
return new ValidationError('Unknown error');
};
export function isValidationError(err) {
return err instanceof ValidationError;
}
export function isValidationErrorLike(err) {
return err instanceof Error && err.name === 'ZodValidationError';
}
export const errorMap = (issue, ctx) => {
const error = fromZodIssue({
...issue,
message: issue.message ?? ctx.defaultError,
});
return {
message: error.message,
};
};

View File

@@ -0,0 +1 @@
export { ValidationError, toValidationError, isValidationError, isValidationErrorLike, fromZodError, fromZodIssue, errorMap, } from './ValidationError';

View File

@@ -0,0 +1,3 @@
export function isNonEmptyArray(value) {
return value.length !== 0;
}

View File

@@ -0,0 +1,22 @@
const identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u;
export function joinPath(path) {
if (path.length === 1) {
return path[0].toString();
}
return path.reduce((acc, item) => {
if (typeof item === 'number') {
return acc + '[' + item.toString() + ']';
}
if (item.includes('"')) {
return acc + '["' + escapeQuotes(item) + '"]';
}
if (!identifierRegex.test(item)) {
return acc + '["' + item + '"]';
}
const separator = acc.length === 0 ? '' : '.';
return acc + separator + item;
}, '');
}
function escapeQuotes(str) {
return str.replace(/"/g, '\\"');
}