diff --git a/lib/app/data/models/bentuk_bantuan_model.dart b/lib/app/data/models/bentuk_bantuan_model.dart new file mode 100644 index 0000000..e4a5766 --- /dev/null +++ b/lib/app/data/models/bentuk_bantuan_model.dart @@ -0,0 +1,45 @@ +import 'dart:convert'; + +class BentukBantuanModel { + final String id; + final String nama; + final String? deskripsi; + final String? kategori; + final DateTime createdAt; + final DateTime? updatedAt; + + BentukBantuanModel({ + required this.id, + required this.nama, + this.deskripsi, + this.kategori, + required this.createdAt, + this.updatedAt, + }); + + factory BentukBantuanModel.fromRawJson(String str) => + BentukBantuanModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory BentukBantuanModel.fromJson(Map json) => + BentukBantuanModel( + id: json["id"], + nama: json["nama"], + deskripsi: json["deskripsi"], + kategori: json["kategori"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "nama": nama, + "deskripsi": deskripsi, + "kategori": kategori, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/detail_penyaluran_model.dart b/lib/app/data/models/detail_penyaluran_model.dart new file mode 100644 index 0000000..1084e02 --- /dev/null +++ b/lib/app/data/models/detail_penyaluran_model.dart @@ -0,0 +1,69 @@ +import 'dart:convert'; + +class DetailPenyaluranModel { + final String id; + final String penyaluranBantuanId; // Referensi ke PenyaluranBantuan + final String? penerimaBantuanId; // Referensi ke PenerimaBantuan + final double jumlah; + final String? satuan; + final String? catatan; + final String status; // Contoh: 'diterima', 'ditolak' + final List? gambarUrls; // URL gambar bukti penerimaan + final DateTime tanggalDiterima; + final DateTime createdAt; + final DateTime? updatedAt; + + DetailPenyaluranModel({ + required this.id, + required this.penyaluranBantuanId, + this.penerimaBantuanId, + required this.jumlah, + this.satuan, + this.catatan, + required this.status, + this.gambarUrls, + required this.tanggalDiterima, + required this.createdAt, + this.updatedAt, + }); + + factory DetailPenyaluranModel.fromRawJson(String str) => + DetailPenyaluranModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory DetailPenyaluranModel.fromJson(Map json) => + DetailPenyaluranModel( + id: json["id"], + penyaluranBantuanId: json["penyaluran_bantuan_id"], + penerimaBantuanId: json["penerima_bantuan_id"], + jumlah: json["jumlah"].toDouble(), + satuan: json["satuan"], + catatan: json["catatan"], + status: json["status"], + gambarUrls: json["gambar_urls"] == null + ? null + : List.from(json["gambar_urls"].map((x) => x)), + tanggalDiterima: DateTime.parse(json["tanggal_diterima"]), + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "penyaluran_bantuan_id": penyaluranBantuanId, + "penerima_bantuan_id": penerimaBantuanId, + "jumlah": jumlah, + "satuan": satuan, + "catatan": catatan, + "status": status, + "gambar_urls": gambarUrls == null + ? null + : List.from(gambarUrls!.map((x) => x)), + "tanggal_diterima": tanggalDiterima.toIso8601String(), + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/donatur_model.dart b/lib/app/data/models/donatur_model.dart new file mode 100644 index 0000000..f220eb7 --- /dev/null +++ b/lib/app/data/models/donatur_model.dart @@ -0,0 +1,52 @@ +import 'dart:convert'; + +class DonaturModel { + final String id; + final String nama; + final String? alamat; + final String? noTelp; + final String? email; + final String? jenisDonatur; // Individu, Organisasi, Perusahaan, dll + final DateTime createdAt; + final DateTime? updatedAt; + + DonaturModel({ + required this.id, + required this.nama, + this.alamat, + this.noTelp, + this.email, + this.jenisDonatur, + required this.createdAt, + this.updatedAt, + }); + + factory DonaturModel.fromRawJson(String str) => + DonaturModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory DonaturModel.fromJson(Map json) => DonaturModel( + id: json["id"], + nama: json["nama"], + alamat: json["alamat"], + noTelp: json["no_telp"], + email: json["email"], + jenisDonatur: json["jenis_donatur"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "nama": nama, + "alamat": alamat, + "no_telp": noTelp, + "email": email, + "jenis_donatur": jenisDonatur, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/laporan_model.dart b/lib/app/data/models/laporan_model.dart new file mode 100644 index 0000000..8296b60 --- /dev/null +++ b/lib/app/data/models/laporan_model.dart @@ -0,0 +1,77 @@ +import 'dart:convert'; + +class LaporanModel { + final String id; + final String judul; + final String? deskripsi; + final String jenis; // Contoh: 'penyaluran', 'penitipan', 'pengaduan' + final String? + referensiId; // ID dari entitas yang dilaporkan (penyaluran, penitipan, dll) + final String status; // Contoh: 'draft', 'final', 'disetujui' + final String? userId; // Pengguna yang membuat laporan + final List? fileUrls; // URL file laporan (PDF, Excel, dll) + final DateTime periodeAwal; + final DateTime periodeAkhir; + final DateTime tanggalLaporan; + final DateTime createdAt; + final DateTime? updatedAt; + + LaporanModel({ + required this.id, + required this.judul, + this.deskripsi, + required this.jenis, + this.referensiId, + required this.status, + this.userId, + this.fileUrls, + required this.periodeAwal, + required this.periodeAkhir, + required this.tanggalLaporan, + required this.createdAt, + this.updatedAt, + }); + + factory LaporanModel.fromRawJson(String str) => + LaporanModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory LaporanModel.fromJson(Map json) => LaporanModel( + id: json["id"], + judul: json["judul"], + deskripsi: json["deskripsi"], + jenis: json["jenis"], + referensiId: json["referensi_id"], + status: json["status"], + userId: json["user_id"], + fileUrls: json["file_urls"] == null + ? null + : List.from(json["file_urls"].map((x) => x)), + periodeAwal: DateTime.parse(json["periode_awal"]), + periodeAkhir: DateTime.parse(json["periode_akhir"]), + tanggalLaporan: DateTime.parse(json["tanggal_laporan"]), + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "judul": judul, + "deskripsi": deskripsi, + "jenis": jenis, + "referensi_id": referensiId, + "status": status, + "user_id": userId, + "file_urls": fileUrls == null + ? null + : List.from(fileUrls!.map((x) => x)), + "periode_awal": periodeAwal.toIso8601String(), + "periode_akhir": periodeAkhir.toIso8601String(), + "tanggal_laporan": tanggalLaporan.toIso8601String(), + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/lokasi_penyaluran_model.dart b/lib/app/data/models/lokasi_penyaluran_model.dart new file mode 100644 index 0000000..7b40ec6 --- /dev/null +++ b/lib/app/data/models/lokasi_penyaluran_model.dart @@ -0,0 +1,74 @@ +import 'dart:convert'; + +class LokasiPenyaluranModel { + final String id; + final String nama; + final String? alamat; + final String? desa; + final String? kecamatan; + final String? kabupaten; + final String? provinsi; + final String? kodePos; + final double? latitude; + final double? longitude; + final String? petugasDesaId; // Referensi ke PetugasDesa + final DateTime createdAt; + final DateTime? updatedAt; + + LokasiPenyaluranModel({ + required this.id, + required this.nama, + this.alamat, + this.desa, + this.kecamatan, + this.kabupaten, + this.provinsi, + this.kodePos, + this.latitude, + this.longitude, + this.petugasDesaId, + required this.createdAt, + this.updatedAt, + }); + + factory LokasiPenyaluranModel.fromRawJson(String str) => + LokasiPenyaluranModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory LokasiPenyaluranModel.fromJson(Map json) => + LokasiPenyaluranModel( + id: json["id"], + nama: json["nama"], + alamat: json["alamat"], + desa: json["desa"], + kecamatan: json["kecamatan"], + kabupaten: json["kabupaten"], + provinsi: json["provinsi"], + kodePos: json["kode_pos"], + latitude: json["latitude"] != null ? json["latitude"].toDouble() : null, + longitude: + json["longitude"] != null ? json["longitude"].toDouble() : null, + petugasDesaId: json["petugas_desa_id"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "nama": nama, + "alamat": alamat, + "desa": desa, + "kecamatan": kecamatan, + "kabupaten": kabupaten, + "provinsi": provinsi, + "kode_pos": kodePos, + "latitude": latitude, + "longitude": longitude, + "petugas_desa_id": petugasDesaId, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/notifikasi_model.dart b/lib/app/data/models/notifikasi_model.dart new file mode 100644 index 0000000..2e5bf30 --- /dev/null +++ b/lib/app/data/models/notifikasi_model.dart @@ -0,0 +1,57 @@ +import 'dart:convert'; + +class NotifikasiModel { + final String id; + final String judul; + final String pesan; + final String? jenis; // Contoh: 'penyaluran', 'penitipan', 'pengaduan' + final String? referensiId; // ID dari entitas yang terkait notifikasi + final String? userId; // Pengguna yang menerima notifikasi + final bool dibaca; + final DateTime createdAt; + final DateTime? updatedAt; + + NotifikasiModel({ + required this.id, + required this.judul, + required this.pesan, + this.jenis, + this.referensiId, + this.userId, + this.dibaca = false, + required this.createdAt, + this.updatedAt, + }); + + factory NotifikasiModel.fromRawJson(String str) => + NotifikasiModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory NotifikasiModel.fromJson(Map json) => + NotifikasiModel( + id: json["id"], + judul: json["judul"], + pesan: json["pesan"], + jenis: json["jenis"], + referensiId: json["referensi_id"], + userId: json["user_id"], + dibaca: json["dibaca"] ?? false, + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "judul": judul, + "pesan": pesan, + "jenis": jenis, + "referensi_id": referensiId, + "user_id": userId, + "dibaca": dibaca, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/penerima_bantuan_model.dart b/lib/app/data/models/penerima_bantuan_model.dart new file mode 100644 index 0000000..b09d70e --- /dev/null +++ b/lib/app/data/models/penerima_bantuan_model.dart @@ -0,0 +1,77 @@ +import 'dart:convert'; + +class PenerimaBantuanModel { + final String id; + final String nama; + final String? nik; + final String? alamat; + final String? desa; + final String? kecamatan; + final String? kabupaten; + final String? provinsi; + final String? noTelp; + final String? kategori; // Contoh: 'lansia', 'disabilitas', 'miskin', dll + final String? status; // Contoh: 'aktif', 'nonaktif' + final String? lokasiPenyaluranId; // Referensi ke LokasiPenyaluran + final DateTime createdAt; + final DateTime? updatedAt; + + PenerimaBantuanModel({ + required this.id, + required this.nama, + this.nik, + this.alamat, + this.desa, + this.kecamatan, + this.kabupaten, + this.provinsi, + this.noTelp, + this.kategori, + this.status, + this.lokasiPenyaluranId, + required this.createdAt, + this.updatedAt, + }); + + factory PenerimaBantuanModel.fromRawJson(String str) => + PenerimaBantuanModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory PenerimaBantuanModel.fromJson(Map json) => + PenerimaBantuanModel( + id: json["id"], + nama: json["nama"], + nik: json["nik"], + alamat: json["alamat"], + desa: json["desa"], + kecamatan: json["kecamatan"], + kabupaten: json["kabupaten"], + provinsi: json["provinsi"], + noTelp: json["no_telp"], + kategori: json["kategori"], + status: json["status"], + lokasiPenyaluranId: json["lokasi_penyaluran_id"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "nama": nama, + "nik": nik, + "alamat": alamat, + "desa": desa, + "kecamatan": kecamatan, + "kabupaten": kabupaten, + "provinsi": provinsi, + "no_telp": noTelp, + "kategori": kategori, + "status": status, + "lokasi_penyaluran_id": lokasiPenyaluranId, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/pengaduan_model.dart b/lib/app/data/models/pengaduan_model.dart new file mode 100644 index 0000000..738baf8 --- /dev/null +++ b/lib/app/data/models/pengaduan_model.dart @@ -0,0 +1,60 @@ +import 'dart:convert'; + +class PengaduanModel { + final String id; + final String judul; + final String deskripsi; + final String? userId; // Pengguna yang membuat pengaduan + final String? penyaluranBantuanId; // Referensi ke PenyaluranBantuan + final String status; // Contoh: 'pending', 'diproses', 'selesai' + final List? gambarUrls; // URL gambar bukti pengaduan + final DateTime createdAt; + final DateTime? updatedAt; + + PengaduanModel({ + required this.id, + required this.judul, + required this.deskripsi, + this.userId, + this.penyaluranBantuanId, + required this.status, + this.gambarUrls, + required this.createdAt, + this.updatedAt, + }); + + factory PengaduanModel.fromRawJson(String str) => + PengaduanModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory PengaduanModel.fromJson(Map json) => PengaduanModel( + id: json["id"], + judul: json["judul"], + deskripsi: json["deskripsi"], + userId: json["user_id"], + penyaluranBantuanId: json["penyaluran_bantuan_id"], + status: json["status"], + gambarUrls: json["gambar_urls"] == null + ? null + : List.from(json["gambar_urls"].map((x) => x)), + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "judul": judul, + "deskripsi": deskripsi, + "user_id": userId, + "penyaluran_bantuan_id": penyaluranBantuanId, + "status": status, + "gambar_urls": gambarUrls == null + ? null + : List.from(gambarUrls!.map((x) => x)), + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/penitipan_bantuan_model.dart b/lib/app/data/models/penitipan_bantuan_model.dart new file mode 100644 index 0000000..dd3ae67 --- /dev/null +++ b/lib/app/data/models/penitipan_bantuan_model.dart @@ -0,0 +1,73 @@ +import 'dart:convert'; + +class PenitipanBantuanModel { + final String id; + final String? donaturId; // Referensi ke Donatur + final String? bentukBantuanId; // Referensi ke BentukBantuan + final String? sumberBantuanId; // Referensi ke SumberBantuan + final double jumlah; + final String? satuan; // Contoh: kg, buah, paket, dll + final String? deskripsi; + final String status; // Contoh: 'diterima', 'disalurkan', 'ditolak' + final List? gambarUrls; // URL gambar bukti penitipan + final DateTime tanggalPenitipan; + final DateTime createdAt; + final DateTime? updatedAt; + + PenitipanBantuanModel({ + required this.id, + this.donaturId, + this.bentukBantuanId, + this.sumberBantuanId, + required this.jumlah, + this.satuan, + this.deskripsi, + required this.status, + this.gambarUrls, + required this.tanggalPenitipan, + required this.createdAt, + this.updatedAt, + }); + + factory PenitipanBantuanModel.fromRawJson(String str) => + PenitipanBantuanModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory PenitipanBantuanModel.fromJson(Map json) => + PenitipanBantuanModel( + id: json["id"], + donaturId: json["donatur_id"], + bentukBantuanId: json["bentuk_bantuan_id"], + sumberBantuanId: json["sumber_bantuan_id"], + jumlah: json["jumlah"].toDouble(), + satuan: json["satuan"], + deskripsi: json["deskripsi"], + status: json["status"], + gambarUrls: json["gambar_urls"] == null + ? null + : List.from(json["gambar_urls"].map((x) => x)), + tanggalPenitipan: DateTime.parse(json["tanggal_penitipan"]), + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "donatur_id": donaturId, + "bentuk_bantuan_id": bentukBantuanId, + "sumber_bantuan_id": sumberBantuanId, + "jumlah": jumlah, + "satuan": satuan, + "deskripsi": deskripsi, + "status": status, + "gambar_urls": gambarUrls == null + ? null + : List.from(gambarUrls!.map((x) => x)), + "tanggal_penitipan": tanggalPenitipan.toIso8601String(), + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/penyaluran_bantuan_model.dart b/lib/app/data/models/penyaluran_bantuan_model.dart new file mode 100644 index 0000000..f101c34 --- /dev/null +++ b/lib/app/data/models/penyaluran_bantuan_model.dart @@ -0,0 +1,73 @@ +import 'dart:convert'; + +class PenyaluranBantuanModel { + final String id; + final String? penitipanBantuanId; // Referensi ke PenitipanBantuan + final String? lokasiPenyaluranId; // Referensi ke LokasiPenyaluran + final String? petugasDesaId; // Referensi ke PetugasDesa + final double jumlah; + final String? satuan; // Contoh: kg, buah, paket, dll + final String? deskripsi; + final String status; // Contoh: 'diproses', 'disalurkan', 'dibatalkan' + final List? gambarUrls; // URL gambar bukti penyaluran + final DateTime tanggalPenyaluran; + final DateTime createdAt; + final DateTime? updatedAt; + + PenyaluranBantuanModel({ + required this.id, + this.penitipanBantuanId, + this.lokasiPenyaluranId, + this.petugasDesaId, + required this.jumlah, + this.satuan, + this.deskripsi, + required this.status, + this.gambarUrls, + required this.tanggalPenyaluran, + required this.createdAt, + this.updatedAt, + }); + + factory PenyaluranBantuanModel.fromRawJson(String str) => + PenyaluranBantuanModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory PenyaluranBantuanModel.fromJson(Map json) => + PenyaluranBantuanModel( + id: json["id"], + penitipanBantuanId: json["penitipan_bantuan_id"], + lokasiPenyaluranId: json["lokasi_penyaluran_id"], + petugasDesaId: json["petugas_desa_id"], + jumlah: json["jumlah"].toDouble(), + satuan: json["satuan"], + deskripsi: json["deskripsi"], + status: json["status"], + gambarUrls: json["gambar_urls"] == null + ? null + : List.from(json["gambar_urls"].map((x) => x)), + tanggalPenyaluran: DateTime.parse(json["tanggal_penyaluran"]), + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "penitipan_bantuan_id": penitipanBantuanId, + "lokasi_penyaluran_id": lokasiPenyaluranId, + "petugas_desa_id": petugasDesaId, + "jumlah": jumlah, + "satuan": satuan, + "deskripsi": deskripsi, + "status": status, + "gambar_urls": gambarUrls == null + ? null + : List.from(gambarUrls!.map((x) => x)), + "tanggal_penyaluran": tanggalPenyaluran.toIso8601String(), + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/petugas_desa_model.dart b/lib/app/data/models/petugas_desa_model.dart new file mode 100644 index 0000000..ba14ca6 --- /dev/null +++ b/lib/app/data/models/petugas_desa_model.dart @@ -0,0 +1,73 @@ +import 'dart:convert'; + +class PetugasDesaModel { + final String id; + final String nama; + final String? alamat; + final String? noTelp; + final String? email; + final String? jabatan; + final String? desa; + final String? kecamatan; + final String? kabupaten; + final String? provinsi; + final String? userId; // Referensi ke User jika petugas memiliki akun + final DateTime createdAt; + final DateTime? updatedAt; + + PetugasDesaModel({ + required this.id, + required this.nama, + this.alamat, + this.noTelp, + this.email, + this.jabatan, + this.desa, + this.kecamatan, + this.kabupaten, + this.provinsi, + this.userId, + required this.createdAt, + this.updatedAt, + }); + + factory PetugasDesaModel.fromRawJson(String str) => + PetugasDesaModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory PetugasDesaModel.fromJson(Map json) => + PetugasDesaModel( + id: json["id"], + nama: json["nama"], + alamat: json["alamat"], + noTelp: json["no_telp"], + email: json["email"], + jabatan: json["jabatan"], + desa: json["desa"], + kecamatan: json["kecamatan"], + kabupaten: json["kabupaten"], + provinsi: json["provinsi"], + userId: json["user_id"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "nama": nama, + "alamat": alamat, + "no_telp": noTelp, + "email": email, + "jabatan": jabatan, + "desa": desa, + "kecamatan": kecamatan, + "kabupaten": kabupaten, + "provinsi": provinsi, + "user_id": userId, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/stok_bantuan_model.dart b/lib/app/data/models/stok_bantuan_model.dart new file mode 100644 index 0000000..a324802 --- /dev/null +++ b/lib/app/data/models/stok_bantuan_model.dart @@ -0,0 +1,61 @@ +import 'dart:convert'; + +class StokBantuanModel { + final String id; + final String bentukBantuanId; // Referensi ke BentukBantuan + final double jumlahMasuk; + final double jumlahKeluar; + final double stokSisa; + final String? satuan; + final String? catatan; + final DateTime tanggalUpdate; + final DateTime createdAt; + final DateTime? updatedAt; + + StokBantuanModel({ + required this.id, + required this.bentukBantuanId, + required this.jumlahMasuk, + required this.jumlahKeluar, + required this.stokSisa, + this.satuan, + this.catatan, + required this.tanggalUpdate, + required this.createdAt, + this.updatedAt, + }); + + factory StokBantuanModel.fromRawJson(String str) => + StokBantuanModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory StokBantuanModel.fromJson(Map json) => + StokBantuanModel( + id: json["id"], + bentukBantuanId: json["bentuk_bantuan_id"], + jumlahMasuk: json["jumlah_masuk"].toDouble(), + jumlahKeluar: json["jumlah_keluar"].toDouble(), + stokSisa: json["stok_sisa"].toDouble(), + satuan: json["satuan"], + catatan: json["catatan"], + tanggalUpdate: DateTime.parse(json["tanggal_update"]), + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "bentuk_bantuan_id": bentukBantuanId, + "jumlah_masuk": jumlahMasuk, + "jumlah_keluar": jumlahKeluar, + "stok_sisa": stokSisa, + "satuan": satuan, + "catatan": catatan, + "tanggal_update": tanggalUpdate.toIso8601String(), + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/sumber_bantuan_model.dart b/lib/app/data/models/sumber_bantuan_model.dart new file mode 100644 index 0000000..8ae3870 --- /dev/null +++ b/lib/app/data/models/sumber_bantuan_model.dart @@ -0,0 +1,45 @@ +import 'dart:convert'; + +class SumberBantuanModel { + final String id; + final String nama; + final String? deskripsi; + final String? kategori; // Contoh: 'pemerintah', 'swasta', 'masyarakat' + final DateTime createdAt; + final DateTime? updatedAt; + + SumberBantuanModel({ + required this.id, + required this.nama, + this.deskripsi, + this.kategori, + required this.createdAt, + this.updatedAt, + }); + + factory SumberBantuanModel.fromRawJson(String str) => + SumberBantuanModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory SumberBantuanModel.fromJson(Map json) => + SumberBantuanModel( + id: json["id"], + nama: json["nama"], + deskripsi: json["deskripsi"], + kategori: json["kategori"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "nama": nama, + "deskripsi": deskripsi, + "kategori": kategori, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +} diff --git a/lib/app/data/models/tindakan_pengaduan_model.dart b/lib/app/data/models/tindakan_pengaduan_model.dart new file mode 100644 index 0000000..e7ceb65 --- /dev/null +++ b/lib/app/data/models/tindakan_pengaduan_model.dart @@ -0,0 +1,65 @@ +import 'dart:convert'; + +class TindakanPengaduanModel { + final String id; + final String pengaduanId; // Referensi ke Pengaduan + final String? userId; // Pengguna yang melakukan tindakan + final String tindakan; // Deskripsi tindakan yang dilakukan + final String status; // Contoh: 'diproses', 'selesai' + final String? catatan; + final List? gambarUrls; // URL gambar bukti tindakan + final DateTime tanggalTindakan; + final DateTime createdAt; + final DateTime? updatedAt; + + TindakanPengaduanModel({ + required this.id, + required this.pengaduanId, + this.userId, + required this.tindakan, + required this.status, + this.catatan, + this.gambarUrls, + required this.tanggalTindakan, + required this.createdAt, + this.updatedAt, + }); + + factory TindakanPengaduanModel.fromRawJson(String str) => + TindakanPengaduanModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory TindakanPengaduanModel.fromJson(Map json) => + TindakanPengaduanModel( + id: json["id"], + pengaduanId: json["pengaduan_id"], + userId: json["user_id"], + tindakan: json["tindakan"], + status: json["status"], + catatan: json["catatan"], + gambarUrls: json["gambar_urls"] == null + ? null + : List.from(json["gambar_urls"].map((x) => x)), + tanggalTindakan: DateTime.parse(json["tanggal_tindakan"]), + createdAt: DateTime.parse(json["created_at"]), + updatedAt: json["updated_at"] == null + ? null + : DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "pengaduan_id": pengaduanId, + "user_id": userId, + "tindakan": tindakan, + "status": status, + "catatan": catatan, + "gambar_urls": gambarUrls == null + ? null + : List.from(gambarUrls!.map((x) => x)), + "tanggal_tindakan": tanggalTindakan.toIso8601String(), + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt?.toIso8601String(), + }; +}