save before flutter upgrade
This commit is contained in:
34
lib/models/billing/billing_process.dart
Normal file
34
lib/models/billing/billing_process.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class BillingProcess {
|
||||
BillingProcess({
|
||||
required this.billingProcessId,
|
||||
required this.createdAt,
|
||||
required this.createdBy,
|
||||
required this.status,
|
||||
required this.customersBilled,
|
||||
required this.totalBilled,
|
||||
});
|
||||
|
||||
int billingProcessId;
|
||||
DateTime createdAt;
|
||||
String createdBy;
|
||||
String status;
|
||||
int customersBilled;
|
||||
num totalBilled;
|
||||
|
||||
factory BillingProcess.fromJson(String str) => BillingProcess.fromMap(json.decode(str));
|
||||
|
||||
factory BillingProcess.fromMap(Map<String, dynamic> json) {
|
||||
BillingProcess billingProcess = BillingProcess(
|
||||
billingProcessId: json["billing_process_id"],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
createdBy: json['created_by'],
|
||||
status: json['status'],
|
||||
customersBilled: json['customers_billed'],
|
||||
totalBilled: json['total_billed'],
|
||||
);
|
||||
|
||||
return billingProcess;
|
||||
}
|
||||
}
|
||||
133
lib/models/configuration.dart
Normal file
133
lib/models/configuration.dart
Normal file
@@ -0,0 +1,133 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Configuration {
|
||||
Config? config;
|
||||
|
||||
Configuration({
|
||||
this.config,
|
||||
});
|
||||
|
||||
factory Configuration.fromJson(String str) => Configuration.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Configuration.fromMap(Map<String, dynamic> json) => Configuration(
|
||||
config: json["config"] == null ? null : Config.fromMap(json["config"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"config": config?.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
class Config {
|
||||
Mode? dark;
|
||||
Mode? light;
|
||||
Logos? logos;
|
||||
|
||||
Config({
|
||||
this.dark,
|
||||
this.light,
|
||||
this.logos,
|
||||
});
|
||||
|
||||
factory Config.fromJson(String str) => Config.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Config.fromMap(Map<String, dynamic> json) => Config(
|
||||
dark: json["dark"] == null ? null : Mode.fromMap(json["dark"]),
|
||||
light: json["light"] == null ? null : Mode.fromMap(json["light"]),
|
||||
logos: json["logos"] == null ? null : Logos.fromMap(json["logos"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"dark": dark?.toMap(),
|
||||
"light": light?.toMap(),
|
||||
"logos": logos?.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
class Mode {
|
||||
String? hintText;
|
||||
String? alternate;
|
||||
String? primaryText;
|
||||
String? primaryColor;
|
||||
String? tertiaryText;
|
||||
String? secondaryText;
|
||||
String? tertiaryColor;
|
||||
String? secondaryColor;
|
||||
String? primaryBackground;
|
||||
String? tertiaryBackground;
|
||||
String? secondaryBackground;
|
||||
|
||||
Mode({
|
||||
this.hintText,
|
||||
this.alternate,
|
||||
this.primaryText,
|
||||
this.primaryColor,
|
||||
this.tertiaryText,
|
||||
this.secondaryText,
|
||||
this.tertiaryColor,
|
||||
this.secondaryColor,
|
||||
this.primaryBackground,
|
||||
this.tertiaryBackground,
|
||||
this.secondaryBackground,
|
||||
});
|
||||
|
||||
factory Mode.fromJson(String str) => Mode.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Mode.fromMap(Map<String, dynamic> json) => Mode(
|
||||
hintText: json["hintText"],
|
||||
alternate: json["alternate"],
|
||||
primaryText: json["primaryText"],
|
||||
primaryColor: json["primaryColor"],
|
||||
tertiaryText: json["tertiaryText"],
|
||||
secondaryText: json["secondaryText"],
|
||||
tertiaryColor: json["tertiaryColor"],
|
||||
secondaryColor: json["secondaryColor"],
|
||||
primaryBackground: json["primaryBackground"],
|
||||
tertiaryBackground: json["tertiaryBackground"],
|
||||
secondaryBackground: json["secondaryBackground"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"hintText": hintText,
|
||||
"alternate": alternate,
|
||||
"primaryText": primaryText,
|
||||
"primaryColor": primaryColor,
|
||||
"tertiaryText": tertiaryText,
|
||||
"secondaryText": secondaryText,
|
||||
"tertiaryColor": tertiaryColor,
|
||||
"secondaryColor": secondaryColor,
|
||||
"primaryBackground": primaryBackground,
|
||||
"tertiaryBackground": tertiaryBackground,
|
||||
"secondaryBackground": secondaryBackground,
|
||||
};
|
||||
}
|
||||
|
||||
class Logos {
|
||||
String? logoColor;
|
||||
String? logoBlanco;
|
||||
|
||||
Logos({
|
||||
this.logoColor,
|
||||
this.logoBlanco,
|
||||
});
|
||||
|
||||
factory Logos.fromJson(String str) => Logos.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Logos.fromMap(Map<String, dynamic> json) => Logos(
|
||||
logoColor: json["logoColor"],
|
||||
logoBlanco: json["logoBlanco"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"logoColor": logoColor,
|
||||
"logoBlanco": logoBlanco,
|
||||
};
|
||||
}
|
||||
130
lib/models/content_manager/ad_by_genre.dart
Normal file
130
lib/models/content_manager/ad_by_genre.dart
Normal file
@@ -0,0 +1,130 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AdsByGenre {
|
||||
String genreName;
|
||||
int videoCount;
|
||||
int rowNumber;
|
||||
List<Video> videos;
|
||||
int genreId;
|
||||
dynamic genrePoster;
|
||||
String? storageCategoryImageFileName;
|
||||
bool isExpanded = false;
|
||||
AdsByGenre({
|
||||
required this.genreName,
|
||||
required this.videoCount,
|
||||
required this.rowNumber,
|
||||
required this.videos,
|
||||
required this.genreId,
|
||||
required this.genrePoster,
|
||||
required this.storageCategoryImageFileName,
|
||||
});
|
||||
|
||||
factory AdsByGenre.fromJson(String str) =>
|
||||
AdsByGenre.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory AdsByGenre.fromMap(Map<String, dynamic> json) => AdsByGenre(
|
||||
genreName: json["genre_name"],
|
||||
videoCount: json["video_count"],
|
||||
rowNumber: json["row_number"],
|
||||
videos: List<Video>.from(json["videos"].map((x) => Video.fromMap(x))),
|
||||
genreId: json["genre_id"],
|
||||
genrePoster: json["genre_poster"],
|
||||
storageCategoryImageFileName: json["poster_image_file"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"genre_name": genreName,
|
||||
"video_count": videoCount,
|
||||
"row_number": rowNumber,
|
||||
"videos": List<dynamic>.from(videos.map((x) => x.toMap())),
|
||||
"genre_id": genreId,
|
||||
"genre_poster": genrePoster,
|
||||
"poster_image_file": storageCategoryImageFileName,
|
||||
};
|
||||
}
|
||||
|
||||
class Video {
|
||||
String title;
|
||||
int points;
|
||||
dynamic status;
|
||||
dynamic urlAd;
|
||||
dynamic partner;
|
||||
int duration;
|
||||
String overview;
|
||||
int priority;
|
||||
int videoId;
|
||||
String videoUrl;
|
||||
List<String> categories;
|
||||
DateTime createdAt;
|
||||
String posterPath;
|
||||
bool videoStatus;
|
||||
dynamic expirationDate;
|
||||
String videoFileName;
|
||||
String posterFileName;
|
||||
|
||||
Video({
|
||||
required this.title,
|
||||
required this.points,
|
||||
required this.status,
|
||||
required this.urlAd,
|
||||
required this.partner,
|
||||
required this.duration,
|
||||
required this.overview,
|
||||
required this.priority,
|
||||
required this.videoId,
|
||||
required this.videoUrl,
|
||||
required this.categories,
|
||||
required this.createdAt,
|
||||
required this.posterPath,
|
||||
required this.videoStatus,
|
||||
required this.expirationDate,
|
||||
required this.videoFileName,
|
||||
required this.posterFileName,
|
||||
});
|
||||
|
||||
factory Video.fromJson(String str) => Video.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Video.fromMap(Map<String, dynamic> json) => Video(
|
||||
title: json["title"],
|
||||
points: json["points"],
|
||||
status: json["status"],
|
||||
urlAd: json["url_ad"],
|
||||
partner: json["partner"],
|
||||
duration: json["duration"],
|
||||
overview: json["overview"],
|
||||
priority: json["priority"],
|
||||
videoId: json["video_id"],
|
||||
videoUrl: json["video_url"],
|
||||
categories: List<String>.from(json["categories"].map((x) => x)),
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
posterPath: json["poster_path"],
|
||||
videoStatus: json["video_status"],
|
||||
expirationDate: json["expiration_date"],
|
||||
videoFileName: json["video_file_name"],
|
||||
posterFileName: json["poster_file_name"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"title": title,
|
||||
"points": points,
|
||||
"status": status,
|
||||
"url_ad": urlAd,
|
||||
"partner": partner,
|
||||
"duration": duration,
|
||||
"overview": overview,
|
||||
"priority": priority,
|
||||
"video_id": videoId,
|
||||
"video_url": videoUrl,
|
||||
"categories": List<dynamic>.from(categories.map((x) => x)),
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"poster_path": posterPath,
|
||||
"video_status": videoStatus,
|
||||
"expiration_date": expirationDate,
|
||||
"video_file_name": videoFileName,
|
||||
"poster_file_name": posterFileName,
|
||||
};
|
||||
}
|
||||
125
lib/models/content_manager/all_ads_one_table_model.dart
Normal file
125
lib/models/content_manager/all_ads_one_table_model.dart
Normal file
@@ -0,0 +1,125 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AllAdsOneTableModel {
|
||||
final int id;
|
||||
final int? rowNumber; // Opcional, para el campo row_number
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String overview;
|
||||
final String posterPath;
|
||||
final String title;
|
||||
final String video; // Corresponde a video_url
|
||||
final int durationVideo;
|
||||
final dynamic urlAd; // Añadido para url_ad
|
||||
final int priority;
|
||||
final bool videoStatus; // Cambiado de status text a videoStatus boolean
|
||||
final dynamic expirationDate;
|
||||
final int points;
|
||||
final String? videoFileName;
|
||||
final dynamic partner;
|
||||
final String posterFileName;
|
||||
final List<dynamic> categories;
|
||||
final List<Map<String, dynamic>>
|
||||
qrCodes; // Puede ser List<dynamic> o Map<String, dynamic>
|
||||
final int warningCount;
|
||||
|
||||
AllAdsOneTableModel({
|
||||
required this.id,
|
||||
this.rowNumber,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.overview,
|
||||
required this.posterPath,
|
||||
required this.title,
|
||||
required this.video,
|
||||
required this.durationVideo,
|
||||
this.urlAd, // Añadido
|
||||
required this.priority,
|
||||
required this.videoStatus, // Requerido y de tipo bool
|
||||
this.expirationDate,
|
||||
required this.points,
|
||||
this.videoFileName,
|
||||
this.partner,
|
||||
required this.posterFileName,
|
||||
required this.categories,
|
||||
required this.qrCodes,
|
||||
required this.warningCount,
|
||||
});
|
||||
|
||||
factory AllAdsOneTableModel.fromJson(String str) =>
|
||||
AllAdsOneTableModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory AllAdsOneTableModel.fromMap(Map<String, dynamic> json) {
|
||||
// Procesamiento de qrCodes similar al de CouponsModel
|
||||
final rawQrCodes = json["qr_codes"];
|
||||
|
||||
final parsedQrCodes = rawQrCodes is List
|
||||
? rawQrCodes
|
||||
.map((e) {
|
||||
if (e is String) {
|
||||
try {
|
||||
return Map<String, dynamic>.from(jsonDecode(e));
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
} else if (e is Map) {
|
||||
return Map<String, dynamic>.from(e);
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
})
|
||||
.toList()
|
||||
.cast<Map<String, dynamic>>() // 🔥 necesario sí o sí
|
||||
: [];
|
||||
|
||||
return AllAdsOneTableModel(
|
||||
id: json["video_id"] ?? json["id"],
|
||||
rowNumber: json["row_number"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
updatedAt: DateTime.parse(json["updated_at"]),
|
||||
overview: json["overview"],
|
||||
posterPath: json["poster_path"],
|
||||
title: json["title"],
|
||||
video: json["video_url"],
|
||||
durationVideo: json["duration_video"],
|
||||
urlAd: json["url_ad"], // Mapeo para url_ad
|
||||
priority: json["priority"],
|
||||
videoStatus: json["video_status"], // Mapeo para video_status
|
||||
expirationDate: json["expiration_date"],
|
||||
points: json["points"],
|
||||
videoFileName: json["video_file_name"],
|
||||
partner: json["partner"],
|
||||
posterFileName: json["poster_file_name"],
|
||||
categories: json["categories"] == null
|
||||
? []
|
||||
: List<dynamic>.from(json["categories"].map((x) => x)),
|
||||
qrCodes: parsedQrCodes.cast<Map<String, dynamic>>(),
|
||||
warningCount: json["warning_count"],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"video_id": id,
|
||||
"row_number": rowNumber,
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"updated_at": updatedAt.toIso8601String(),
|
||||
"overview": overview,
|
||||
"poster_path": posterPath,
|
||||
"title": title,
|
||||
"video_url": video,
|
||||
"duration_video": durationVideo,
|
||||
"url_ad": urlAd, // Añadido
|
||||
"priority": priority,
|
||||
"video_status": videoStatus,
|
||||
"expiration_date": expirationDate,
|
||||
"points": points,
|
||||
"video_file_name": videoFileName,
|
||||
"partner": partner,
|
||||
"poster_file_name": posterFileName,
|
||||
"categories": List<dynamic>.from(categories.map((x) => x)),
|
||||
"qr_codes": qrCodes,
|
||||
"warning_count": warningCount,
|
||||
};
|
||||
}
|
||||
83
lib/models/content_manager/all_books_one_table_model.dart
Normal file
83
lib/models/content_manager/all_books_one_table_model.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AllBooksOneTableModel {
|
||||
int rowNumber;
|
||||
int bookId;
|
||||
DateTime createdAt;
|
||||
String bookDescription;
|
||||
String title;
|
||||
String book;
|
||||
String size;
|
||||
String year;
|
||||
String? bookCover;
|
||||
int autorFk;
|
||||
int statusFk;
|
||||
String bookStatus;
|
||||
String autorFirstName;
|
||||
String autorLastName;
|
||||
String? autorFullName;
|
||||
List<String?> categories;
|
||||
|
||||
AllBooksOneTableModel({
|
||||
required this.rowNumber,
|
||||
required this.bookId,
|
||||
required this.createdAt,
|
||||
required this.bookDescription,
|
||||
required this.title,
|
||||
required this.book,
|
||||
required this.size,
|
||||
required this.year,
|
||||
required this.bookCover,
|
||||
required this.autorFk,
|
||||
required this.statusFk,
|
||||
required this.bookStatus,
|
||||
required this.autorFirstName,
|
||||
required this.autorLastName,
|
||||
required this.autorFullName,
|
||||
required this.categories,
|
||||
});
|
||||
|
||||
factory AllBooksOneTableModel.fromJson(String str) =>
|
||||
AllBooksOneTableModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory AllBooksOneTableModel.fromMap(Map<String, dynamic> json) =>
|
||||
AllBooksOneTableModel(
|
||||
rowNumber: json["row_number"],
|
||||
bookId: json["book_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
bookDescription: json["book_description"],
|
||||
title: json["title"],
|
||||
book: json["book"],
|
||||
size: json["size"],
|
||||
year: json["year"],
|
||||
bookCover: json["book_cover"],
|
||||
autorFk: json["autor_fk"],
|
||||
statusFk: json["status_fk"],
|
||||
bookStatus: json["book_status"],
|
||||
autorFirstName: json["autor_first_name"],
|
||||
autorLastName: json["autor_last_name"],
|
||||
autorFullName: json["autor_name"],
|
||||
categories: List<String?>.from(json["categories"].map((x) => x)),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"row_number": rowNumber,
|
||||
"book_id": bookId,
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"book_description": bookDescription,
|
||||
"title": title,
|
||||
"book": book,
|
||||
"size": size,
|
||||
"year": year,
|
||||
"book_cover": bookCover,
|
||||
"autor_fk": autorFk,
|
||||
"status_fk": statusFk,
|
||||
"book_status": bookStatus,
|
||||
"autor_first_name": autorFirstName,
|
||||
"autor_last_name": autorLastName,
|
||||
"autor_name": autorFullName,
|
||||
"categories": List<dynamic>.from(categories.map((x) => x)),
|
||||
};
|
||||
}
|
||||
69
lib/models/content_manager/book.dart
Normal file
69
lib/models/content_manager/book.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Book {
|
||||
int bookId;
|
||||
String title;
|
||||
String bookDescription;
|
||||
DateTime createdAt;
|
||||
String book;
|
||||
String bookCover;
|
||||
String size;
|
||||
String year;
|
||||
String bookStatus;
|
||||
int autorId;
|
||||
String autorFirstName;
|
||||
String? autorLastName;
|
||||
String category;
|
||||
|
||||
Book({
|
||||
required this.bookId,
|
||||
required this.title,
|
||||
required this.bookDescription,
|
||||
required this.createdAt,
|
||||
required this.book,
|
||||
required this.bookCover,
|
||||
required this.size,
|
||||
required this.year,
|
||||
required this.bookStatus,
|
||||
required this.autorId,
|
||||
required this.autorFirstName,
|
||||
required this.autorLastName,
|
||||
required this.category,
|
||||
});
|
||||
|
||||
factory Book.fromJson(String str) => Book.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Book.fromMap(Map<String, dynamic> json) => Book(
|
||||
bookId: json["book_id"],
|
||||
title: json["title"],
|
||||
bookDescription: json["book_description"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
book: json["book"],
|
||||
bookCover: json["book_cover"],
|
||||
size: json["size"],
|
||||
year: json["year"],
|
||||
bookStatus: json["book_status"],
|
||||
autorId: json["autor_id"],
|
||||
autorFirstName: json["autor_first_name"],
|
||||
autorLastName: json["autor_last_name"],
|
||||
category: json["category"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"book_id": bookId,
|
||||
"title": title,
|
||||
"book_description": bookDescription,
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"book": book,
|
||||
"book_cover": bookCover,
|
||||
"size": size,
|
||||
"year": year,
|
||||
"book_status": bookStatus,
|
||||
"autor_id": autorId,
|
||||
"autor_first_name": autorFirstName,
|
||||
"autor_last_name": autorLastName,
|
||||
"category": category,
|
||||
};
|
||||
}
|
||||
124
lib/models/content_manager/book_by_genre.dart
Normal file
124
lib/models/content_manager/book_by_genre.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class BooksByGenreModel {
|
||||
String genreName;
|
||||
int bookCount;
|
||||
int rowNumber;
|
||||
List<Book> books;
|
||||
int genreId;
|
||||
dynamic genrePoster;
|
||||
dynamic posterImageFile;
|
||||
bool isExpanded = false;
|
||||
|
||||
BooksByGenreModel({
|
||||
required this.genreName,
|
||||
required this.bookCount,
|
||||
required this.rowNumber,
|
||||
required this.books,
|
||||
required this.genreId,
|
||||
required this.genrePoster,
|
||||
required this.posterImageFile,
|
||||
});
|
||||
|
||||
factory BooksByGenreModel.fromJson(String str) =>
|
||||
BooksByGenreModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory BooksByGenreModel.fromMap(Map<String, dynamic> json) =>
|
||||
BooksByGenreModel(
|
||||
genreName: json["genre_name"],
|
||||
bookCount: json["book_count"],
|
||||
rowNumber: json["row_number"],
|
||||
books: List<Book>.from(json["books"].map((x) => Book.fromMap(x))),
|
||||
genreId: json["genre_id"],
|
||||
genrePoster: json["genre_poster"],
|
||||
posterImageFile: json["poster_image_file"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"genre_name": genreName,
|
||||
"book_count": bookCount,
|
||||
"row_number": rowNumber,
|
||||
"books": List<dynamic>.from(books.map((x) => x.toMap())),
|
||||
"genre_id": genreId,
|
||||
"genre_poster": genrePoster,
|
||||
"poster_image_file": posterImageFile,
|
||||
};
|
||||
}
|
||||
|
||||
class Book {
|
||||
String size;
|
||||
String year;
|
||||
String title;
|
||||
String status;
|
||||
int bookId;
|
||||
int autorId;
|
||||
String bookUrl;
|
||||
String overview;
|
||||
int statusId;
|
||||
String? bookCover;
|
||||
List<String> categories;
|
||||
DateTime createdAt;
|
||||
String autorLastName;
|
||||
String autorFirstName;
|
||||
String? autorFullName = '';
|
||||
|
||||
Book({
|
||||
required this.size,
|
||||
required this.year,
|
||||
required this.title,
|
||||
required this.status,
|
||||
required this.bookId,
|
||||
required this.autorId,
|
||||
required this.bookUrl,
|
||||
required this.overview,
|
||||
required this.statusId,
|
||||
required this.bookCover,
|
||||
required this.categories,
|
||||
required this.createdAt,
|
||||
required this.autorLastName,
|
||||
required this.autorFirstName,
|
||||
required this.autorFullName,
|
||||
});
|
||||
|
||||
factory Book.fromJson(String str) => Book.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Book.fromMap(Map<String, dynamic> json) => Book(
|
||||
size: json["size"],
|
||||
year: json["year"],
|
||||
title: json["title"],
|
||||
status: json["status"],
|
||||
bookId: json["book_id"],
|
||||
autorId: json["autor_id"],
|
||||
bookUrl: json["book_url"],
|
||||
overview: json["overview"],
|
||||
statusId: json["status_id"],
|
||||
bookCover: json["book_cover"],
|
||||
categories: List<String>.from(json["categories"].map((x) => x)),
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
autorLastName: json["autor_last_name"],
|
||||
autorFirstName: json["autor_first_name"],
|
||||
autorFullName: json["autor_name"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"size": size,
|
||||
"year": year,
|
||||
"title": title,
|
||||
"status": status,
|
||||
"book_id": bookId,
|
||||
"autor_id": autorId,
|
||||
"book_url": bookUrl,
|
||||
"overview": overview,
|
||||
"status_id": statusId,
|
||||
"book_cover": bookCover,
|
||||
"categories": List<dynamic>.from(categories.map((x) => x)),
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"autor_last_name": autorLastName,
|
||||
"autor_first_name": autorFirstName,
|
||||
"autor_name": autorFullName,
|
||||
};
|
||||
}
|
||||
30
lib/models/content_manager/category_model.dart
Normal file
30
lib/models/content_manager/category_model.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CategoryModel {
|
||||
int categoryId;
|
||||
DateTime createdAt;
|
||||
String name;
|
||||
|
||||
CategoryModel({
|
||||
required this.categoryId,
|
||||
required this.createdAt,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
factory CategoryModel.fromJson(String str) =>
|
||||
CategoryModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CategoryModel.fromMap(Map<String, dynamic> json) => CategoryModel(
|
||||
categoryId: json["category_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
name: json["name"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"category_id": categoryId,
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"name": name,
|
||||
};
|
||||
}
|
||||
122
lib/models/coupons_manager/coupons_manager.dart
Normal file
122
lib/models/coupons_manager/coupons_manager.dart
Normal file
@@ -0,0 +1,122 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CouponsModel {
|
||||
int rowNumber;
|
||||
int couponId;
|
||||
DateTime createdAt;
|
||||
DateTime updateAt;
|
||||
String title;
|
||||
String description;
|
||||
String termConditions;
|
||||
num discountValue;
|
||||
String discountTypeName;
|
||||
String discountTypeDescription;
|
||||
DateTime startDate;
|
||||
DateTime endDate;
|
||||
bool isActive;
|
||||
int usageLimit;
|
||||
String categoryName;
|
||||
bool categoryVisible;
|
||||
String categoryImageFile;
|
||||
bool videoRequired;
|
||||
dynamic couponImageFile;
|
||||
dynamic outLink;
|
||||
List<Map<String, dynamic>> qrCodes;
|
||||
|
||||
CouponsModel({
|
||||
required this.rowNumber,
|
||||
required this.couponId,
|
||||
required this.createdAt,
|
||||
required this.updateAt,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.termConditions,
|
||||
required this.discountValue,
|
||||
required this.discountTypeName,
|
||||
required this.discountTypeDescription,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
required this.isActive,
|
||||
required this.usageLimit,
|
||||
required this.categoryName,
|
||||
required this.categoryVisible,
|
||||
required this.categoryImageFile,
|
||||
required this.videoRequired,
|
||||
required this.couponImageFile,
|
||||
required this.outLink,
|
||||
required this.qrCodes,
|
||||
});
|
||||
|
||||
factory CouponsModel.fromMap(Map<String, dynamic> json) {
|
||||
// Aseguramos que qrCodes sea una lista de Map<String, dynamic>
|
||||
final rawQrCodes = json["qr_codes"];
|
||||
|
||||
final parsedQrCodes = rawQrCodes is List
|
||||
? rawQrCodes
|
||||
.map((e) {
|
||||
if (e is String) {
|
||||
try {
|
||||
return Map<String, dynamic>.from(jsonDecode(e));
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
} else if (e is Map) {
|
||||
return Map<String, dynamic>.from(e);
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
})
|
||||
.toList()
|
||||
.cast<Map<String, dynamic>>() // 🔥 necesario sí o sí
|
||||
: [];
|
||||
return CouponsModel(
|
||||
rowNumber: json["row_number"],
|
||||
couponId: json["coupon_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
updateAt: DateTime.parse(json["update_at"]),
|
||||
title: json["title"],
|
||||
description: json["description"],
|
||||
termConditions: json["term_conditions"],
|
||||
discountValue: json["discount_value"],
|
||||
discountTypeName: json["discount_type_name"],
|
||||
discountTypeDescription: json["discount_type_description"],
|
||||
startDate: DateTime.parse(json["start_date"]),
|
||||
endDate: DateTime.parse(json["end_date"]),
|
||||
isActive: json["is_active"],
|
||||
usageLimit: json["usage_limit"],
|
||||
categoryName: json["category_name"],
|
||||
categoryVisible: json["category_visible"],
|
||||
categoryImageFile: json["category_image_file"],
|
||||
videoRequired: json["video_required"],
|
||||
couponImageFile: json["coupon_image_file"],
|
||||
outLink: json["out_link"],
|
||||
qrCodes: parsedQrCodes.cast<Map<String, dynamic>>(),
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"row_number": rowNumber,
|
||||
"coupon_id": couponId,
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"update_at": updateAt.toIso8601String(),
|
||||
"title": title,
|
||||
"description": description,
|
||||
"term_conditions": termConditions,
|
||||
"discount_value": discountValue,
|
||||
"discount_type_name": discountTypeName,
|
||||
"discount_type_description": discountTypeDescription,
|
||||
"start_date": startDate.toIso8601String(),
|
||||
"end_date": endDate.toIso8601String(),
|
||||
"is_active": isActive,
|
||||
"usage_limit": usageLimit,
|
||||
"category_name": categoryName,
|
||||
"category_visible": categoryVisible,
|
||||
"category_image_file": categoryImageFile,
|
||||
"video_required": videoRequired,
|
||||
"coupon_image_file": couponImageFile,
|
||||
"out_link": outLink,
|
||||
"qr_codes": qrCodes,
|
||||
};
|
||||
}
|
||||
93
lib/models/crm/clientes_model.dart
Normal file
93
lib/models/crm/clientes_model.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class ClientesModel {
|
||||
int? customerId;
|
||||
String? firstName;
|
||||
String? lastName;
|
||||
String? email;
|
||||
String? telefono;
|
||||
String? zipcode;
|
||||
DateTime? createdAt;
|
||||
String? direccion;
|
||||
String? ciudad;
|
||||
String? estado;
|
||||
String? proximaActualizacion;
|
||||
String? creadoPor;
|
||||
String? imagen;
|
||||
int? diasDisponibles;
|
||||
int? id;
|
||||
String? empresa;
|
||||
int? qr;
|
||||
String? service;
|
||||
String? status;
|
||||
|
||||
ClientesModel({
|
||||
this.customerId,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.email,
|
||||
this.telefono,
|
||||
this.zipcode,
|
||||
this.createdAt,
|
||||
this.direccion,
|
||||
this.ciudad,
|
||||
this.estado,
|
||||
this.proximaActualizacion,
|
||||
this.creadoPor,
|
||||
this.imagen,
|
||||
this.diasDisponibles,
|
||||
this.id,
|
||||
this.empresa,
|
||||
this.qr,
|
||||
this.service,
|
||||
this.status,
|
||||
});
|
||||
|
||||
factory ClientesModel.fromJson(String str) => ClientesModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory ClientesModel.fromMap(Map<String, dynamic> json) => ClientesModel(
|
||||
customerId: json["customer_id"],
|
||||
firstName: json["first_name"],
|
||||
lastName: json["last_name"],
|
||||
email: json["email"],
|
||||
telefono: json["telefono"],
|
||||
zipcode: json["zipcode"],
|
||||
createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]),
|
||||
direccion: json["direccion"],
|
||||
ciudad: json["ciudad"],
|
||||
estado: json["estado"],
|
||||
proximaActualizacion: json["proxima_actualizacion"],
|
||||
creadoPor: json["creado_por"],
|
||||
imagen: json["imagen"],
|
||||
diasDisponibles: json["dias_disponibles"],
|
||||
id: json["id"],
|
||||
empresa: json["empresa"],
|
||||
qr: json["qr"],
|
||||
service: json["service"],
|
||||
status: json["status"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"customer_id": customerId,
|
||||
"first_name": firstName,
|
||||
"last_name": lastName,
|
||||
"email": email,
|
||||
"telefono": telefono,
|
||||
"zipcode": zipcode,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"direccion": direccion,
|
||||
"ciudad": ciudad,
|
||||
"estado": estado,
|
||||
"proxima_actualizacion": proximaActualizacion,
|
||||
"creado_por": creadoPor,
|
||||
"imagen": imagen,
|
||||
"dias_disponibles": diasDisponibles,
|
||||
"id": id,
|
||||
"empresa": empresa,
|
||||
"qr": qr,
|
||||
"service": service,
|
||||
"status": status,
|
||||
};
|
||||
}
|
||||
44
lib/models/customers/address.dart
Normal file
44
lib/models/customers/address.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:nethive_neo/models/state.dart';
|
||||
|
||||
class Address {
|
||||
Address({
|
||||
required this.id,
|
||||
required this.address1,
|
||||
required this.address2,
|
||||
required this.zipcode,
|
||||
required this.city,
|
||||
required this.stateFk,
|
||||
required this.state,
|
||||
required this.country,
|
||||
});
|
||||
|
||||
int id;
|
||||
String address1;
|
||||
String? address2;
|
||||
String zipcode;
|
||||
String city;
|
||||
int stateFk;
|
||||
StateAPI state;
|
||||
String country;
|
||||
|
||||
String get fullAddress => '$address1 $city, ${state.code} $zipcode $country';
|
||||
|
||||
factory Address.fromJson(String str) => Address.fromMap(json.decode(str));
|
||||
|
||||
factory Address.fromMap(Map<String, dynamic> json) {
|
||||
Address address = Address(
|
||||
id: json["address_id"],
|
||||
address1: json['address_1'],
|
||||
address2: json['address_2'],
|
||||
zipcode: json['zipcode'],
|
||||
city: json['city'],
|
||||
stateFk: json['state_fk'],
|
||||
state: StateAPI.fromMap(json['state']),
|
||||
country: json['country'],
|
||||
);
|
||||
|
||||
return address;
|
||||
}
|
||||
}
|
||||
31
lib/models/customers/bill_cycle.dart
Normal file
31
lib/models/customers/bill_cycle.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class BillCycle {
|
||||
BillCycle({
|
||||
required this.customerId,
|
||||
required this.day,
|
||||
required this.billDueDay,
|
||||
required this.graceDays,
|
||||
required this.frequency,
|
||||
});
|
||||
|
||||
int customerId;
|
||||
int day;
|
||||
int billDueDay;
|
||||
int graceDays;
|
||||
int frequency;
|
||||
|
||||
factory BillCycle.fromJson(String str) => BillCycle.fromMap(json.decode(str));
|
||||
|
||||
factory BillCycle.fromMap(Map<String, dynamic> json) {
|
||||
BillCycle billCycle = BillCycle(
|
||||
customerId: json["customer_id"],
|
||||
day: json['day'],
|
||||
billDueDay: json['bill_due_day'],
|
||||
graceDays: json['grace_days'],
|
||||
frequency: json['frequency'],
|
||||
);
|
||||
|
||||
return billCycle;
|
||||
}
|
||||
}
|
||||
33
lib/models/customers/credit_card.dart
Normal file
33
lib/models/customers/credit_card.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CreditCard {
|
||||
CreditCard({
|
||||
required this.creditCardId,
|
||||
required this.type,
|
||||
required this.token,
|
||||
required this.automatic,
|
||||
required this.customerFk,
|
||||
});
|
||||
|
||||
int creditCardId;
|
||||
String type;
|
||||
String token;
|
||||
bool automatic;
|
||||
int customerFk;
|
||||
|
||||
String get last4Digits => token.substring(token.length - 4);
|
||||
|
||||
factory CreditCard.fromJson(String str) => CreditCard.fromMap(json.decode(str));
|
||||
|
||||
factory CreditCard.fromMap(Map<String, dynamic> json) {
|
||||
CreditCard creditCard = CreditCard(
|
||||
creditCardId: json["credit_card_id"],
|
||||
type: json['type'] ?? 'Credit Card',
|
||||
token: json['token'],
|
||||
automatic: json['automatic'] ?? true,
|
||||
customerFk: json['customer_fk'],
|
||||
);
|
||||
|
||||
return creditCard;
|
||||
}
|
||||
}
|
||||
45
lib/models/customers/customer.dart
Normal file
45
lib/models/customers/customer.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Customer {
|
||||
Customer({
|
||||
required this.id,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.email,
|
||||
required this.createdAt,
|
||||
required this.status,
|
||||
required this.phoneNumber,
|
||||
required this.balance,
|
||||
this.image,
|
||||
});
|
||||
|
||||
int id;
|
||||
String firstName;
|
||||
String lastName;
|
||||
String email;
|
||||
DateTime createdAt;
|
||||
String status;
|
||||
String phoneNumber;
|
||||
num balance;
|
||||
String? image;
|
||||
|
||||
String get fullName => '$firstName $lastName';
|
||||
|
||||
factory Customer.fromJson(String str) => Customer.fromMap(json.decode(str));
|
||||
|
||||
factory Customer.fromMap(Map<String, dynamic> json) {
|
||||
Customer customer = Customer(
|
||||
id: json["customer_id"],
|
||||
firstName: json['first_name'],
|
||||
lastName: json['last_name'],
|
||||
email: json["email"],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
status: json['status'],
|
||||
phoneNumber: json['mobile_phone'],
|
||||
balance: json['balance'] ?? 0.00,
|
||||
image: json['image'],
|
||||
);
|
||||
|
||||
return customer;
|
||||
}
|
||||
}
|
||||
37
lib/models/customers/customer_dashboards.dart
Normal file
37
lib/models/customers/customer_dashboards.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CustomerDashboards {
|
||||
int? customerId;
|
||||
DateTime? createdAt;
|
||||
String? firstName;
|
||||
String? lastName;
|
||||
String? status;
|
||||
|
||||
CustomerDashboards({
|
||||
this.customerId,
|
||||
this.createdAt,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.status,
|
||||
});
|
||||
|
||||
factory CustomerDashboards.fromJson(String str) => CustomerDashboards.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CustomerDashboards.fromMap(Map<String, dynamic> json) => CustomerDashboards(
|
||||
customerId: json["customer_id"],
|
||||
createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]),
|
||||
firstName: json["first_name"],
|
||||
lastName: json["last_name"],
|
||||
status: json["status"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"customer_id": customerId,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"first_name": firstName,
|
||||
"last_name": lastName,
|
||||
"status": status,
|
||||
};
|
||||
}
|
||||
72
lib/models/customers/customer_details.dart
Normal file
72
lib/models/customers/customer_details.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:nethive_neo/models/models.dart';
|
||||
|
||||
class CustomerDetails {
|
||||
CustomerDetails({
|
||||
required this.id,
|
||||
required this.createdDate,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.email,
|
||||
required this.billingAddress,
|
||||
required this.status,
|
||||
required this.phoneNumber,
|
||||
required this.balance,
|
||||
this.image,
|
||||
required this.billCycle,
|
||||
required this.services,
|
||||
required this.notes,
|
||||
required this.messages,
|
||||
});
|
||||
|
||||
int id;
|
||||
DateTime createdDate;
|
||||
String firstName;
|
||||
String lastName;
|
||||
String email;
|
||||
Address billingAddress;
|
||||
String status;
|
||||
String phoneNumber;
|
||||
num balance;
|
||||
String? image;
|
||||
BillCycle billCycle;
|
||||
List<Service> services;
|
||||
List<Note> notes;
|
||||
List<Message> messages;
|
||||
|
||||
String get fullName => '$firstName $lastName';
|
||||
|
||||
DateTime get billingDate {
|
||||
final now = DateTime.now();
|
||||
return DateTime(now.year, now.month, billCycle.day);
|
||||
}
|
||||
|
||||
factory CustomerDetails.fromJson(String str) =>
|
||||
CustomerDetails.fromMap(json.decode(str));
|
||||
|
||||
factory CustomerDetails.fromMap(Map<String, dynamic> json) {
|
||||
CustomerDetails customer = CustomerDetails(
|
||||
id: json["customer_id"],
|
||||
createdDate: DateTime.parse(json['created_date']),
|
||||
firstName: json['first_name'],
|
||||
lastName: json['last_name'],
|
||||
email: json["email"],
|
||||
billingAddress: Address.fromMap(json['billing_address']),
|
||||
status: json['status'],
|
||||
phoneNumber: json['mobile_phone'],
|
||||
balance: json['balance'] ?? 0.00,
|
||||
image: json['image'],
|
||||
billCycle: BillCycle.fromMap(json['billing_cycle']),
|
||||
services: (json['services'] as List)
|
||||
.map((service) => Service.fromMap(service))
|
||||
.toList(),
|
||||
notes: (json['notes'] as List).map((note) => Note.fromMap(note)).toList(),
|
||||
messages: (json['messages'] as List)
|
||||
.map((note) => Message.fromMap(note))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
return customer;
|
||||
}
|
||||
}
|
||||
73
lib/models/customers/customer_marcadores.dart
Normal file
73
lib/models/customers/customer_marcadores.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CustomerMarcadores {
|
||||
int? id;
|
||||
DateTime? createdAt;
|
||||
double? customersTotals;
|
||||
double? activeTotals;
|
||||
double? leadTotals;
|
||||
List<NewCustomersId>? newCustomersId;
|
||||
|
||||
CustomerMarcadores({
|
||||
this.id,
|
||||
this.createdAt,
|
||||
this.customersTotals,
|
||||
this.activeTotals,
|
||||
this.leadTotals,
|
||||
this.newCustomersId,
|
||||
});
|
||||
|
||||
factory CustomerMarcadores.fromJson(String str) => CustomerMarcadores.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CustomerMarcadores.fromMap(Map<String, dynamic> json) => CustomerMarcadores(
|
||||
id: json["id"],
|
||||
createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]),
|
||||
customersTotals: json["customers_totals"],
|
||||
activeTotals: json["active_totals"],
|
||||
leadTotals: json["lead_totals"],
|
||||
newCustomersId: json["new_customers_id"] == null ? [] : List<NewCustomersId>.from(json["new_customers_id"]!.map((x) => NewCustomersId.fromMap(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"customers_totals": customersTotals,
|
||||
"active_totals": activeTotals,
|
||||
"lead_totals": leadTotals,
|
||||
"new_customers_id": newCustomersId == null ? [] : List<dynamic>.from(newCustomersId!.map((x) => x.toMap())),
|
||||
};
|
||||
}
|
||||
|
||||
class NewCustomersId {
|
||||
int? count;
|
||||
String? status;
|
||||
DateTime? createdAt;
|
||||
List<int>? customerIds;
|
||||
|
||||
NewCustomersId({
|
||||
this.count,
|
||||
this.status,
|
||||
this.createdAt,
|
||||
this.customerIds,
|
||||
});
|
||||
|
||||
factory NewCustomersId.fromJson(String str) => NewCustomersId.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory NewCustomersId.fromMap(Map<String, dynamic> json) => NewCustomersId(
|
||||
count: json["count"],
|
||||
status: json["status"],
|
||||
createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]),
|
||||
customerIds: json["customer_ids"] == null ? [] : List<int>.from(json["customer_ids"]!.map((x) => x)),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"count": count,
|
||||
"status": status,
|
||||
"created_at": "${createdAt!.year.toString().padLeft(4, '0')}-${createdAt!.month.toString().padLeft(2, '0')}-${createdAt!.day.toString().padLeft(2, '0')}",
|
||||
"customer_ids": customerIds == null ? [] : List<dynamic>.from(customerIds!.map((x) => x)),
|
||||
};
|
||||
}
|
||||
47
lib/models/customers/customer_subscriptions.dart
Normal file
47
lib/models/customers/customer_subscriptions.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CustomerSubscription {
|
||||
int subscriptionId;
|
||||
String description;
|
||||
double amount;
|
||||
String status;
|
||||
String createdAt;
|
||||
String periodStart;
|
||||
String? periodEnd;
|
||||
|
||||
CustomerSubscription({
|
||||
required this.subscriptionId,
|
||||
required this.description,
|
||||
required this.amount,
|
||||
required this.status,
|
||||
required this.createdAt,
|
||||
required this.periodStart,
|
||||
required this.periodEnd,
|
||||
});
|
||||
|
||||
factory CustomerSubscription.fromJson(String str) =>
|
||||
CustomerSubscription.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CustomerSubscription.fromMap(Map<String, dynamic> json) =>
|
||||
CustomerSubscription(
|
||||
subscriptionId: json["subscription_id"],
|
||||
description: json["description"],
|
||||
amount: json["amount"],
|
||||
status: json["status"],
|
||||
createdAt: json["created_at"],
|
||||
periodStart: json["period_start"],
|
||||
periodEnd: json["period_end"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"subscription_id": subscriptionId,
|
||||
"description": description,
|
||||
"amount": amount,
|
||||
"status": status,
|
||||
"created_at": createdAt,
|
||||
"period_start": periodStart,
|
||||
"period_end": periodEnd,
|
||||
};
|
||||
}
|
||||
57
lib/models/customers/heatmap_customer_model.dart
Normal file
57
lib/models/customers/heatmap_customer_model.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class HeatmapCustomers {
|
||||
int? year;
|
||||
int? month;
|
||||
Registro? registro;
|
||||
|
||||
HeatmapCustomers({
|
||||
this.year,
|
||||
this.month,
|
||||
this.registro,
|
||||
});
|
||||
|
||||
factory HeatmapCustomers.fromJson(String str) => HeatmapCustomers.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory HeatmapCustomers.fromMap(Map<String, dynamic> json) => HeatmapCustomers(
|
||||
year: json["year"],
|
||||
month: json["month"],
|
||||
registro: json["registro"] == null ? null : Registro.fromMap(json["registro"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"year": year,
|
||||
"month": month,
|
||||
"registro": registro?.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
class Registro {
|
||||
double? leads;
|
||||
double? total;
|
||||
double? actives;
|
||||
|
||||
Registro({
|
||||
this.leads,
|
||||
this.total,
|
||||
this.actives,
|
||||
});
|
||||
|
||||
factory Registro.fromJson(String str) => Registro.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Registro.fromMap(Map<String, dynamic> json) => Registro(
|
||||
leads: json["Leads"],
|
||||
total: json["Total"],
|
||||
actives: json["Actives"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"Leads": leads,
|
||||
"Total": total,
|
||||
"Actives": actives,
|
||||
};
|
||||
}
|
||||
25
lib/models/customers/invoice.dart
Normal file
25
lib/models/customers/invoice.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Invoice {
|
||||
Invoice({
|
||||
required this.invoiceId,
|
||||
required this.date,
|
||||
required this.code,
|
||||
});
|
||||
|
||||
int invoiceId;
|
||||
DateTime date;
|
||||
String code;
|
||||
|
||||
factory Invoice.fromJson(String str) => Invoice.fromMap(json.decode(str));
|
||||
|
||||
factory Invoice.fromMap(Map<String, dynamic> json) {
|
||||
Invoice invoice = Invoice(
|
||||
invoiceId: json['invoice_id'],
|
||||
date: DateTime.parse(json["created_at"]),
|
||||
code: json['invoice'],
|
||||
);
|
||||
|
||||
return invoice;
|
||||
}
|
||||
}
|
||||
26
lib/models/customers/messages.dart
Normal file
26
lib/models/customers/messages.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Message {
|
||||
Message({
|
||||
required this.messageId,
|
||||
required this.createdAt,
|
||||
required this.customerFk,
|
||||
required this.text,
|
||||
});
|
||||
|
||||
int messageId;
|
||||
DateTime createdAt;
|
||||
int customerFk;
|
||||
String text;
|
||||
|
||||
factory Message.fromJson(String str) => Message.fromMap(json.decode(str));
|
||||
|
||||
factory Message.fromMap(Map<String, dynamic> json) {
|
||||
return Message(
|
||||
messageId: json["notification_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
customerFk: json['from'],
|
||||
text: json['message'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
28
lib/models/customers/note.dart
Normal file
28
lib/models/customers/note.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Note {
|
||||
Note({
|
||||
required this.noteId,
|
||||
required this.createdAt,
|
||||
required this.customerFk,
|
||||
required this.text,
|
||||
});
|
||||
|
||||
int noteId;
|
||||
DateTime createdAt;
|
||||
int customerFk;
|
||||
String text;
|
||||
|
||||
factory Note.fromJson(String str) => Note.fromMap(json.decode(str));
|
||||
|
||||
factory Note.fromMap(Map<String, dynamic> json) {
|
||||
Note note = Note(
|
||||
noteId: json["note_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
customerFk: json['customer_fk'],
|
||||
text: json['note'] ?? '',
|
||||
);
|
||||
|
||||
return note;
|
||||
}
|
||||
}
|
||||
44
lib/models/customers/payment.dart
Normal file
44
lib/models/customers/payment.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Payment {
|
||||
Payment({
|
||||
required this.paymentId,
|
||||
required this.transactionId,
|
||||
required this.date,
|
||||
required this.method,
|
||||
required this.description,
|
||||
required this.status,
|
||||
required this.amount,
|
||||
required this.error,
|
||||
});
|
||||
|
||||
int transactionId;
|
||||
int paymentId;
|
||||
DateTime date;
|
||||
String method;
|
||||
String description;
|
||||
String status;
|
||||
num amount;
|
||||
String error;
|
||||
|
||||
// String get displayValue => creditCard == '-' ? creditCard : '****$last4Digits';
|
||||
|
||||
// String get last4Digits => creditCard.substring(creditCard.length - 4);
|
||||
|
||||
factory Payment.fromJson(String str) => Payment.fromMap(json.decode(str));
|
||||
|
||||
factory Payment.fromMap(Map<String, dynamic> json) {
|
||||
Payment payment = Payment(
|
||||
paymentId: json['payment_id'],
|
||||
transactionId: json['transaction_id'],
|
||||
date: DateTime.parse(json["date"]),
|
||||
method: json['method'],
|
||||
description: json['description'],
|
||||
status: json['status'],
|
||||
amount: json['amount'],
|
||||
error: json['error'] ?? '',
|
||||
);
|
||||
|
||||
return payment;
|
||||
}
|
||||
}
|
||||
26
lib/models/customers/recent_activity.dart
Normal file
26
lib/models/customers/recent_activity.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class RecentActivity {
|
||||
RecentActivity({
|
||||
required this.recentActivityId,
|
||||
required this.createdAt,
|
||||
required this.customerFk,
|
||||
required this.activity,
|
||||
});
|
||||
|
||||
int recentActivityId;
|
||||
DateTime createdAt;
|
||||
int customerFk;
|
||||
String activity;
|
||||
|
||||
factory RecentActivity.fromJson(String str) => RecentActivity.fromMap(json.decode(str));
|
||||
|
||||
factory RecentActivity.fromMap(Map<String, dynamic> json) {
|
||||
return RecentActivity(
|
||||
recentActivityId: json["recent_activity_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
customerFk: json['customer_fk'],
|
||||
activity: json['activity'],
|
||||
);
|
||||
}
|
||||
}
|
||||
30
lib/models/customers/transaction.dart
Normal file
30
lib/models/customers/transaction.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Transaction {
|
||||
Transaction(
|
||||
{required this.date,
|
||||
required this.description,
|
||||
required this.type,
|
||||
required this.amount,
|
||||
required this.status});
|
||||
|
||||
DateTime date;
|
||||
String description;
|
||||
String type;
|
||||
num amount;
|
||||
String status;
|
||||
|
||||
factory Transaction.fromJson(String str) =>
|
||||
Transaction.fromMap(json.decode(str));
|
||||
|
||||
factory Transaction.fromMap(Map<String, dynamic> json) {
|
||||
Transaction transaction = Transaction(
|
||||
date: DateTime.parse(json["created_at"]),
|
||||
description: json['description'],
|
||||
type: json['type_transaction'],
|
||||
amount: json['total_amout'],
|
||||
status: json['status']);
|
||||
|
||||
return transaction;
|
||||
}
|
||||
}
|
||||
73
lib/models/form_custom_field.dart
Normal file
73
lib/models/form_custom_field.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class FormCustomField {
|
||||
int? formId;
|
||||
int? fillId;
|
||||
int fieldId;
|
||||
String fieldName;
|
||||
String? fieldType;
|
||||
String? fieldIcon;
|
||||
IconData? fieldIconData;
|
||||
bool? fieldVisible;
|
||||
int? fieldOrder;
|
||||
List<String>? enumValues;
|
||||
bool? enumVisible;
|
||||
int? fieldValueId;
|
||||
String? fieldValue;
|
||||
List<String> fieldValues = [];
|
||||
TextEditingController textEditingController = TextEditingController();
|
||||
|
||||
FormCustomField({
|
||||
this.formId,
|
||||
this.fillId,
|
||||
required this.fieldId,
|
||||
required this.fieldName,
|
||||
this.fieldType,
|
||||
this.fieldIcon,
|
||||
this.fieldIconData,
|
||||
this.fieldVisible,
|
||||
this.fieldOrder,
|
||||
this.enumValues,
|
||||
this.enumVisible,
|
||||
this.fieldValueId,
|
||||
this.fieldValue,
|
||||
});
|
||||
|
||||
factory FormCustomField.fromJson(String str) => FormCustomField.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory FormCustomField.fromMap(Map<String, dynamic> json) => FormCustomField(
|
||||
formId: json["form_id"],
|
||||
fillId: json["fill_id"],
|
||||
fieldId: json["field_id"],
|
||||
fieldName: json["field_name"],
|
||||
fieldType: json["field_type"],
|
||||
fieldIconData: json["field_icon"] != null ? IconData(int.parse(json["field_icon"]), fontFamily: 'MaterialIcons') : null,
|
||||
fieldIcon: json["field_icon"],
|
||||
fieldVisible: json["field_visible"],
|
||||
fieldOrder: json["field_order"],
|
||||
fieldValueId: json["field_value_id"],
|
||||
fieldValue: json["field_value"],
|
||||
enumValues: json["enum_values"] == null ? [] : List<String>.from(json["enum_values"]!.map((x) => x)),
|
||||
enumVisible: json["enum_visible"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"form_id": formId,
|
||||
"fill_id": fillId,
|
||||
"field_id": fieldId,
|
||||
"field_name": fieldName,
|
||||
"field_type": fieldType,
|
||||
"field_icon": fieldIcon,
|
||||
"field_visible": fieldVisible,
|
||||
"field_order": fieldOrder,
|
||||
"field_value_id": fieldValueId,
|
||||
"field_value": fieldValue,
|
||||
"enum_values": enumValues == null ? [] : List<dynamic>.from(enumValues!.map((x) => x)),
|
||||
"enum_visible": enumVisible,
|
||||
};
|
||||
}
|
||||
21
lib/models/models.dart
Normal file
21
lib/models/models.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
export 'package:nethive_neo/models/customers/recent_activity.dart';
|
||||
export 'package:nethive_neo/models/customers/messages.dart';
|
||||
export 'package:nethive_neo/models/customers/invoice.dart';
|
||||
export 'package:nethive_neo/models/customers/payment.dart';
|
||||
export 'package:nethive_neo/models/customers/transaction.dart';
|
||||
export 'package:nethive_neo/models/customers/credit_card.dart';
|
||||
export 'package:nethive_neo/models/billing/billing_process.dart';
|
||||
export 'package:nethive_neo/models/customers/note.dart';
|
||||
export 'package:nethive_neo/models/customers/customer_details.dart';
|
||||
export 'package:nethive_neo/models/service.dart';
|
||||
export 'package:nethive_neo/models/customers/bill_cycle.dart';
|
||||
export 'package:nethive_neo/models/state.dart';
|
||||
export 'package:nethive_neo/models/customers/address.dart';
|
||||
export 'package:nethive_neo/models/customers/customer.dart';
|
||||
export 'package:nethive_neo/models/configuration.dart';
|
||||
export 'package:nethive_neo/models/users/user.dart';
|
||||
export 'package:nethive_neo/models/users/role.dart';
|
||||
export 'package:nethive_neo/models/users/token.dart';
|
||||
export 'package:nethive_neo/models/content_manager/ad_by_genre.dart';
|
||||
export 'package:nethive_neo/models/content_manager/all_ads_one_table_model.dart';
|
||||
export 'package:nethive_neo/models/content_manager/category_model.dart';
|
||||
61
lib/models/service.dart
Normal file
61
lib/models/service.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Service {
|
||||
Service({
|
||||
required this.serviceId,
|
||||
required this.code,
|
||||
required this.name,
|
||||
this.description,
|
||||
required this.transactionTypeFk,
|
||||
required this.type,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
int serviceId;
|
||||
String code;
|
||||
String name;
|
||||
String? description;
|
||||
int transactionTypeFk;
|
||||
String? type;
|
||||
num value;
|
||||
|
||||
factory Service.fromJson(String str) => Service.fromMap(json.decode(str));
|
||||
|
||||
factory Service.fromMap(Map<String, dynamic> json) {
|
||||
Service service = Service(
|
||||
serviceId: json["service_id"],
|
||||
code: json['code'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
transactionTypeFk: json['transaction_type_fk'],
|
||||
type: json['type'],
|
||||
value: json['value'],
|
||||
);
|
||||
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
class CustomerService {
|
||||
CustomerService({
|
||||
required this.quantity,
|
||||
required this.createdAt,
|
||||
required this.details,
|
||||
});
|
||||
|
||||
int quantity;
|
||||
DateTime createdAt;
|
||||
Service details;
|
||||
|
||||
factory CustomerService.fromJson(String str) => CustomerService.fromMap(json.decode(str));
|
||||
|
||||
factory CustomerService.fromMap(Map<String, dynamic> json) {
|
||||
CustomerService customerService = CustomerService(
|
||||
quantity: json["quantity"],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
details: Service.fromMap(json),
|
||||
);
|
||||
|
||||
return customerService;
|
||||
}
|
||||
}
|
||||
23
lib/models/state.dart
Normal file
23
lib/models/state.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class StateAPI {
|
||||
StateAPI({
|
||||
required this.id,
|
||||
required this.code,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
int id;
|
||||
String code;
|
||||
String name;
|
||||
|
||||
factory StateAPI.fromJson(String str) => StateAPI.fromMap(json.decode(str));
|
||||
|
||||
factory StateAPI.fromMap(Map<String, dynamic> json) {
|
||||
return StateAPI(
|
||||
id: json["state_id"],
|
||||
code: json['code'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
43
lib/models/support/support.dart
Normal file
43
lib/models/support/support.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CustomerSupport {
|
||||
int? customerId;
|
||||
String? firstName;
|
||||
String? lastName;
|
||||
String? email;
|
||||
String? mobilePhone;
|
||||
String? address;
|
||||
|
||||
CustomerSupport({
|
||||
this.customerId,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.email,
|
||||
this.mobilePhone,
|
||||
this.address,
|
||||
});
|
||||
String get completeName => '$firstName $lastName';
|
||||
|
||||
factory CustomerSupport.fromJson(String str) =>
|
||||
CustomerSupport.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CustomerSupport.fromMap(Map<String, dynamic> json) => CustomerSupport(
|
||||
customerId: json["customer_id"],
|
||||
firstName: json["first_name"],
|
||||
lastName: json["last_name"],
|
||||
email: json["email"],
|
||||
mobilePhone: json["mobile_phone"],
|
||||
address: json["address"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"customer_id": customerId,
|
||||
"first_name": firstName,
|
||||
"last_name": lastName,
|
||||
"email": email,
|
||||
"mobile_phone": mobilePhone,
|
||||
"address": address,
|
||||
};
|
||||
}
|
||||
78
lib/models/users/role.dart
Normal file
78
lib/models/users/role.dart
Normal file
@@ -0,0 +1,78 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Role {
|
||||
Role({
|
||||
required this.name,
|
||||
required this.roleId,
|
||||
required this.permissions,
|
||||
});
|
||||
|
||||
String name;
|
||||
int roleId;
|
||||
Permissions permissions;
|
||||
|
||||
factory Role.fromJson(String str) => Role.fromMap(json.decode(str));
|
||||
|
||||
factory Role.fromMap(Map<String, dynamic> json) => Role(
|
||||
name: json["name"],
|
||||
roleId: json["role_id"],
|
||||
permissions: Permissions.fromMap(json["permissions"]),
|
||||
);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other is Role && other.name == name && other.roleId == roleId;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(name, roleId, permissions);
|
||||
}
|
||||
|
||||
class Permissions {
|
||||
Permissions({
|
||||
required this.home,
|
||||
required this.crm,
|
||||
required this.qr,
|
||||
required this.orders,
|
||||
required this.inventory,
|
||||
required this.serviceOrder,
|
||||
required this.support,
|
||||
required this.sales,
|
||||
required this.billing,
|
||||
required this.technical,
|
||||
required this.users,
|
||||
required this.limited,
|
||||
});
|
||||
|
||||
String? home;
|
||||
String? crm;
|
||||
String? qr;
|
||||
String? orders;
|
||||
String? inventory;
|
||||
String? serviceOrder;
|
||||
String? sales;
|
||||
String? support;
|
||||
String? billing;
|
||||
String? users;
|
||||
String? technical;
|
||||
bool? limited;
|
||||
|
||||
factory Permissions.fromJson(String str) =>
|
||||
Permissions.fromMap(json.decode(str));
|
||||
|
||||
factory Permissions.fromMap(Map<String, dynamic> json) => Permissions(
|
||||
home: json['Home'],
|
||||
crm: json['CRM'],
|
||||
qr: json['QR'],
|
||||
orders: json['Orders'],
|
||||
inventory: json['Inventory'],
|
||||
serviceOrder: json['Service Order'],
|
||||
sales: json['Sales'],
|
||||
support: json['Support'],
|
||||
billing: json['Billing'],
|
||||
users: json['Users'],
|
||||
technical: json["Technical"],
|
||||
limited: json["Limited"],
|
||||
);
|
||||
}
|
||||
60
lib/models/users/token.dart
Normal file
60
lib/models/users/token.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:nethive_neo/helpers/globals.dart';
|
||||
|
||||
class Token {
|
||||
Token({
|
||||
required this.token,
|
||||
required this.userId,
|
||||
required this.email,
|
||||
required this.created,
|
||||
});
|
||||
|
||||
String token;
|
||||
String userId;
|
||||
String email;
|
||||
DateTime created;
|
||||
|
||||
factory Token.fromJson(String str, String token) =>
|
||||
Token.fromMap(json.decode(str), token);
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Token.fromMap(Map<String, dynamic> payload, String token) {
|
||||
return Token(
|
||||
token: token,
|
||||
userId: payload["user_id"],
|
||||
email: payload["email"],
|
||||
created: DateTime.parse(payload['created']),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"user_id": userId,
|
||||
"email": email,
|
||||
"created": created,
|
||||
};
|
||||
|
||||
Future<bool> validate(String type) async {
|
||||
int timeLimit = 5;
|
||||
|
||||
try {
|
||||
final minutesPassed =
|
||||
DateTime.now().toUtc().difference(created).inMinutes;
|
||||
if (minutesPassed < timeLimit) {
|
||||
final res = await supabase
|
||||
.from('token')
|
||||
.select('token_$type')
|
||||
.eq('user_id', userId);
|
||||
final validatedToken = res[0]['token_$type'];
|
||||
if (token == validatedToken) return true;
|
||||
}
|
||||
} catch (e) {
|
||||
log('Error en validateToken - $e');
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
89
lib/models/users/user.dart
Normal file
89
lib/models/users/user.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:nethive_neo/models/users/role.dart';
|
||||
|
||||
class User {
|
||||
User({
|
||||
required this.id,
|
||||
required this.sequentialId,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.email,
|
||||
required this.role,
|
||||
required this.mobilePhone,
|
||||
required this.status,
|
||||
this.image,
|
||||
});
|
||||
|
||||
String id;
|
||||
int sequentialId;
|
||||
String firstName;
|
||||
String lastName;
|
||||
Role role;
|
||||
String email;
|
||||
String? mobilePhone;
|
||||
String status;
|
||||
String? image;
|
||||
|
||||
String get fullName => '$firstName $lastName';
|
||||
|
||||
int get statusColor {
|
||||
late final int color;
|
||||
switch (status) {
|
||||
case 'Active':
|
||||
color = 0XFF2EA437;
|
||||
break;
|
||||
default:
|
||||
color = 0XFF2EA437;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
bool get isAdmin => role.name == 'Administrator';
|
||||
bool get isInventory => role.name == 'Inventory Warehouse';
|
||||
bool get isSales => role.name == 'Sales Rep';
|
||||
bool get isSupport => role.name == 'Support';
|
||||
bool get isOperation => role.name == 'Operation';
|
||||
|
||||
factory User.fromJson(String str) => User.fromMap(json.decode(str));
|
||||
|
||||
factory User.fromMap(Map<String, dynamic> json) {
|
||||
User user = User(
|
||||
id: json["user_profile_id"],
|
||||
sequentialId: json["sequential_id"],
|
||||
firstName: json['first_name'],
|
||||
lastName: json['last_name'],
|
||||
role: Role.fromMap(json['role']),
|
||||
email: json["email"],
|
||||
mobilePhone: json['mobile_phone'],
|
||||
status: json['status'],
|
||||
image: json['image'],
|
||||
);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
User copyWith({
|
||||
String? id,
|
||||
int? sequentialId,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
Role? role,
|
||||
String? email,
|
||||
String? mobilePhone,
|
||||
String? status,
|
||||
String? image,
|
||||
}) {
|
||||
return User(
|
||||
id: id ?? this.id,
|
||||
sequentialId: sequentialId ?? this.sequentialId,
|
||||
firstName: firstName ?? this.firstName,
|
||||
lastName: lastName ?? this.lastName,
|
||||
role: role ?? this.role,
|
||||
email: email ?? this.email,
|
||||
mobilePhone: mobilePhone ?? this.mobilePhone,
|
||||
status: status ?? this.status,
|
||||
image: image ?? this.image,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user