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