22 Commits

Author SHA1 Message Date
43b056f412 fix: broken cypress tests due to new internship list view
Some checks failed
Cypress E2E Tests / cypress-tests (push) Has been cancelled
2025-12-04 12:46:10 +01:00
Veronika Fehérvíziová
b9be4a2e6c fix: allow changing internship status when denied by admin 2025-12-02 22:53:01 +01:00
Veronika Fehérvíziová
06e6e59a18 feat: notify company of internship status updates 2025-12-02 22:52:22 +01:00
Veronika Fehérvíziová
a9ac8a2735 refactor: rename contact method to contactPerson to avoid default conflicts 2025-12-02 22:51:53 +01:00
Veronika Fehérvíziová
01aae85efc refactor: update email template for internship status updates 2025-12-02 22:51:29 +01:00
Veronika Fehérvíziová
b95cdb070d Revert "refactor: increase the number of users and companies in seeder"
This reverts commit 1d2016c011.
2025-12-02 20:40:10 +01:00
Veronika Fehérvíziová
e64b6c2eca feat: add dynamic max year of study based on selected program in registration form 2025-12-02 20:32:31 +01:00
Veronika Fehérvíziová
4a5a4f990c feat: improve phone input validation and update study program options in registration form 2025-12-02 20:28:17 +01:00
Veronika Fehérvíziová
2b31c1d2ad feat: enhance phone input validation in registration form 2025-12-02 20:27:59 +01:00
Veronika Fehérvíziová
b612c0f873 feat: add validation rules for internship filter inputs 2025-12-02 20:26:14 +01:00
Veronika Fehérvíziová
9de30a7df1 refactor: improve address generation in Company and Student data factories 2025-12-02 19:30:54 +01:00
Veronika Fehérvíziová
1d2016c011 refactor: increase the number of users and companies in seeder 2025-12-02 19:30:42 +01:00
Veronika Fehérvíziová
687018e0fe rename and translate CLI command for admin create 2025-12-02 19:10:13 +01:00
Veronika Fehérvíziová
6902eadef5 refactor: rename CLI for creating admin 2025-12-02 19:00:04 +01:00
Andrej
d570ca3398 fix: missing query when requesting internsip csv export
Some checks failed
Cypress E2E Tests / cypress-tests (push) Has been cancelled
2025-12-01 19:44:34 +01:00
Andrej
bef5a596ba feat: add export functionality for internships to CSV in admin internships dashboard 2025-12-01 19:38:02 +01:00
Andrej
c63f973f15 feat: enhance InternshipListView to support events 2025-12-01 19:37:34 +01:00
Andrej
ddf6787b76 feat: update triggerDownload function to accept file extension parameter 2025-12-01 19:37:06 +01:00
Andrej
3a9f9c0d58 feat: add InternshipFilter interface 2025-12-01 19:36:09 +01:00
Andrej
4a26fa82d3 feat: implement API route for exporting internships into CSV 2025-12-01 19:35:22 +01:00
Andrej
1ab02ae489 feat: add API route for exporting internships into CSV 2025-12-01 19:34:51 +01:00
Veronika Fehérvíziová
b08311e90b fix: invalid dialog title when removing internship 2025-11-30 21:31:18 +01:00
21 changed files with 303 additions and 175 deletions

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use Hash;
class CreateAdmin extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:create-admin';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new admin user';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('=== Create Admin ===');
// Načítanie údajov interaktívne
$firstName = $this->ask('First name');
$lastName = $this->ask('Last name');
$email = $this->ask('E-mail');
// Kontrola duplicity emailu
if (User::where('email', $email)->exists()) {
$this->error('A user with the same email already exists.');
return 1;
}
$password = $this->secret('Enter password');
$phone = $this->ask('Enter phone number');
// Vytvorenie používateľa
$user = User::create([
'name' => $firstName . ' ' . $lastName,
'first_name' => $firstName,
'last_name' => $lastName,
'email' => $email,
'password' => Hash::make($password),
'active' => true,
'role' => 'ADMIN',
'phone' => $phone,
]);
$this->info("\n Admin {$user->first_name} {$user->last_name} created.");
return 0;
}
}

