Skip to content

Commit

Permalink
Merge branch 'main' into prod/festapp
Browse files Browse the repository at this point in the history
  • Loading branch information
miakh committed Jan 11, 2025
2 parents fb1b3d2 + 6ee21d7 commit 5ca2f64
Show file tree
Hide file tree
Showing 28 changed files with 723 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.24.5"
"flutter": "3.27.1"
}
2 changes: 1 addition & 1 deletion .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.5'
flutter-version: '3.27.1'
channel: 'stable'

- run: flutter build web --web-renderer canvaskit --release --base-href /
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"dart.flutterSdkPath": ".fvm/versions/3.24.5"
"dart.flutterSdkPath": ".fvm/versions/3.27.1"
}
3 changes: 3 additions & 0 deletions android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
</adaptive-icon>
2 changes: 2 additions & 0 deletions assets/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,5 +349,7 @@
"Tickets": "Vstupenky",
"Orders": "Objednávky",
"State": "Stav",
"Do you want to send the tickets to orders?": "Chcete poslat vstupenky pro objednávky?",
"Send tickets": "Poslat vstupenky",
"_": "_"
}
2 changes: 2 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,5 +349,7 @@
"Tickets": "Tickets",
"Orders": "Orders",
"State": "State",
"Do you want to send the tickets to orders?": "Do you want to send the tickets to orders?",
"Send tickets": "Send tickets",
"_":"_"
}
4 changes: 2 additions & 2 deletions lib/AppRouter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class AppRouter extends RootStackRouter {
AutoRoute(page: InstallRoute.page, path: sl(InstallPage.ROUTE)),
AutoRoute(page: AdminDashboardRoute.page, path: sl(AdminDashboardPage.ROUTE)),
AutoRoute(page: AdminDashboardRoute.page, path: sl(AdminDashboardPage.ROUTE)),
AutoRoute(page: FormRoute.page, path: "/${FormPage.ROUTE}/:id"),
AutoRoute(page: FormEditRoute.page, path: "/${FormPage.ROUTE}/:formKey/edit"),
AutoRoute(page: FormRoute.page, path: "/${FormPage.ROUTE}/:formLink"),
AutoRoute(page: FormEditRoute.page, path: "/${FormPage.ROUTE}/:formLink/edit"),
AutoRoute(page: CheckRoute.page, path: "/:{$LINK}/${CheckPage.ROUTE}/:id"),
AutoRoute(page: NewsFormRoute.page, path: "/:{$LINK}/${NewsFormPage.ROUTE}"),
AutoRoute(page: HtmlEditorRoute.page, path: "/:{$LINK}/${HtmlEditorPage.ROUTE}"),
Expand Down
43 changes: 29 additions & 14 deletions lib/AppRouter.gr.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 15 additions & 11 deletions lib/dataModelsEshop/ProductModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ProductModel {
int? productType;
int? occasion;
String? productTypeString;
int? order;

static const String foodType = "food";
static const String taxiType = "taxi";
Expand All @@ -20,17 +21,18 @@ class ProductModel {

factory ProductModel.fromJson(Map<String, dynamic> json) {
return ProductModel(
id: json[TbEshop.products.id],
createdAt: json[TbEshop.products.created_at] != null ? DateTime.parse(json[TbEshop.products.created_at]) : null,
updatedAt: json[TbEshop.products.updated_at] != null ? DateTime.parse(json[TbEshop.products.updated_at]) : null,
title: json[TbEshop.products.title],
isHidden: json[TbEshop.products.is_hidden],
description: json[TbEshop.products.description],
price: json[TbEshop.products.price] != null ? double.tryParse(json[TbEshop.products.price].toString()) : null,
data: json[TbEshop.products.data],
productType: json[TbEshop.products.product_type],
occasion: json[TbEshop.products.occasion],
productTypeString: json[metaTypeField],
id: json[TbEshop.products.id],
createdAt: json[TbEshop.products.created_at] != null ? DateTime.parse(json[TbEshop.products.created_at]) : null,
updatedAt: json[TbEshop.products.updated_at] != null ? DateTime.parse(json[TbEshop.products.updated_at]) : null,
title: json[TbEshop.products.title],
isHidden: json[TbEshop.products.is_hidden],
description: json[TbEshop.products.description],
price: json[TbEshop.products.price] != null ? double.tryParse(json[TbEshop.products.price].toString()) : null,
data: json[TbEshop.products.data],
productType: json[TbEshop.products.product_type],
occasion: json[TbEshop.products.occasion],
productTypeString: json[metaTypeField],
order: json[TbEshop.products.order] // Adding order to the JSON factory method
);
}

Expand All @@ -45,6 +47,7 @@ class ProductModel {
TbEshop.products.data: data,
TbEshop.products.product_type: productType,
TbEshop.products.occasion: occasion,
'order': order
};

String toBasicString() => title ?? id.toString();
Expand All @@ -61,5 +64,6 @@ class ProductModel {
this.productType,
this.occasion,
this.productTypeString,
this.order,
});
}
1 change: 1 addition & 0 deletions lib/dataModelsEshop/TbEshop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ProductsTb {
String get data => "data";
String get product_type => "product_type";
String get occasion => "occasion";
String get order => "order";
}

class OrderProductTicketTb {
Expand Down
9 changes: 7 additions & 2 deletions lib/dataModelsEshop/TicketModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TicketModel extends IPlutoRowModel {
double? totalPrice;

// Relating spots and products directly to the ticket
List<BlueprintObjectModel>? relatedSpots;
BlueprintObjectModel? relatedSpot;
List<ProductModel>? relatedProducts;

// Relating order directly to the ticket
Expand All @@ -34,6 +34,7 @@ class TicketModel extends IPlutoRowModel {
static const String metaRelatedOrder = "related_order";
static const String metaTicketsProducts = "ticket_products";
static const String metaPrice = "price";
static const String metaSpot = "spot";

TicketModel({
this.id,
Expand All @@ -44,7 +45,7 @@ class TicketModel extends IPlutoRowModel {
this.occasion,
this.note,
this.noteHidden,
this.relatedSpots,
this.relatedSpot,
this.relatedProducts,
this.relatedOrder,
});
Expand Down Expand Up @@ -95,6 +96,10 @@ class TicketModel extends IPlutoRowModel {
value: relatedProducts != null
? relatedProducts!.map((p)=>p.toBasicString()).join(" | ")
: ""),
metaSpot: PlutoCell(
value: relatedSpot != null
? relatedSpot?.toShortString()
: ""),
metaPrice: PlutoCell(value: totalPrice != null ? Utilities.formatPrice(context, totalPrice!) : ""),
});
}
Expand Down
51 changes: 38 additions & 13 deletions lib/dataServices/DbEshop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DbEshop {
"${TbEshop.product_types.id},"
"${TbEshop.product_types.type},"
"${TbEshop.product_types.title},"
"${TbEshop.products.table}(${TbEshop.products.id},${TbEshop.products.title},${TbEshop.products.price})"
"${TbEshop.products.table}(${TbEshop.products.id},${TbEshop.products.title},${TbEshop.products.price},${TbEshop.products.order})"
)
.eq(TbEshop.product_types.occasion, currentOccasion)
.eq("${TbEshop.products.table}.${TbEshop.products.is_hidden}", false);
Expand All @@ -37,7 +37,7 @@ class DbEshop {
data.map((x) {
var toReturn = ProductTypeModel.fromJson(x);
toReturn.products = toReturn.products?.sortedBy((i) => i.title ?? "");
toReturn.products = toReturn.products?.sortedBy<num>((i) => i.price ?? 0);
toReturn.products = toReturn.products?.sortedBy<num>((i) => i.order ?? 0);
for (ProductModel v in toReturn.products??[]){
v.title = v.price != null && v.price! > 0 ? "${v.title} (${Utilities.formatPrice(context, v.price!)})" : v.title;
}
Expand All @@ -51,9 +51,9 @@ class DbEshop {
return await _supabase.functions.invoke("send-ticket-order", body: {"orderDetails": data});
}

static Future<FormModel?> getForm(String formKey) async {
static Future<FormModel?> getFormFromLink(String link) async {
final response = await _supabase
.rpc('get_form', params: {'form_key': formKey});
.rpc('get_form_from_link', params: {'form_link': link});

if(response["code"] == 200){
var form = FormModel.fromJson(response["data"]);
Expand All @@ -62,11 +62,11 @@ class DbEshop {
return null;
}

static Future<FormModel?> getFormForEdit(String formKey) async {
static Future<FormModel?> getFormForEdit(String formLink) async {
var data = await _supabase
.from(Tb.forms.table)
.select()
.eq(Tb.forms.key, formKey)
.eq(Tb.forms.link, formLink)
.maybeSingle();
if(data==null)
{
Expand Down Expand Up @@ -125,7 +125,7 @@ class DbEshop {
final response = await _supabase.rpc(
'get_blueprint_editor',
params: {
'form_key': formKey,
'form_link': formKey,
},
);

Expand Down Expand Up @@ -176,12 +176,12 @@ class DbEshop {
return true;
}

static Future<List<OrderModel>> getAllOrders(String formKey) async {
static Future<List<OrderModel>> getAllOrders(String formLink) async {

final response = await _supabase.rpc(
'get_orders',
params: {
'form_key': formKey,
'form_link': formLink,
},
);

Expand All @@ -206,9 +206,9 @@ class DbEshop {

for (var ticket in order.relatedTickets!) {
// Relate spots to the ticket via orderProductTickets
ticket.relatedSpots = spots!.where((spot) {
ticket.relatedSpot = spots!.firstWhereOrNull((spot) {
return orderProductTickets!.any((opt) => opt.ticketId == ticket.id && opt.id == spot.orderProductTicket);
}).toList();
});

// Relate products to the ticket via orderProductTickets
ticket.relatedProducts = products!.where((product) {
Expand Down Expand Up @@ -244,8 +244,8 @@ class DbEshop {
return orders.sortedBy((ou)=>ou.createdAt!).reversed.toList();
}

static Future<List<TicketModel>> getAllTickets(String formKey) async {
var orders = await getAllOrders(formKey);
static Future<List<TicketModel>> getAllTickets(String formLink) async {
var orders = await getAllOrders(formLink);
List<TicketModel> toReturn = [];
for(var o in orders){

Expand All @@ -266,6 +266,31 @@ class DbEshop {
toReturn = toReturn.sortedBy((ou)=>ou.createdAt!).reversed.toList();
return toReturn;
}

static Future<FunctionResponse> sendTicketsToEmail({
required List<int> ticketIds,
required String email,
required int oc, // Occasion ID
}) async {
final body = {
"ticketIds": ticketIds,
"email": email,
"oc": oc,
};

try {
final response = await _supabase.functions.invoke(
"send-tickets",
body: body,
);

return response;
} catch (e) {
print("Unexpected error in sendTicketsToEmail: $e");
rethrow;
}
}

static Future<void> deleteOrder(OrderModel model) async {

}
Expand Down
Loading

0 comments on commit 5ca2f64

Please sign in to comment.