diff --git a/app/Http/Controllers/Admin/Manage/Cutting/CuttingController.php b/app/Http/Controllers/Admin/Manage/Cutting/CuttingController.php index b1f294c..7009f68 100644 --- a/app/Http/Controllers/Admin/Manage/Cutting/CuttingController.php +++ b/app/Http/Controllers/Admin/Manage/Cutting/CuttingController.php @@ -109,4 +109,11 @@ public function transitionStatus(CuttingStatusTransitionRequest $request, Cuttin return redirect()->route('admin.manage.cuttings.index'); } + + public function share(Cutting $cutting): Response + { + return Inertia::render('admin/manage/cuttings/Share', [ + 'cutting' => $this->cuttingService->findForShare($cutting), + ]); + } } diff --git a/app/Services/Manage/CuttingService.php b/app/Services/Manage/CuttingService.php index 9616575..f38c96c 100644 --- a/app/Services/Manage/CuttingService.php +++ b/app/Services/Manage/CuttingService.php @@ -211,6 +211,21 @@ public function findForEdit(Cutting $cutting): Cutting return $cutting; } + public function findForShare(Cutting $cutting): Cutting + { + $cutting->load([ + 'createdBy.profile', + 'materials.rawMaterialPrice.rawMaterial:id,name,unit', + 'results.productVariant.product:id,name', + 'results.productVariant:id,product_id,name', + ]); + + $this->appendCostPreview($cutting); + $cutting->materials->each(fn (CuttingMaterial $m) => $this->breakMaterialCircularReference($m)); + + return $cutting; + } + public function draftMaterialsForUser(User $user): array { return $this->draftMaterialsQuery($user) diff --git a/resources/js/components/button/RowShareAction.vue b/resources/js/components/button/RowShareAction.vue new file mode 100644 index 0000000..f55b6e5 --- /dev/null +++ b/resources/js/components/button/RowShareAction.vue @@ -0,0 +1,93 @@ + + + diff --git a/resources/js/components/button/index.ts b/resources/js/components/button/index.ts index a89000e..7548802 100644 --- a/resources/js/components/button/index.ts +++ b/resources/js/components/button/index.ts @@ -9,5 +9,6 @@ export { default as RowStatusAction } from './RowStatusAction.vue'; export { default as RowPrintAction } from './RowPrintAction.vue'; export { default as RowDetailAction } from './RowDetailAction.vue'; export { default as RowTransferAction } from './RowTransferAction.vue'; +export { default as RowShareAction } from './RowShareAction.vue'; export { default as CreateButton } from './CreateButton.vue'; export { default as BackButton } from './BackButton.vue'; diff --git a/resources/js/pages/admin/manage/cuttings/Share.vue b/resources/js/pages/admin/manage/cuttings/Share.vue new file mode 100644 index 0000000..d3ca33c --- /dev/null +++ b/resources/js/pages/admin/manage/cuttings/Share.vue @@ -0,0 +1,197 @@ + + + diff --git a/resources/js/pages/admin/manage/cuttings/table/data-table-actions.vue b/resources/js/pages/admin/manage/cuttings/table/data-table-actions.vue index c7da2b2..a32d9e8 100644 --- a/resources/js/pages/admin/manage/cuttings/table/data-table-actions.vue +++ b/resources/js/pages/admin/manage/cuttings/table/data-table-actions.vue @@ -2,7 +2,7 @@ import { router } from '@inertiajs/vue3'; import { computed, ref } from 'vue'; import { toast } from 'vue-sonner'; -import { RowDeleteAction, RowEditAction, RowStatusAction } from '@/components/button'; +import { RowDeleteAction, RowEditAction, RowShareAction, RowStatusAction } from '@/components/button'; import ConfirmDialog from '@/components/ConfirmDialog.vue'; import OwnerVerificationRowActions from '@/components/owner-verification/OwnerVerificationRowActions.vue'; import { useCan } from '@/composables/useCan'; @@ -104,6 +104,8 @@ function transitionStatus() { :label="action.label" :destructive="action.destructive" @click="openStatusConfirm(action)" /> + +