products data

This commit is contained in:
2026-04-12 19:21:54 +02:00
parent bdf928cca3
commit b8caff7636
9 changed files with 419 additions and 28 deletions

View File

@@ -0,0 +1,57 @@
import 'package:equatable/equatable.dart';
class BrandModel extends Equatable {
final String? id;
final String name;
final String companyId;
final bool isActive;
final DateTime? createdAt;
const BrandModel({
this.id,
required this.name,
required this.companyId,
this.isActive = true,
this.createdAt,
});
factory BrandModel.fromJson(Map<String, dynamic> json) {
return BrandModel(
id: json['id'] as String,
name: json['name'] as String,
companyId: json['company_id'] as String,
isActive: json['is_active'] as bool? ?? true,
createdAt: json['created_at'] != null
? DateTime.parse(json['created_at'])
: null,
);
}
Map<String, dynamic> toJson() {
return {
if (id != null) 'id': id,
'name': name,
'company_id': companyId,
'is_active': isActive,
};
}
BrandModel copyWith({
String? id,
String? name,
String? companyId,
bool? isActive,
DateTime? createdAt,
}) {
return BrandModel(
id: id ?? this.id,
name: name ?? this.name,
companyId: companyId ?? this.companyId,
isActive: isActive ?? this.isActive,
createdAt: createdAt ?? this.createdAt,
);
}
@override
List<Object?> get props => [id, name, companyId, isActive, createdAt];
}

View File

@@ -0,0 +1,70 @@
import 'package:equatable/equatable.dart';
class ModelModel extends Equatable {
final String? id;
final String name;
final String nameWithBrand;
final String brandId;
final bool isActive;
final DateTime? createdAt;
const ModelModel({
this.id,
required this.name,
required this.nameWithBrand,
required this.brandId,
this.isActive = true,
this.createdAt,
});
factory ModelModel.fromJson(Map<String, dynamic> json) {
return ModelModel(
id: json['id'] as String,
name: json['name'] as String,
nameWithBrand: json['name_with_brand'] as String,
brandId: json['brand_id'] as String,
isActive: json['is_active'] as bool? ?? true,
createdAt: json['created_at'] != null
? DateTime.parse(json['created_at'])
: null,
);
}
Map<String, dynamic> toJson() {
return {
if (id != null) 'id': id,
'name': name,
'name_with_brand': nameWithBrand,
'brand_id': brandId,
'is_active': isActive,
};
}
ModelModel copyWith({
String? id,
String? name,
String? nameWithBrand,
String? brandId,
bool? isActive,
DateTime? createdAt,
}) {
return ModelModel(
id: id ?? this.id,
name: name ?? this.name,
nameWithBrand: nameWithBrand ?? this.nameWithBrand,
brandId: brandId ?? this.brandId,
isActive: isActive ?? this.isActive,
createdAt: createdAt ?? this.createdAt,
);
}
@override
List<Object?> get props => [
id,
name,
nameWithBrand,
brandId,
isActive,
createdAt,
];
}