fix outlet, fix category, fix printer
This commit is contained in:
parent
b2b2e2b111
commit
6fa45c8ac0
@ -1,5 +1,8 @@
|
||||
import '../../env.dart';
|
||||
import '../../injection.dart';
|
||||
|
||||
class AppConstant {
|
||||
static const String appName = "Apskel POS";
|
||||
static const String dbName = "apskel_pos.db";
|
||||
static String dbName = getIt<Env>().dbName;
|
||||
static const int cacheExpire = 10; // in minutes
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ class DatabaseHelper {
|
||||
|
||||
return await openDatabase(
|
||||
path,
|
||||
version: 2, // Updated version for categories table
|
||||
version: 1, // Updated version for categories table
|
||||
onCreate: _onCreate,
|
||||
onUpgrade: _onUpgrade,
|
||||
);
|
||||
@ -68,6 +68,7 @@ class DatabaseHelper {
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
business_type TEXT,
|
||||
sort_order INTEGER DEFAULT 0,
|
||||
metadata TEXT,
|
||||
is_active INTEGER DEFAULT 1,
|
||||
created_at TEXT,
|
||||
@ -106,13 +107,7 @@ class DatabaseHelper {
|
||||
await db.execute('CREATE INDEX idx_printers_type ON printers(type)');
|
||||
}
|
||||
|
||||
Future<void> _onUpgrade(Database db, int oldVersion, int newVersion) async {
|
||||
if (oldVersion < 2) {
|
||||
await db.execute(
|
||||
'ALTER TABLE categories ADD COLUMN "order" INTEGER DEFAULT 0',
|
||||
);
|
||||
}
|
||||
}
|
||||
Future<void> _onUpgrade(Database db, int oldVersion, int newVersion) async {}
|
||||
|
||||
Future<void> close() async {
|
||||
final db = await database;
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:injectable/injectable.dart';
|
||||
|
||||
abstract class Env {
|
||||
String get baseUrl;
|
||||
String get dbName;
|
||||
// add getter here...
|
||||
}
|
||||
|
||||
@ -9,7 +10,10 @@ abstract class Env {
|
||||
@dev
|
||||
class DevEnv implements Env {
|
||||
@override
|
||||
String get baseUrl => 'https://api-pos.apskel.id'; // example value
|
||||
String get baseUrl => 'https://api-pos.apskel.id';
|
||||
|
||||
@override
|
||||
String get dbName => "apskel_pos_dev.db"; // example value
|
||||
}
|
||||
|
||||
@Injectable(as: Env)
|
||||
@ -17,4 +21,7 @@ class DevEnv implements Env {
|
||||
class ProdEnv implements Env {
|
||||
@override
|
||||
String get baseUrl => 'https://api-pos.apskel.id';
|
||||
|
||||
@override
|
||||
String get dbName => "apskel_pos_dev.db";
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@ class AuthLocalDataProvider {
|
||||
try {
|
||||
await _sharedPreferences.remove(LocalStorageKey.token);
|
||||
await _sharedPreferences.remove(LocalStorageKey.user);
|
||||
await _sharedPreferences.remove(LocalStorageKey.outlet);
|
||||
} catch (e) {
|
||||
log('deleteAllAuthError', name: _logName, error: e);
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ class CategoryDto with _$CategoryDto {
|
||||
'name': name,
|
||||
'description': description,
|
||||
'business_type': businessType,
|
||||
'order': order,
|
||||
'sort_order': order,
|
||||
'metadata': metadata != null ? jsonEncode(metadata) : null,
|
||||
'created_at': createdAt,
|
||||
'updated_at': updatedAt,
|
||||
|
||||
@ -247,6 +247,11 @@ class PrinterRepository implements IPrinterRepository {
|
||||
);
|
||||
}
|
||||
|
||||
log(
|
||||
'Printer connected to bluetooth: ${printer.name}, ${printer.address}',
|
||||
name: _logName,
|
||||
);
|
||||
|
||||
bool printResult = await _printBluetooth(printData);
|
||||
if (!printResult) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../application/auth/auth_bloc.dart';
|
||||
import '../../../application/auth/logout/logout_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../components/assets/assets.gen.dart';
|
||||
@ -10,9 +11,20 @@ import '../../components/toast/flushbar.dart';
|
||||
import '../../router/app_router.gr.dart';
|
||||
|
||||
@RoutePage()
|
||||
class MainPage extends StatelessWidget {
|
||||
class MainPage extends StatefulWidget {
|
||||
const MainPage({super.key});
|
||||
|
||||
@override
|
||||
State<MainPage> createState() => _MainPageState();
|
||||
}
|
||||
|
||||
class _MainPageState extends State<MainPage> {
|
||||
@override
|
||||
void initState() {
|
||||
context.read<AuthBloc>().add(const AuthEvent.fetchCurrentUser());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<LogoutBloc, LogoutState>(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user