View File

@@ -1,59 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
class CreateGarant extends Command
{
/**
* Názov CLI príkazu.
*/
protected $signature = 'user:create-garant';
/**
* Popis príkazu.
*/
protected $description = 'Interaktívne vytvorí nového používateľa s rolou admin (garant)';
/**
* Spustenie príkazu.
* php artisan user:create-garant
*/
public function handle()
{
$this->info('=== Vytvorenie garanta (admin) ===');
// Načítanie údajov interaktívne
$firstName = $this->ask('Zadaj krstné meno');
$lastName = $this->ask('Zadaj priezvisko');
$email = $this->ask('Zadaj email');
// Kontrola duplicity emailu
if (User::where('email', $email)->exists()) {
$this->error('Používateľ s týmto emailom už existuje.');
return 1;
}
$password = $this->secret('Zadaj heslo (nebude sa zobrazovať)');
$phone = $this->ask('Zadaj telefón ');
// Vytvorenie používateľa
$user = User::create([
'name' => $firstName . ' ' . $lastName,
'first_name' => $firstName,
'last_name' => $lastName,
'email' => $email,
'phone' => $phone,
'role' => 'ADMIN',
'password' => Hash::make($password),
]);
$this->info("\n Garant {$user->first_name} {$user->last_name} bol úspešne vytvorený s rolou ADMIN.");
$this->info("Email: {$user->email}");
return 0;
}
}

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Models\Internship;
use App\Models\InternshipStatusData;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Mpdf\Mpdf;
@@ -12,54 +13,7 @@ class InternshipController extends Controller
{
public function all(Request $request)
{
$user = $request->user();
$request->validate([
'year' => 'nullable|integer',
'company' => 'nullable|string|min:3|max:32',
'study_programe' => 'nullable|string|min:3|max:32',
'student' => 'nullable|string|min:3|max:32',
'page' => 'nullable|integer|min:1',
'per_page' => 'nullable|integer|min:-1|max:100',
]);
$perPage = $request->input('per_page', 15);
// Handle "All" items (-1)
if ($perPage == -1) {
$perPage = Internship::count();
}
$internships = Internship::query()
->with(['student.studentData'])
->when($request->year, function ($query, $year) {
$query->whereYear('start', $year);
})
->when($request->company, function ($query, $company) {
$query->whereHas('company', function ($q) use ($company) {
$q->where('name', 'like', "%$company%");
});
})
->when($request->study_programe, function ($query, $studyPrograme) {
$query->whereHas('student.studentData', function ($q) use ($studyPrograme) {
$q->where('study_field', 'like', "%$studyPrograme%");
});
})
->when($request->student, function ($query, $student) {
$query->whereHas('student', function ($q) use ($student) {
$q->where('name', 'like', "%$student%");
});
})
->when($user->role === 'STUDENT', function ($query) use ($user) {
$query->where('user_id', '=', $user->id);
})
->when($user->role === 'EMPLOYER', function ($query) use ($user) {
$query->whereHas('company', function ($q) use ($user) {
$q->where('contact', 'like', $user->id);
});
})
->paginate($perPage);
$internships = $this->filterSearch($request);
return response()->json($internships);
}
@@ -169,6 +123,43 @@ class InternshipController extends Controller
->header('Content-Disposition', 'attachment; filename="report_' . $id . '.pdf"');
}
public function export(Request $request)
{
$internships = $this->filterSearch($request, true);
$csv_header = [
'ID',
'Student',
'Company',
'Start',
'End',
'YearOfStudy',
'Semester',
'StudyField',
'Status'
];
$csv_content = implode(',', $csv_header) . "\n";
foreach ($internships as $internship) {
$data = [
$internship->id,
'"' . $internship->student->name . '"',
'"' . $internship->company->name . '"',
Carbon::parse($internship->start)->format('d.m.Y'),
Carbon::parse($internship->end)->format('d.m.Y'),
$internship->year_of_study,
$internship->semester,
$internship->student->studentData->study_field,
$internship->status->status->value
];
$csv_content .= implode(',', $data) . "\n";
}
return response($csv_content, 200)
->header('Content-Type', 'application/csv')
->header('Content-Disposition', 'attachment; filename="internships.csv"');
}
/**
* Display a listing of the resource.
*/
@@ -364,4 +355,61 @@ class InternshipController extends Controller
], 400));
}
}
private function filterSearch(Request $request, bool $ignorePage = false)
{
$user = $request->user();
$request->validate([
'year' => 'nullable|integer',
'company' => 'nullable|string|min:3|max:32',
'study_programe' => 'nullable|string|min:3|max:32',
'student' => 'nullable|string|min:3|max:32',
'page' => 'nullable|integer|min:1',
'per_page' => 'nullable|integer|min:-1|max:100',
]);
if ($ignorePage) {
$request->merge(['per_page' => -1]);
}
$perPage = $request->input('per_page', 15);
// Handle "All" items (-1)
if ($perPage == -1) {
$perPage = Internship::count();
}
$internships = Internship::query()
->with(['student.studentData'])
->when($request->year, function ($query, $year) {
$query->whereYear('start', $year);
})
->when($request->company, function ($query, $company) {
$query->whereHas('company', function ($q) use ($company) {
$q->where('name', 'like', "%$company%");
});
})
->when($request->study_programe, function ($query, $studyPrograme) {
$query->whereHas('student.studentData', function ($q) use ($studyPrograme) {
$q->where('study_field', 'like', "%$studyPrograme%");
});
})
->when($request->student, function ($query, $student) {
$query->whereHas('student', function ($q) use ($student) {
$q->where('name', 'like', "%$student%");
});
})
->when($user->role === 'STUDENT', function ($query) use ($user) {
$query->where('user_id', '=', $user->id);
})
->when($user->role === 'EMPLOYER', function ($query) use ($user) {
$query->whereHas('company', function ($q) use ($user) {
$q->where('contact', 'like', $user->id);
});
})
->paginate($perPage);
return $internships;
}
}

