Feat: done database migration

This commit is contained in:
orangdeso 2025-03-28 21:39:24 +07:00
parent 4e3d4b5d33
commit c3c0f41269
7 changed files with 65 additions and 34 deletions

View File

@ -2,7 +2,7 @@ plugins {
id "com.android.application" id "com.android.application"
id "kotlin-android" id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin" id "dev.flutter.flutter-gradle-plugin"
id 'com.google.gms.google-services' id 'com.google.gms.google-services' // firebase
} }
def localProperties = new Properties() def localProperties = new Properties()
@ -56,6 +56,8 @@ flutter {
} }
dependencies { dependencies {
implementation platform('com.google.firebase:firebase-bom:33.9.0') // Firebase
// implementation platform('com.google.firebase:firebase-bom:33.9.0')
implementation(platform("com.google.firebase:firebase-bom:33.11.0"))
implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-analytics'
} }

View File

@ -1,13 +1,14 @@
{ {
"project_info": { "project_info": {
"project_number": "500904629253", "project_number": "263537612753",
"project_id": "e-porter-95934", "firebase_url": "https://tomatify-b02d2-default-rtdb.asia-southeast1.firebasedatabase.app",
"storage_bucket": "e-porter-95934.firebasestorage.app" "project_id": "tomatify-b02d2",
"storage_bucket": "tomatify-b02d2.appspot.com"
}, },
"client": [ "client": [
{ {
"client_info": { "client_info": {
"mobilesdk_app_id": "1:500904629253:android:605ea4c7c68257ee0ab86c", "mobilesdk_app_id": "1:263537612753:android:55032afbca267c984f72f0",
"android_client_info": { "android_client_info": {
"package_name": "com.example.e_porter" "package_name": "com.example.e_porter"
} }
@ -15,7 +16,26 @@
"oauth_client": [], "oauth_client": [],
"api_key": [ "api_key": [
{ {
"current_key": "AIzaSyC0wuDunsKoDmB8H8dCX6ZDmvGH93rlwYE" "current_key": "AIzaSyAIY5iiaWO08YrhxFoxkQHYUOUKrl7kZRs"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:263537612753:android:ff16ddcf74fc8dd34f72f0",
"android_client_info": {
"package_name": "com.example.tomato"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyAIY5iiaWO08YrhxFoxkQHYUOUKrl7kZRs"
} }
], ],
"services": { "services": {

View File

@ -7,7 +7,7 @@ buildscript {
dependencies { dependencies {
classpath "com.android.tools.build:gradle:8.2.0" classpath "com.android.tools.build:gradle:8.2.0"
classpath 'com.google.gms:google-services:4.4.2' classpath 'com.google.gms:google-services:4.4.2' // firebase
} }
} }

View File

@ -1,15 +1,12 @@
// data/repositories/porter_service_repository_impl.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import '../../domain/models/porter_service_model.dart'; import '../../domain/models/porter_service_model.dart';
import '../../domain/repositories/porter_service_repository.dart'; import '../../domain/repositories/porter_service_repository.dart';
class PorterServiceRepositoryImpl implements PorterServiceRepository { class PorterServiceRepositoryImpl implements PorterServiceRepository {
final FirebaseFirestore _firestore; final FirebaseFirestore _firestore;
final String _collectionName = 'PorterServices'; final String _collectionName = 'porterServices';
PorterServiceRepositoryImpl({FirebaseFirestore? firestore}) PorterServiceRepositoryImpl({FirebaseFirestore? firestore}) : _firestore = firestore ?? FirebaseFirestore.instance;
: _firestore = firestore ?? FirebaseFirestore.instance;
@override @override
Future<List<PorterServiceModel>> getAllServices() async { Future<List<PorterServiceModel>> getAllServices() async {
@ -28,12 +25,9 @@ class PorterServiceRepositoryImpl implements PorterServiceRepository {
@override @override
Future<List<PorterServiceModel>> getServicesByType(String type) async { Future<List<PorterServiceModel>> getServicesByType(String type) async {
try { try {
final snapshot = await _firestore final snapshot =
.collection(_collectionName) await _firestore.collection(_collectionName).where('availableFor', arrayContains: type).orderBy('sort').get();
.where('availableFor', arrayContains: type)
.orderBy('sort')
.get();
return snapshot.docs.map((doc) { return snapshot.docs.map((doc) {
final data = doc.data() as Map<String, dynamic>; final data = doc.data() as Map<String, dynamic>;
return PorterServiceModel.fromJson(data, doc.id); return PorterServiceModel.fromJson(data, doc.id);

View File

@ -138,7 +138,6 @@ class _SearchTicketsScreenState extends State<SearchTicketsScreen> {
"ticketDate": ticketDate, "ticketDate": ticketDate,
"passenger": passengerCount, "passenger": passengerCount,
}; };
// logger.d('ID Ticket: $ticketId \nID Flight: $flightId \nTicket Date: $ticketDate \nPassenger: $passengerCount');
Get.toNamed(Routes.TICKETBOOKINGSTEP1, arguments: argument); Get.toNamed(Routes.TICKETBOOKINGSTEP1, arguments: argument);
}, },
), ),

View File

@ -183,14 +183,6 @@ class _TicketBookingStep3ScreenState extends State<TicketBookingStep3Screen> {
}); });
} }
List<String> _getSelectedServices() {
List<String> selectedServices = [];
if (_isChecked1) selectedServices.add("Keberangkatan: Fast Track");
if (_isChecked2) selectedServices.add("Kedatangan: Porter VIP");
if (_isChecked3) selectedServices.add("Transit: Transit");
return selectedServices;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
totalPrice = calculateTotalPrice(flightData?.price.toDouble() ?? 0.0, passenger); totalPrice = calculateTotalPrice(flightData?.price.toDouble() ?? 0.0, passenger);

View File

@ -36,6 +36,7 @@ class _TicketBookingStep4ScreenState extends State<TicketBookingStep4Screen> {
double? totalPrice; double? totalPrice;
double? grandTotal; double? grandTotal;
final double serviceCharge = 10000.0;
final TicketController ticketController = Get.find<TicketController>(); final TicketController ticketController = Get.find<TicketController>();
FlightModel? flightData; FlightModel? flightData;
@ -109,6 +110,10 @@ class _TicketBookingStep4ScreenState extends State<TicketBookingStep4Screen> {
return '0'; return '0';
} }
double totalAll() {
return (grandTotal ?? 0.0) + serviceCharge;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final hasDeparturePorter = final hasDeparturePorter =
@ -187,8 +192,11 @@ class _TicketBookingStep4ScreenState extends State<TicketBookingStep4Screen> {
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
), ),
SizedBox(width: 8.w), SizedBox(width: 8.w),
TypographyStyles.small("x ${passenger}", TypographyStyles.small(
color: GrayColors.gray600, fontWeight: FontWeight.w400) "x ${passenger}",
color: GrayColors.gray600,
fontWeight: FontWeight.w400,
)
], ],
), ),
Padding( Padding(
@ -213,7 +221,11 @@ class _TicketBookingStep4ScreenState extends State<TicketBookingStep4Screen> {
SizedBox(height: 2.h), SizedBox(height: 2.h),
_buildTextService(), _buildTextService(),
SizedBox(height: 2.h), SizedBox(height: 2.h),
_buildRowText(context, text: "Biaya layanan", valueText: "10.000"), _buildRowText(
context,
text: "Biaya layanan",
valueText: "Rp ${NumberFormat.decimalPattern('id_ID').format(serviceCharge)}",
),
], ],
)) ))
], ],
@ -222,11 +234,23 @@ class _TicketBookingStep4ScreenState extends State<TicketBookingStep4Screen> {
)), )),
bottomNavigationBar: FooterPrice( bottomNavigationBar: FooterPrice(
labelText: "Pembayaran", labelText: "Pembayaran",
price: "Rp ${NumberFormat.decimalPattern('id_ID').format(grandTotal)}", price: "Rp ${NumberFormat.decimalPattern('id_ID').format(totalAll())}",
labelButton: "Buat Pesanan", labelButton: "Buat Pesanan",
iconButton: CustomeIcons.ProtectOutline(color: Colors.white), iconButton: CustomeIcons.ProtectOutline(color: Colors.white),
onTap: () { onTap: () {
Get.toNamed(Routes.PAYMENT); final argument = {
'ticketId': ticketId,
'flightId': flightId,
'date': ticketDate,
'passenger': passenger,
'selectedPassenger': selectedPassengers,
'numberSeat': numberSeat,
'totalPrice': totalPrice,
'grandTotal': grandTotal,
'selectedServiceLabels': selectedServiceLabels,
'selectedPorterServices': selectedPorterServices,
};
Get.toNamed(Routes.PAYMENT, arguments: argument);
}, },
)); ));
} }
@ -323,7 +347,7 @@ class _TicketBookingStep4ScreenState extends State<TicketBookingStep4Screen> {
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
), ),
TypographyStyles.caption( TypographyStyles.caption(
"Rp ${valueText}", valueText,
color: GrayColors.gray600, color: GrayColors.gray600,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
), ),