import 'package:equatable/equatable.dart'; /// What a staff member is allowed to do. enum StaffRole { admin('Admin', 'Full access to every module'), manager('Manager', 'Sales, inventory and reports'), cashier('Cashier', 'Billing and customers only'); const StaffRole(this.label, this.description); final String label; final String description; bool get canVoidSale => this != StaffRole.cashier; bool get canEditPricing => this == StaffRole.admin; bool get canViewReports => this != StaffRole.cashier; } /// A person who signs in at the terminal. /// /// Deliberately carries no PIN. It used to, which meant the credential was in /// memory, in every widget that held a user, and — because the accounts were /// declared as constants — inside the shipped binary. Verification now happens /// in `StaffDao` against a stored hash, and nothing above the data layer ever /// sees the secret. class StaffUser extends Equatable { const StaffUser({ required this.id, required this.name, required this.role, this.mustChangePin = false, this.isActive = true, }); final String id; final String name; final StaffRole role; /// Set on a seeded or admin-reset account until the person picks their own. final bool mustChangePin; /// Deactivated rather than deleted, so bills already rung keep pointing at a /// real person. final bool isActive; StaffUser copyWith({ String? name, StaffRole? role, bool? mustChangePin, bool? isActive, }) => StaffUser( id: id, name: name ?? this.name, role: role ?? this.role, mustChangePin: mustChangePin ?? this.mustChangePin, isActive: isActive ?? this.isActive, ); @override List get props => [id, name, role, mustChangePin, isActive]; } /// The registered outlet this terminal belongs to. class StoreAccount extends Equatable { const StoreAccount({ required this.id, required this.name, required this.email, required this.address, required this.gstin, required this.phone, required this.staff, this.plan = 'Business', }); final String id; final String name; final String email; final String address; final String gstin; final String phone; final List staff; final String plan; StoreAccount copyWith({ String? name, String? email, String? address, String? gstin, String? phone, List? staff, String? plan, }) => StoreAccount( id: id, name: name ?? this.name, email: email ?? this.email, address: address ?? this.address, gstin: gstin ?? this.gstin, phone: phone ?? this.phone, staff: staff ?? this.staff, plan: plan ?? this.plan, ); @override List get props => [id, name, email, address, gstin, phone, plan]; }