View File

@@ -123,17 +123,30 @@ class InternshipStatusDataController extends Controller
'modified_by' => $user->id
]);
// mail študentovi
Mail::to($internship->student)
->sendNow(new InternshipStatusUpdated(
$internship,
$user->name,
$internship->student->name,
$internship->company->name,
$internshipStatus->status,
$request->enum('status', InternshipStatus::class),
$request->note
$newStatus->status,
$request->note,
$user,
recipiantIsStudent: true,
));
// ak zmenu nevykonala firma, posleme mail aj firme
if ($user->id !== $internship->company->contactPerson->id) {
Mail::to($internship->company->contactPerson->email)
->sendNow(new InternshipStatusUpdated(
$internship,
$internshipStatus->status,
$newStatus->status,
$request->note,
$user,
recipiantIsStudent: false,
));
}
$newStatus->save();
return response()->noContent();
}

View File

@@ -4,6 +4,7 @@ namespace App\Mail;
use App\Enums\InternshipStatus;
use App\Models\Internship;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
@@ -15,25 +16,23 @@ class InternshipStatusUpdated extends Mailable
use Queueable, SerializesModels;
private Internship $internship;
private string $changedByName;
private string $studentName;
private string $companyName;
private InternshipStatus $oldStatus;
private InternshipStatus $newStatus;
private string $note;
private User $changedBy;
private bool $recipiantIsStudent;
/**
* Create a new message instance.
*/
public function __construct(Internship $internship, string $changedByName, string $studentName, string $companyName, InternshipStatus $oldStatus, InternshipStatus $newStatus, string $note)
public function __construct(Internship $internship, InternshipStatus $oldStatus, InternshipStatus $newStatus, string $note, User $changedBy, bool $recipiantIsStudent)
{
$this->internship = $internship;
$this->changedByName = $changedByName;
$this->studentName = $studentName;
$this->companyName = $companyName;
$this->oldStatus = $oldStatus;
$this->newStatus = $newStatus;
$this->note = $note;
$this->changedBy = $changedBy;
$this->recipiantIsStudent = $recipiantIsStudent;
}
/**
@@ -55,12 +54,11 @@ class InternshipStatusUpdated extends Mailable
view: 'mail.internship.status_updated',
with: [
"internship" => $this->internship,
"changedByName" => $this->changedByName,
"studentName" => $this->studentName,
"companyName" => $this->companyName,
"oldStatus" => $this->prettyStatus($this->oldStatus->value),
"newStatus" => $this->prettyStatus($this->newStatus->value),
"note" => $this->note,
"recipiantIsStudent" => $this->recipiantIsStudent,
"changedBy" => $this->changedBy,
]
);
}

View File

@@ -44,7 +44,7 @@ class Company extends Model
/**
* Get the contact person (user) for the company.
*/
public function contact()
public function contactPerson()
{
return $this->belongsTo(User::class, 'contact');
}

