count_down_ac

This commit is contained in:
mohammad
2025-01-08 17:17:52 +03:00
parent cff8c4728c
commit 7a22bb4bc8
18 changed files with 779 additions and 99 deletions

View File

@ -1,8 +1,39 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:syncrow_app/features/auth/model/token.dart';
class Role {
final String uuid;
final DateTime createdAt;
final DateTime updatedAt;
final String type;
Role({
required this.uuid,
required this.createdAt,
required this.updatedAt,
required this.type,
});
factory Role.fromJson(Map<String, dynamic> json) {
return Role(
uuid: json['uuid'],
createdAt: DateTime.parse(json['createdAt']),
updatedAt: DateTime.parse(json['updatedAt']),
type: json['type'],
);
}
Map<String, dynamic> toJson() {
return {
'uuid': uuid,
'createdAt': createdAt.toIso8601String(),
'updatedAt': updatedAt.toIso8601String(),
'type': type,
};
}
}
class UserModel {
static String userUuidKey = 'userUuid';
final String? uuid;
@ -16,6 +47,7 @@ class UserModel {
final String? timeZone;
final String? regionUuid;
final bool? isAgreementAccepted;
final Role? role;
UserModel({
required this.uuid,
@ -27,8 +59,9 @@ class UserModel {
required this.isEmailVerified,
required this.regionUuid,
required this.isAgreementAccepted,
required this.regionName, // Add this line
required this.timeZone, // Add this line
required this.regionName,
required this.timeZone,
required this.role,
});
factory UserModel.fromJson(Map<String, dynamic> json) {
@ -41,13 +74,13 @@ class UserModel {
phoneNumber: json['phoneNumber'],
isEmailVerified: json['isEmailVerified'],
isAgreementAccepted: json['isAgreementAccepted'],
regionName: json['region']?['regionName'], // Extract regionName
timeZone: json['timeZone']?['timeZoneOffset'], // Extract regionName
regionName: json['region']?['regionName'],
timeZone: json['timeZone']?['timeZoneOffset'],
regionUuid: json['region']?['uuid'],
role: json['role'] != null ? Role.fromJson(json['role']) : null,
);
}
//uuid to json
//from token
factory UserModel.fromToken(Token token) {
Map<String, dynamic> tempJson = Token.decodeToken(token.accessToken);
return UserModel(
@ -62,6 +95,7 @@ class UserModel {
regionUuid: null,
regionName: tempJson['region']?['regionName'],
timeZone: tempJson['timezone']?['timeZoneOffset'],
role: tempJson['role'] != null ? Role.fromJson(tempJson['role']) : null,
);
}
@ -74,14 +108,18 @@ class UserModel {
Map<String, dynamic> toJson() {
return {
'id': uuid,
'uuid': uuid,
'email': email,
'lastName': lastName,
'firstName': firstName,
'photoUrl': profilePicture,
'lastName': lastName,
'profilePicture': profilePicture != null ? base64.encode(profilePicture!) : null,
'phoneNumber': phoneNumber,
'isEmailVerified': isEmailVerified,
'regionUuid': regionUuid,
'isAgreementAccepted': isAgreementAccepted,
'regionName': regionName,
'timeZone': timeZone,
'role': role?.toJson(),
};
}
}