From 68011329211543c030af326940d67dae85d50d7d Mon Sep 17 00:00:00 2001 From: br0kenpixel <23280129+br0kenpixel@users.noreply.github.com> Date: Sat, 29 Nov 2025 14:56:33 +0100 Subject: [PATCH] refactor: rename `agreement` to `proof` --- .../Http/Controllers/InternshipController.php | 28 +++++++++---------- backend/app/Models/Internship.php | 4 +-- .../database/factories/InternshipFactory.php | 2 +- ..._10_20_193012_create_internships_table.php | 5 ++-- backend/routes/api.php | 4 +-- .../InternshipAgreementDownloader.vue | 4 +-- .../components/InternshipDocumentEditor.vue | 28 +++++++++---------- .../components/InternshipDocumentViewer.vue | 25 ++++++++++++----- frontend/app/types/internships.ts | 2 +- .../e2e/admin/internships/downloads.cy.ts | 2 +- 10 files changed, 57 insertions(+), 47 deletions(-) diff --git a/backend/app/Http/Controllers/InternshipController.php b/backend/app/Http/Controllers/InternshipController.php index 0768d61..a7d87ff 100644 --- a/backend/app/Http/Controllers/InternshipController.php +++ b/backend/app/Http/Controllers/InternshipController.php @@ -61,7 +61,7 @@ class InternshipController extends Controller return response()->json($internship); } - public function get_default_agreement(Request $request, int $id) + public function get_default_proof(Request $request, int $id) { $user = auth()->user(); $internship = Internship::find($id); @@ -78,7 +78,7 @@ class InternshipController extends Controller $contact = User::find($internship->company->contact); - $html = view('agreement.default', [ + $html = view('proof.default', [ 'company' => $internship->company, 'companyContact' => $contact, 'internship' => $internship, @@ -93,10 +93,10 @@ class InternshipController extends Controller return response($pdf->Output('', 'S'), 200) ->header('Content-Type', 'application/pdf') - ->header('Content-Disposition', 'attachment; filename="agreement_' . $id . '.pdf"'); + ->header('Content-Disposition', 'attachment; filename="proof_' . $id . '.pdf"'); } - public function get_agreement(int $id) + public function get_proof(int $id) { $user = auth()->user(); $internship = Internship::find($id); @@ -107,9 +107,9 @@ class InternshipController extends Controller ], 400); } - if (!$internship->agreement) { + if (!$internship->proof) { return response()->json([ - 'message' => 'No agreement file exists for this internship.' + 'message' => 'No proof file exists for this internship.' ], 404); } @@ -117,9 +117,9 @@ class InternshipController extends Controller abort(403, 'Unauthorized'); } - return response($internship->agreement, 200) + return response($internship->proof, 200) ->header('Content-Type', 'application/pdf') - ->header('Content-Disposition', 'attachment; filename="agreement_' . $id . '.pdf"'); + ->header('Content-Disposition', 'attachment; filename="proof_' . $id . '.pdf"'); } public function get_report(int $id) @@ -182,7 +182,7 @@ class InternshipController extends Controller 'year_of_study' => $request->year_of_study, 'semester' => $request->semester, 'position_description' => $request->position_description, - 'agreement' => null + 'proof' => null ]); InternshipStatusData::create([ @@ -250,13 +250,13 @@ class InternshipController extends Controller } $request->validate([ - 'agreement' => ['nullable', 'file', 'mimes:pdf', 'max:10240'], + 'proof' => ['nullable', 'file', 'mimes:pdf', 'max:10240'], 'report' => ['nullable', 'file', 'mimes:pdf', 'max:10240'], 'report_confirmed' => ['required', 'boolean'], ]); - if ($request->hasFile('agreement')) { - $internship->agreement = file_get_contents($request->file('agreement')->getRealPath()); + if ($request->hasFile('proof')) { + $internship->proof = file_get_contents($request->file('proof')->getRealPath()); } if ($request->hasFile('report')) { @@ -264,9 +264,9 @@ class InternshipController extends Controller } if ($user->role === 'EMPLOYER') { - if ($request->report_confirmed && (!$internship->agreement || !$internship->report)) { + if ($request->report_confirmed && (!$internship->proof || !$internship->report)) { return response()->json([ - 'message' => 'Report cannot be confirmed without an agreement and report.' + 'message' => 'Report cannot be confirmed without an proof and report.' ], 400); } diff --git a/backend/app/Models/Internship.php b/backend/app/Models/Internship.php index eb66005..fa77655 100644 --- a/backend/app/Models/Internship.php +++ b/backend/app/Models/Internship.php @@ -25,7 +25,7 @@ class Internship extends Model 'year_of_study', 'semester', 'position_description', - 'agreement', + 'proof', 'report', 'report_confirmed', ]; @@ -135,7 +135,7 @@ class Internship extends Model 'year_of_study' => $this->year_of_study, 'semester' => $this->semester, 'position_description' => $this->position_description, - 'agreement' => $this->agreement !== null, + 'proof' => $this->proof !== null, 'report' => $this->report !== null, 'report_confirmed' => $this->report_confirmed, 'status' => $this->status, diff --git a/backend/database/factories/InternshipFactory.php b/backend/database/factories/InternshipFactory.php index 4b0e117..f2dd600 100644 --- a/backend/database/factories/InternshipFactory.php +++ b/backend/database/factories/InternshipFactory.php @@ -27,7 +27,7 @@ class InternshipFactory extends Factory 'year_of_study' => fake()->randomElement([1, 2, 3, 4, 5]), 'semester' => fake()->randomElement(["WINTER", "SUMMER"]), 'position_description' => fake()->jobTitle(), - 'agreement' => null, + 'proof' => null, 'report' => null, 'report_confirmed' => false, ]; diff --git a/backend/database/migrations/2025_10_20_193012_create_internships_table.php b/backend/database/migrations/2025_10_20_193012_create_internships_table.php index 83571d4..b85d00c 100644 --- a/backend/database/migrations/2025_10_20_193012_create_internships_table.php +++ b/backend/database/migrations/2025_10_20_193012_create_internships_table.php @@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. */ @@ -20,7 +19,7 @@ return new class extends Migration $table->unsignedSmallInteger("year_of_study")->nullable(false); $table->enum("semester", ["WINTER", "SUMMER"])->nullable(false); $table->string("position_description")->nullable(false); - $table->binary("agreement")->nullable(true); + $table->binary("proof")->nullable(true); $table->binary("report")->nullable(true); $table->boolean("report_confirmed")->nullable(false)->default(false); $table->timestamps(); diff --git a/backend/routes/api.php b/backend/routes/api.php index a3310eb..a21ab05 100644 --- a/backend/routes/api.php +++ b/backend/routes/api.php @@ -49,8 +49,8 @@ Route::prefix('/internships')->group(function () { Route::put("/status", [InternshipStatusDataController::class, 'update'])->name("api.internships.status.update"); Route::get("/statuses", [InternshipStatusDataController::class, 'get'])->name("api.internships.get"); Route::get("/next-statuses", [InternshipStatusDataController::class, 'get_next_states'])->name("api.internships.status.next.get"); - Route::get("/default-agreement", [InternshipController::class, 'get_default_agreement'])->name("api.internships.agreement.default.get"); - Route::get("/agreement", [InternshipController::class, 'get_agreement'])->name("api.internships.agreement.get"); + Route::get("/default-proof", [InternshipController::class, 'get_default_proof'])->name("api.internships.proof.default.get"); + Route::get("/proof", [InternshipController::class, 'get_proof'])->name("api.internships.proof.get"); Route::get("/report", [InternshipController::class, 'get_report'])->name("api.internships.report.get"); Route::post("/documents", [InternshipController::class, 'update_documents'])->name("api.internships.documents.set"); Route::post("/basic", [InternshipController::class, 'update_basic'])->name("api.internships.update.basic"); diff --git a/frontend/app/components/InternshipAgreementDownloader.vue b/frontend/app/components/InternshipAgreementDownloader.vue index c82c0b9..ac18af3 100644 --- a/frontend/app/components/InternshipAgreementDownloader.vue +++ b/frontend/app/components/InternshipAgreementDownloader.vue @@ -13,8 +13,8 @@ async function requestDownload() { loading.value = true; try { - const agreement = await client(`/api/internships/${props.internship_id}/default-agreement`); - triggerDownload(agreement, `default-agreement-${props.internship_id}`); + const proof = await client(`/api/internships/${props.internship_id}/default-proof`); + triggerDownload(proof, `default-proof-${props.internship_id}`); } catch (e) { if (e instanceof FetchError) { alert(`Nepodarilo sa vygenerovať zmluvu: ${e.statusMessage}`); diff --git a/frontend/app/components/InternshipDocumentEditor.vue b/frontend/app/components/InternshipDocumentEditor.vue index d0dbd83..0524d42 100644 --- a/frontend/app/components/InternshipDocumentEditor.vue +++ b/frontend/app/components/InternshipDocumentEditor.vue @@ -18,7 +18,7 @@ const rules = { const loading = ref(false); const error = ref(null); -const agreement = ref(null); +const proof = ref(null); const report = ref(null); const report_confirmed = ref(props.internship.report_confirmed); @@ -35,9 +35,9 @@ function triggerDownload(file: Blob, file_name: string) { window.URL.revokeObjectURL(url); } -async function downloadAgreement() { - const agreement: Blob = await client(`/api/internships/${props.internship.id}/agreement`); - triggerDownload(agreement, `agreement-${props.internship.id}`); +async function downloadProof() { + const proof: Blob = await client(`/api/internships/${props.internship.id}/proof`); + triggerDownload(proof, `proof-${props.internship.id}`); } async function downloadReport() { @@ -51,8 +51,8 @@ async function onSubmit() { const formData = new FormData(); formData.append('report_confirmed', report_confirmed.value ? '1' : '0'); - if (agreement.value) { - formData.append('agreement', agreement.value); + if (proof.value) { + formData.append('proof', proof.value); } if (report.value) { formData.append('report', report.value); @@ -64,7 +64,7 @@ async function onSubmit() { body: formData }); - agreement.value = null; + proof.value = null; report.value = null; emit('successfulSubmit'); } catch (e) { @@ -87,18 +87,18 @@ async function onSubmit() {
-

Podpísaná zmluva / dohoda

+

Dokument na overenie praxe

- +
- + Stiahnuť
-
@@ -123,14 +123,14 @@ async function onSubmit() { hint="Povolené: PDF, max 10 MB" persistent-hint />
+ :disabled="!proof && !report && (!props.internship.proof || !props.internship.report)"> Uloziť
diff --git a/frontend/app/components/InternshipDocumentViewer.vue b/frontend/app/components/InternshipDocumentViewer.vue index d4dbb63..cce2841 100644 --- a/frontend/app/components/InternshipDocumentViewer.vue +++ b/frontend/app/components/InternshipDocumentViewer.vue @@ -8,8 +8,8 @@ const props = defineProps<{ const client = useSanctumClient(); async function downloadAgreement() { - const agreement: Blob = await client(`/api/internships/${props.internship.id}/agreement`); - triggerDownload(agreement, `agreement-${props.internship.id}`); + const proof: Blob = await client(`/api/internships/${props.internship.id}/proof`); + triggerDownload(proof, `proof-${props.internship.id}`); } async function downloadReport() { @@ -21,18 +21,21 @@ async function downloadReport() {