Simplify lab trial dispatch and fix per-jaw pricing
This commit is contained in:
@@ -189,15 +189,19 @@ class _LabJobDetailScreenState extends ConsumerState<LabJobDetailScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
void _showHandToClinicSheet(Job job) {
|
||||
void _showHandToClinicSheet(Job job, {required bool finish}) {
|
||||
_showAdaptive(
|
||||
context,
|
||||
_HandToClinicSheet(
|
||||
job: job,
|
||||
finish: finish,
|
||||
onDone: (Job updated) {
|
||||
if (mounted) {
|
||||
setState(() => _job = updated.copyWith(
|
||||
clinicName: job.clinicName, labName: job.labName));
|
||||
setState(() {
|
||||
_job = updated.copyWith(
|
||||
clinicName: job.clinicName, labName: job.labName);
|
||||
_historyFuture = JobHistoryService.instance.listForJob(job.id);
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -525,20 +529,26 @@ class _LabJobDetailScreenState extends ConsumerState<LabJobDetailScreen> {
|
||||
backgroundColor: AppColors.success,
|
||||
),
|
||||
),
|
||||
if (canSendToClinic)
|
||||
if (canSendToClinic && job.provaRequired) ...[
|
||||
FilledButton.icon(
|
||||
onPressed: () => _showHandToClinicSheet(job),
|
||||
onPressed: () => _showHandToClinicSheet(job, finish: false),
|
||||
icon: const Icon(Icons.send_outlined),
|
||||
label: Text(
|
||||
(job.isLastStep)
|
||||
? 'Son Prova - Teslime Gönder'
|
||||
: 'Prova için Kliniğe Gönder',
|
||||
),
|
||||
label: const Text('Provaya Gönder'),
|
||||
style: FilledButton.styleFrom(
|
||||
minimumSize: const Size.fromHeight(52),
|
||||
backgroundColor: (job.isLastStep)
|
||||
? AppColors.success
|
||||
: AppColors.inProgress,
|
||||
backgroundColor: AppColors.inProgress,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
if (canSendToClinic)
|
||||
FilledButton.icon(
|
||||
onPressed: () => _showHandToClinicSheet(job, finish: true),
|
||||
icon: const Icon(Icons.check_circle_outline),
|
||||
label: const Text('Bitime Gönder'),
|
||||
style: FilledButton.styleFrom(
|
||||
minimumSize: const Size.fromHeight(52),
|
||||
backgroundColor: AppColors.success,
|
||||
),
|
||||
),
|
||||
if (canCancelJobs && job.status == JobStatus.pending) ...[
|
||||
@@ -674,8 +684,13 @@ class _LatestRevisionBanner extends StatelessWidget {
|
||||
// ── Hand to Clinic Sheet ─────────────────────────────────────────────────────
|
||||
|
||||
class _HandToClinicSheet extends StatefulWidget {
|
||||
const _HandToClinicSheet({required this.job, required this.onDone});
|
||||
const _HandToClinicSheet({
|
||||
required this.job,
|
||||
required this.finish,
|
||||
required this.onDone,
|
||||
});
|
||||
final Job job;
|
||||
final bool finish;
|
||||
final void Function(Job updatedJob) onDone;
|
||||
|
||||
@override
|
||||
@@ -685,6 +700,7 @@ class _HandToClinicSheet extends StatefulWidget {
|
||||
class _HandToClinicSheetState extends State<_HandToClinicSheet> {
|
||||
final _noteController = TextEditingController();
|
||||
bool _sending = false;
|
||||
String? _noteError;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -696,20 +712,8 @@ class _HandToClinicSheetState extends State<_HandToClinicSheet> {
|
||||
Widget build(BuildContext context) {
|
||||
final isDesktop =
|
||||
MediaQuery.sizeOf(context).width > AppLayout.sidebarBreakpoint;
|
||||
final currentStep = widget.job.currentStep;
|
||||
final isLast = widget.job.isLastStep;
|
||||
final stepLabel = currentStep?.label ?? '';
|
||||
final requiresClinicApproval = currentStep?.requiresClinicApproval ?? true;
|
||||
final continuesInLab = !widget.job.provaRequired &&
|
||||
currentStep == JobStep.olcuKontrol &&
|
||||
widget.job.nextStep == JobStep.cilaBitim;
|
||||
final buttonLabel = isLast
|
||||
? (widget.job.provaRequired
|
||||
? 'Son Prova · Teslime Gönder'
|
||||
: 'Teslime Gönder')
|
||||
: requiresClinicApproval && !continuesInLab
|
||||
? '$stepLabel için Kliniğe Gönder'
|
||||
: '$stepLabel tamamlandı, sonraki adıma geç';
|
||||
final isLast = widget.finish;
|
||||
final buttonLabel = isLast ? 'Bitime Gönder' : 'Provaya Gönder';
|
||||
final buttonColor = isLast ? AppColors.success : AppColors.inProgress;
|
||||
|
||||
return Container(
|
||||
@@ -737,18 +741,17 @@ class _HandToClinicSheetState extends State<_HandToClinicSheet> {
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
isLast
|
||||
? 'İş teslim edilecek olarak işaretlenecek.'
|
||||
: requiresClinicApproval && !continuesInLab
|
||||
? 'İş klinikteki prova veya onay için gönderilecek.'
|
||||
: 'Bu iç adım tamamlanacak ve iş laboratuvarda ilerleyecek.',
|
||||
? 'Cila / bitim tamamlandıktan sonra seçin. İş teslim için gönderildi olarak işaretlenecek.'
|
||||
: 'İş üretim aşamasında kalır. Klinik onayından sonra gerektiği kadar tekrar provaya gönderebilirsiniz.',
|
||||
style: const TextStyle(color: AppColors.textSecondary),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: _noteController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Not (isteğe bağlı)',
|
||||
hintText: 'Klinik için not ekleyin...',
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Aşama açıklaması',
|
||||
hintText: 'Yapılan işlemi ve klinik için açıklamanızı yazın...',
|
||||
errorText: _noteError,
|
||||
),
|
||||
maxLines: 3,
|
||||
),
|
||||
@@ -757,6 +760,10 @@ class _HandToClinicSheetState extends State<_HandToClinicSheet> {
|
||||
onPressed: _sending
|
||||
? null
|
||||
: () async {
|
||||
if (_noteController.text.trim().isEmpty) {
|
||||
setState(() => _noteError = 'Aşama açıklaması yazın.');
|
||||
return;
|
||||
}
|
||||
setState(() => _sending = true);
|
||||
final navigator = Navigator.of(context);
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
@@ -765,20 +772,17 @@ class _HandToClinicSheetState extends State<_HandToClinicSheet> {
|
||||
await LabJobsRepository.instance.handToClinic(
|
||||
widget.job.id,
|
||||
widget.job,
|
||||
note: _noteController.text.trim().isEmpty
|
||||
? null
|
||||
: _noteController.text.trim(),
|
||||
finish: widget.finish,
|
||||
note: _noteController.text.trim(),
|
||||
);
|
||||
widget.onDone(updated);
|
||||
navigator.pop();
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(isLast
|
||||
? 'İş teslim için gönderildi'
|
||||
: requiresClinicApproval && !continuesInLab
|
||||
? 'Onay için kliniğe gönderildi'
|
||||
: 'İş bir sonraki iç adıma geçirildi')),
|
||||
: 'İş provaya gönderildi')),
|
||||
);
|
||||
if (context.mounted) widget.onDone(updated);
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
setState(() => _sending = false);
|
||||
|
||||
Reference in New Issue
Block a user