first commit
This commit is contained in:
15
lib/provider/all_service_provider.dart
Normal file
15
lib/provider/all_service_provider.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:queuedisplay/model/error_msg_model.dart';
|
||||
import 'package:queuedisplay/model/layanan_dokter.dart';
|
||||
|
||||
import '../model/service_model.dart';
|
||||
|
||||
final allServiceProvider = StateProvider<List<Layanan>>(
|
||||
(ref) => List.empty(),
|
||||
);
|
||||
final allServiceDoctorProvider = StateProvider<List<LayananDokter>>(
|
||||
(ref) => List.empty(),
|
||||
);
|
||||
final errorListMsgProvider = StateProvider<List<ErrorMsgModel>>(
|
||||
(ref) => List.empty(growable: true),
|
||||
);
|
||||
65
lib/provider/counter_provider.dart
Normal file
65
lib/provider/counter_provider.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:queuedisplay/model/counter_model.dart';
|
||||
import 'package:queuedisplay/repository/counter_repository.dart';
|
||||
|
||||
import '../repository/base_repository.dart';
|
||||
|
||||
import 'dio_provider.dart';
|
||||
|
||||
abstract class CounterListState extends Equatable {
|
||||
final DateTime date;
|
||||
const CounterListState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class CounterListStateInit extends CounterListState {
|
||||
CounterListStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class CounterListStateLoading extends CounterListState {
|
||||
CounterListStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class CounterListStateError extends CounterListState {
|
||||
final String message;
|
||||
CounterListStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class CounterListStateDone extends CounterListState {
|
||||
final List<Counter> model;
|
||||
CounterListStateDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class CounterListNotifier extends StateNotifier<CounterListState> {
|
||||
final Ref ref;
|
||||
CounterListNotifier({
|
||||
required this.ref,
|
||||
}) : super(CounterListStateInit());
|
||||
|
||||
void list() async {
|
||||
try {
|
||||
state = CounterListStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await CounterRepository(dio: dio).getData();
|
||||
state = CounterListStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = CounterListStateError(message: e.message);
|
||||
} else {
|
||||
state = CounterListStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final CounterProvider =
|
||||
StateNotifierProvider<CounterListNotifier, CounterListState>(
|
||||
(ref) => CounterListNotifier(ref: ref));
|
||||
4
lib/provider/dio_provider.dart
Normal file
4
lib/provider/dio_provider.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final dioProvider = Provider<Dio>((ref) => Dio());
|
||||
72
lib/provider/display_counter_dedicated_provider.dart
Normal file
72
lib/provider/display_counter_dedicated_provider.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../model/display_counter_dedicated_modelv2.dart';
|
||||
import '../repository/base_repository.dart';
|
||||
import '../repository/service_repository.dart';
|
||||
import 'dio_provider.dart';
|
||||
|
||||
abstract class DisplayCounterDedicatedState extends Equatable {
|
||||
final DateTime date;
|
||||
const DisplayCounterDedicatedState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class DisplayCounterDedicatedStateInit extends DisplayCounterDedicatedState {
|
||||
DisplayCounterDedicatedStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class DisplayCounterDedicatedStateLoading extends DisplayCounterDedicatedState {
|
||||
DisplayCounterDedicatedStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class DisplayCounterDedicatedStateError extends DisplayCounterDedicatedState {
|
||||
final String message;
|
||||
DisplayCounterDedicatedStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class DisplayCounterDedicatedStateDone extends DisplayCounterDedicatedState {
|
||||
// final List<DisplayCounterDedicatedModel> model;
|
||||
final List<DisplayCounterDedicatedModelV2> model;
|
||||
DisplayCounterDedicatedStateDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class DisplayLayananNotifier
|
||||
extends StateNotifier<DisplayCounterDedicatedState> {
|
||||
final Ref ref;
|
||||
DisplayLayananNotifier({
|
||||
required this.ref,
|
||||
}) : super(DisplayCounterDedicatedStateInit());
|
||||
|
||||
void listDisplayByCounterID(List<int> counterID, String branchID) async {
|
||||
try {
|
||||
state = DisplayCounterDedicatedStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await ServiceRepository(dio: dio)
|
||||
.getDataByCounterID(counterID, branchID);
|
||||
state = DisplayCounterDedicatedStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
if (e.message == "XMLHttpRequest error." ||
|
||||
e.message == "XMLHttpRequest error.") {
|
||||
state =
|
||||
DisplayCounterDedicatedStateError(message: "Connection Error");
|
||||
} else {
|
||||
state = DisplayCounterDedicatedStateError(message: e.message);
|
||||
}
|
||||
} else {
|
||||
state = DisplayCounterDedicatedStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final displayProvider =
|
||||
StateNotifierProvider<DisplayLayananNotifier, DisplayCounterDedicatedState>(
|
||||
(ref) => DisplayLayananNotifier(ref: ref));
|
||||
64
lib/provider/layanan_dokter_provider.dart
Normal file
64
lib/provider/layanan_dokter_provider.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../model/layanan_dokter.dart';
|
||||
import '../repository/base_repository.dart';
|
||||
import '../repository/service_repository_layanan_dokter.dart';
|
||||
import 'dio_provider.dart';
|
||||
|
||||
abstract class LayananListState extends Equatable {
|
||||
final DateTime date;
|
||||
const LayananListState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class LayananListStateInit extends LayananListState {
|
||||
LayananListStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class LayananListStateLoading extends LayananListState {
|
||||
LayananListStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class LayananListStateError extends LayananListState {
|
||||
final String message;
|
||||
LayananListStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class LayananListStateDone extends LayananListState {
|
||||
final List<LayananDokter> model;
|
||||
LayananListStateDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class LayananListNotifier extends StateNotifier<LayananListState> {
|
||||
final Ref ref;
|
||||
LayananListNotifier({
|
||||
required this.ref,
|
||||
}) : super(LayananListStateInit());
|
||||
|
||||
void list() async {
|
||||
try {
|
||||
state = LayananListStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await ServiceRepositoryLayananDokter(dio: dio).getData();
|
||||
state = LayananListStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = LayananListStateError(message: e.message);
|
||||
} else {
|
||||
state = LayananListStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final layananProvider =
|
||||
StateNotifierProvider<LayananListNotifier, LayananListState>(
|
||||
(ref) => LayananListNotifier(ref: ref));
|
||||
64
lib/provider/sampling_location_provider.dart
Normal file
64
lib/provider/sampling_location_provider.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:queuedisplay/model/sampling_location_model.dart';
|
||||
import 'package:queuedisplay/provider/dio_provider.dart';
|
||||
import 'package:queuedisplay/repository/sampling_location_repository.dart';
|
||||
|
||||
import '../repository/base_repository.dart';
|
||||
|
||||
abstract class SamplingLocationList extends Equatable {
|
||||
final DateTime date;
|
||||
const SamplingLocationList(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class SamplingLocationListInit extends SamplingLocationList {
|
||||
SamplingLocationListInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class SamplingLocationListLoading extends SamplingLocationList {
|
||||
SamplingLocationListLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class SamplingLocationListError extends SamplingLocationList {
|
||||
final String message;
|
||||
SamplingLocationListError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class SamplingLocationListDone extends SamplingLocationList {
|
||||
final List<SamplingLocation> model;
|
||||
SamplingLocationListDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class SamplingLocationListNotifier extends StateNotifier<SamplingLocationList> {
|
||||
final Ref ref;
|
||||
SamplingLocationListNotifier({
|
||||
required this.ref,
|
||||
}) : super(SamplingLocationListInit());
|
||||
|
||||
void list() async {
|
||||
try {
|
||||
state = SamplingLocationListLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await SamplingLocationRepository(dio: dio).getData();
|
||||
state = SamplingLocationListDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = SamplingLocationListError(message: e.message);
|
||||
} else {
|
||||
state = SamplingLocationListError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final SamplingLocationProvider =
|
||||
StateNotifierProvider<SamplingLocationListNotifier, SamplingLocationList>(
|
||||
(ref) => SamplingLocationListNotifier(ref: ref));
|
||||
64
lib/provider/service_provider.dart
Normal file
64
lib/provider/service_provider.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../model/service_model.dart';
|
||||
import '../repository/base_repository.dart';
|
||||
import '../repository/service_repository.dart';
|
||||
import 'dio_provider.dart';
|
||||
|
||||
abstract class ServiceListState extends Equatable {
|
||||
final DateTime date;
|
||||
const ServiceListState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class ServiceListStateInit extends ServiceListState {
|
||||
ServiceListStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class ServiceListStateLoading extends ServiceListState {
|
||||
ServiceListStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class ServiceListStateError extends ServiceListState {
|
||||
final String message;
|
||||
ServiceListStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class ServiceListStateDone extends ServiceListState {
|
||||
final List<Layanan> model;
|
||||
ServiceListStateDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class ServiceListNotifier extends StateNotifier<ServiceListState> {
|
||||
final Ref ref;
|
||||
ServiceListNotifier({
|
||||
required this.ref,
|
||||
}) : super(ServiceListStateInit());
|
||||
|
||||
void list(String branchID) async {
|
||||
try {
|
||||
state = ServiceListStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await ServiceRepository(dio: dio).getData(branchID);
|
||||
state = ServiceListStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = ServiceListStateError(message: e.message);
|
||||
} else {
|
||||
state = ServiceListStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final serviceProvider =
|
||||
StateNotifierProvider<ServiceListNotifier, ServiceListState>(
|
||||
(ref) => ServiceListNotifier(ref: ref));
|
||||
Reference in New Issue
Block a user