feat(plans): plan creating has been completed

This commit is contained in:
Username1548
2025-04-29 14:44:33 +07:00
parent c8b828bfe1
commit 0fcb2c1a0d
43 changed files with 1602 additions and 635 deletions

View File

@@ -15,8 +15,8 @@ class CreatePlanModel with _$CreatePlanModel {
const factory CreatePlanModel({
String? name,
String? details,
String? state,
int? duration,
@Default('active') String? state,
int? duration,
required List<bool> type,
XFile? image,
required List<PacketOptions> options,
@@ -25,9 +25,12 @@ class CreatePlanModel with _$CreatePlanModel {
Future<Map<String, dynamic>> toCreationJson() async => {
'name': name,
'duration': duration,
'state': state,
'type': type,
'state': 'active',
'description_md': details,
'type[slim]': type[0] ? '1' : '0',
'type[fit]': type[1] ? '1' : '0',
'type[wellness]': type[2] ? '1' : '0',
'type[behavior]': type[3] ? '1' : '0',
'image': image != null ? await MultipartFile.fromFile((await ImageCompressUtility.compressFile(File(image!.path))).path, filename: image!.name) : null,
};

View File

@@ -0,0 +1,11 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'plan_slug_model.freezed.dart';
part 'plan_slug_model.g.dart';
@freezed
class PlanSlugModel with _$PlanSlugModel {
factory PlanSlugModel({@JsonKey(name: 'slug') required String slug}) = _PlanSlugModel;
factory PlanSlugModel.fromJson(Map<String, dynamic> json) => _$PlanSlugModelFromJson(json);
}