View File

@@ -107,6 +107,10 @@ class Internship extends Model
$current_status === InternshipStatus::CONFIRMED_BY_ADMIN && $userRole === "ADMIN" && !$report_confirmed
=> ['DENIED_BY_ADMIN', 'CONFIRMED_BY_COMPANY', 'DENIED_BY_COMPANY'],
// prax bola zamietnutá garantom a ide ju meniť garant
$current_status === InternshipStatus::DENIED_BY_ADMIN && $userRole === "ADMIN"
=> ['CONFIRMED_BY_COMPANY', 'CONFIRMED_BY_ADMIN', 'DENIED_BY_COMPANY'],
// prax bola obhájená a ide ju meniť admin
$current_status === InternshipStatus::DEFENDED && $userRole === "ADMIN"
=> ['NOT_DEFENDED'],

View File

@@ -18,7 +18,7 @@ class CompanyFactory extends Factory
{
return [
'name' => fake()->company(),
'address' => fake()->address(),
'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
'ico' => fake()->numberBetween(111111, 999999),
'contact' => 0,
'hiring' => fake()->boolean(),

View File

@@ -18,7 +18,7 @@ class StudentDataFactory extends Factory
{
return [
'user_id' => 0,
'address' => fake()->address(),
'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
'personal_email' => fake()->safeEmail(),
'study_field' => fake()->randomElement(["AI22m", "AI22b"]),
];

View File

@@ -1,14 +1,21 @@
@include("parts.header")
<p>Vážená/ý {{ $studentName }},</p>
<p>stav vašej praxe vo firme {{ $companyName }} bola aktualizovaná zo stavu "{{ $oldStatus }}" na
"{{ $newStatus }}".</p>
<p>Zmenu vykonal <em>{{ $changedByName }}</em>.</p>
<br />
@if($recipiantIsStudent)
<p>Vážená/ý {{ $internship->student->name }},</p>
@else
<p>Vážená/ý {{ $internship->company->contactPerson->name }},</p>
@endif
<p>oznamujeme Vás o zmene praxe:</p>
@if(!$recipiantIsStudent)
<p>Študent: <em>{{ $internship->student->name }} ({{ $internship->student->email }},
{{ $internship->student->phone }})</em></p>
@endif
<p>Stav: <em>{{ $oldStatus }}</em> <strong>-></strong> <em>{{ $newStatus }}</em></p>
<p>Poznámka: <em>{{ $note }}</em>.</p>
<p>Zmenu vykonal <em>{{ $changedBy->name }}</em>.</p>
<br />
<p>s pozdravom</p>
<p>S pozdravom.</p>
<p>Systém ISOP UKF</p>
@include("parts.footer")

View File

@@ -43,6 +43,7 @@ Route::post('/password-reset', [RegisteredUserController::class, 'reset_password
Route::prefix('/internships')->group(function () {
Route::get("/", [InternshipController::class, 'all'])->middleware(['auth:sanctum'])->name("api.internships");
Route::get("/export", [InternshipController::class, 'export'])->middleware(AdministratorOnly::class)->name("api.internships.export");
Route::prefix('/{id}')->middleware("auth:sanctum")->group(function () {
Route::get("/", [InternshipController::class, 'get'])->name("api.internships.get");

View File

@@ -15,7 +15,7 @@ async function requestDownload() {
try {
const proof = await client<Blob>(`/api/internships/${props.internship_id}/default-proof`);
triggerDownload(proof, `default-proof-${props.internship_id}`);
triggerDownload(proof, `default-proof-${props.internship_id}`, 'pdf');
} catch (e) {
if (e instanceof FetchError) {
alert(`Nepodarilo sa vygenerovať zmluvu: ${e.statusMessage}`);

View File

@@ -9,12 +9,12 @@ const client = useSanctumClient();
async function downloadAgreement() {
const proof: Blob = await client(`/api/internships/${props.internship.id}/proof`);
triggerDownload(proof, `proof-${props.internship.id}`);
triggerDownload(proof, `proof-${props.internship.id}`, 'pdf');
}
async function downloadReport() {
const report: Blob = await client(`/api/internships/${props.internship.id}/report`);
triggerDownload(report, `report-${props.internship.id}`);
triggerDownload(report, `report-${props.internship.id}`, 'pdf');
}
</script>

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Internship } from '~/types/internships';
import type { Internship, InternshipFilter } from '~/types/internships';
import type { Paginated } from '~/types/pagination';
import { prettyInternshipStatus } from '~/types/internship_status';
import { FetchError } from 'ofetch';
@@ -7,8 +7,12 @@ import { FetchError } from 'ofetch';
const props = defineProps<{
mode: 'admin' | 'company' | 'student';
}>();
const emit = defineEmits<{
filterApplied: [value: InternshipFilter],
itemsAvailable: [value: boolean]
}>();
const filters = ref({
const filters = ref<InternshipFilter>({
year: null,
company: null,
study_programe: null,
@@ -21,6 +25,11 @@ const totalItems = ref(0);
const deleteConfirmDialog = ref(false);
const internshipToDelete = ref<Internship | null>(null);
const rules = {
minFilterLen: (v: string) => (v.length >= 3) || 'Min. 3 znaky',
minYear: (v: number | null) => (v === null ? true : v >= 1000) || 'Min. 4-ciferné číslo'
};
const allHeaders = [
{ title: "Študent", key: "student.name", sortable: false },
{ title: "Firma", key: "company.name", sortable: false },
@@ -50,10 +59,12 @@ const { data, error, pending, refresh } = await useLazySanctumFetch<Paginated<In
watch(data, (newData) => {
totalItems.value = newData?.total ?? 0;
emit('itemsAvailable', totalItems.value > 0);
});
watch(filters, async () => {
page.value = 1;
emit('filterApplied', filters.value);
}, { deep: true });
async function delteInternship(internship: Internship) {
@@ -93,16 +104,20 @@ async function confirmDeletion(confirm: boolean) {
<v-row>
<v-col cols="12" md="3">
<v-text-field v-model="filters.year" label="Rok" type="number" clearable density="compact" />
<v-text-field v-model="filters.year" label="Rok" type="number" clearable density="compact"
:rules="[rules.minYear]" />
</v-col>
<v-col cols="12" md="3" v-if="mode !== 'company'">
<v-text-field v-model="filters.company" label="Názov firmy" clearable density="compact" />
<v-text-field v-model="filters.company" label="Názov firmy" clearable density="compact"
:rules="[rules.minFilterLen]" />
</v-col>
<v-col cols="12" md="3" v-if="mode !== 'student'">
<v-text-field v-model="filters.study_programe" label="Študijný program" clearable density="compact" />
<v-text-field v-model="filters.study_programe" label="Študijný program" clearable density="compact"
:rules="[rules.minFilterLen]" />
</v-col>
<v-col cols="12" md="3" v-if="mode !== 'student'">
<v-text-field v-model="filters.student" label="Študent" clearable density="compact" />
<v-text-field v-model="filters.student" label="Študent" clearable density="compact"
:rules="[rules.minFilterLen]" />
</v-col>
</v-row>
@@ -121,13 +136,13 @@ async function confirmDeletion(confirm: boolean) {
<v-tooltip text="Editovať">
<template #activator="{ props }">
<v-btn icon="mdi-pencil" size="small" variant="text"
:to="`/dashboard/${mode}/internships/edit/${item.id}`" />
:to="`/dashboard/${mode}/internships/edit/${item.id}`" class="internship-edit-btn" />
</template>
</v-tooltip>
<v-tooltip text="Vymazať" v-if="mode === 'admin'">
<template #activator="{ props }">
<v-btn icon="mdi-delete" size="small" variant="text" color="error"
@click="() => openDeleteDialog(item)" />
@click="() => openDeleteDialog(item)" class="internship-delete-btn" />
</template>
</v-tooltip>
</template>
@@ -137,7 +152,7 @@ async function confirmDeletion(confirm: boolean) {
<v-dialog v-model="deleteConfirmDialog" max-width="500px">
<v-card>
<v-card-title class="text-h5">
Nový API kľúč
Potvrdiť vymazanie praxe
</v-card-title>
<v-card-text>

View File

@@ -1,4 +1,7 @@
<script setup lang="ts">
import type { InternshipFilter } from '~/types/internships';
import { FetchError } from 'ofetch';
definePageMeta({
middleware: ['sanctum:auth', 'admin-only'],
});
@@ -20,6 +23,30 @@ const headers = [
{ title: 'Stav', key: 'status', align: 'middle' },
{ title: 'Operácie', key: 'ops', align: 'middle' },
];
const internshipFilters = ref<InternshipFilter | null>(null);
const exportPending = ref(false);
const exportAvailable = ref(true);
const client = useSanctumClient();
async function requestExport() {
exportPending.value = true;
try {
const file = await client<Blob>(`/api/internships/export`, {
method: 'GET',
query: internshipFilters.value ?? {},
});
triggerDownload(file, 'internships_export', 'csv');
} catch (e) {
if (e instanceof FetchError) {
alert(`Chyba pri exportovaní: ${e.statusMessage ?? e.message}`);
}
} finally {
exportPending.value = false;
}
}
</script>
<template>
@@ -30,7 +57,16 @@ const headers = [
<!-- spacer -->
<div style="height: 40px;"></div>
<InternshipListView mode="admin" />
<v-btn prepend-icon="mdi-file-export-outline" color="green" class="mr-2 mb-2" @click="requestExport"
:disabled="!exportAvailable" :loading="exportPending">
<v-tooltip activator="parent" location="top">
Exportovať aktuálne zobrazené výsledky do CSV súboru
</v-tooltip>
Export výsledkov
</v-btn>
<InternshipListView mode="admin" @filterApplied="(filters) => internshipFilters = filters"
@itemsAvailable="(available) => exportAvailable = available" />
</v-card>
</v-container>
</template>

View File

@@ -19,7 +19,8 @@ useSeoMeta({
const rules = {
required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole',
email: (v: string) => /.+@.+\..+/.test(v) || 'Zadajte platný email',
phone: (v: string) => (!v || /^[0-9 +()-]{6,}$/.test(v)) || 'Zadajte platné telefónne číslo',
phone: (v: string) =>
(!v || /^\+[0-9]{6,13}$/.test(v)) || 'Zadajte platné telefónne číslo. Príklad: +421908123456',
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
};
@@ -101,8 +102,8 @@ async function handleRegistration() {
density="comfortable" />
<v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:"
variant="outlined" density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón:" variant="outlined"
density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón (s predvoľbou):"
variant="outlined" density="comfortable" />
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />

View File

@@ -23,11 +23,14 @@ const rules = {
personal_email: (v: string) =>
/.+@.+\..+/.test(v) || 'Zadajte platný osobný email',
phone: (v: string) =>
(!v || /^[0-9 +()-]{6,}$/.test(v)) || 'Zadajte platné telefónne číslo',
(!v || /^\+[0-9]{6,13}$/.test(v)) || 'Zadajte platné telefónne číslo. Príklad: +421908123456',
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
};
const programs = [
'Aplikovaná informatika',
{ title: 'Aplikovaná informatika, Bc. (AI22b)', value: 'AI22b' },
{ title: 'Aplikovaná informatika, Bc. (AI15b)', value: 'AI15b' },
{ title: 'Aplikovaná informatika, Mgr. (AI22m)', value: 'AI22m' },
{ title: 'Aplikovaná informatika, Mgr. (AI15m)', value: 'AI15m' },
];
const isValid = ref(false);
@@ -38,10 +41,11 @@ const form = ref({
studentEmail: '',
personalEmail: '',
phone: '',
studyProgram: programs[0] as string,
studyProgram: programs[0]!.value,
year_of_study: 1,
consent: false,
});
const maxYearOfStudy = ref(0);
const loading = ref(false);
const error = ref(null as null | string);
@@ -80,6 +84,10 @@ async function handleRegistration() {
loading.value = false;
}
}
watch(form, (newForm) => {
maxYearOfStudy.value = newForm.studyProgram.slice(-1) === 'b' ? 3 : 2;
}, { deep: true, immediate: true });
</script>
<template>
@@ -109,14 +117,14 @@ async function handleRegistration() {
<v-text-field v-model="form.personalEmail" :rules="[rules.required, rules.personal_email]"
label="Alternatívny email:" variant="outlined" density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]" label="Telefón:"
variant="outlined" density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]"
label="Telefón (s predvoľbou):" variant="outlined" density="comfortable" />
<v-select v-model="form.studyProgram" :items="programs" :rules="[rules.required]"
label="Študijný odbor:" variant="outlined" density="comfortable" />
<v-number-input control-variant="split" v-model="form.year_of_study" :rules="[rules.required]"
label="Ročník:" :min="1" :max="5"></v-number-input>
label="Ročník:" :min="1" :max="maxYearOfStudy"></v-number-input>
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />

View File

@@ -27,6 +27,13 @@ export interface NewInternship {
position_description: string;
};
export interface InternshipFilter {
year: number | null;
company: string | null;
study_programe: string | null;
student: string | null;
};
export function convertDate(date: string): Date {
const matcher = /^\d\d.\d\d.\d\d\d\d$/;

View File

@@ -1,8 +1,8 @@
export function triggerDownload(file: Blob, file_name: string) {
export function triggerDownload(file: Blob, file_name: string, ext: string) {
const url = window.URL.createObjectURL(file);
const link = document.createElement('a');
link.href = url;
link.download = `${file_name}.pdf`;
link.download = `${file_name}.${ext}`;
link.target = "_blank";
link.click();
window.URL.revokeObjectURL(url);

View File

@@ -12,6 +12,7 @@ describe('Admin Student Document Downloads', () => {
cy.contains("Praxe").click()
cy.url().should('include', '/dashboard/admin/internships')
cy.wait(2000)
})
it('should be able to generate and download the default proof', () => {
@@ -24,13 +25,12 @@ describe('Admin Student Document Downloads', () => {
})
cy.get('@randomRow').within(() => {
cy.get('td').contains('Editovať').click()
cy.get('td').get('.internship-edit-btn').click()
})
})
cy.url().should('include', '/dashboard/admin/internships/edit/')
const downloadsFolder = Cypress.config("downloadsFolder");
cy.contains('Stiahnuť originálnu zmluvu').click()
cy.wait(2000)
})

View File

@@ -12,6 +12,7 @@ describe('Admin Internship CRUD', () => {
cy.contains("Praxe").click()
cy.url().should('include', '/dashboard/admin/internships')
cy.wait(2000)
})
it('should load the list of internships in a proper format', () => {
@@ -64,28 +65,15 @@ describe('Admin Internship CRUD', () => {
})
})
// Ešte nie je implementované mazanie
/*it('should be able to delete an internship', () => {
let initialRowCount = 0
cy.get('table tbody tr').its('length').then((count) => {
initialRowCount = count
})
it('should be able to delete an internship', () => {
cy.get('table tbody tr').first().within(() => {
cy.contains('Vymazať').click()
cy.get('.internship-delete-btn').click()
})
cy.contains("Potvrdiť vymazanie").parent().should('be.visible')
cy.contains("Potvrdiť vymazanie").parent().contains("Vymazať").click()
cy.contains("Potvrdiť vymazanie").parent().contains("Áno").click()
cy.contains("Potvrdiť vymazanie").should('not.exist')
cy.wait(1000)
cy.get('table tbody tr').its('length').then((count) => {
expect(count).to.be.eq(initialRowCount - 1)
})
})*/
// TODO: Edit praxe
})
})