Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#28 - contact page #136

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/DTOs/ContactInfoData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Keating\DTOs;

use Keating\Models\ContactInfo;

readonly class ContactInfoData
{
public function __construct(
public string $label,
public string $identifier,
) {}

public static function fromModel(ContactInfo $contactInfo): self
{
return new self(
label: $contactInfo->label,
identifier: $contactInfo->identifier,
);
}
}
30 changes: 30 additions & 0 deletions app/Http/Controllers/Public/ContactController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Keating\Http\Controllers\Public;

use Inertia\Response;
use Keating\DTOs\ContactInfoData;
use Keating\Models\ContactInfo;
use Keating\Models\Setting;

class ContactController
{
public function __invoke(): Response
{
/** @var Setting $settings */
$settings = Setting::query()->first();
$contactInfos = ContactInfo::query()->get();

return inertia("Public/Contact", [
"title" => $settings->teacher_titles,
"name" => $settings->teacher_name,
"email" => $settings->teacher_email,
"department" => $settings->department_name,
"university" => $settings->university_name,
"universityLogo" => asset("cwup-full.png"),
"contactInfos" => $contactInfos->map(fn(ContactInfo $contactInfo): ContactInfoData => ContactInfoData::fromModel($contactInfo)),
]);
}
}
7 changes: 4 additions & 3 deletions app/Models/ContactInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Keating\Enums\Icons;

/**
* @property string $id
* @property string $email
* @property string $github_handle
* @property string $alternative_channel
* @property string $label
* @property string $identifier
* @property Icons $icon
* @property Carbon $created_at
* @property Carbon $updated_at
*/
Expand Down
69 changes: 69 additions & 0 deletions resources/js/Pages/Public/Contact.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<script setup>
import PublicLayout from '@/Layouts/PublicLayout.vue'
import BackgroundGrid from '@/Components/BackgroundGrid.vue'
import SectionHeader from '@/Components/SectionHeader.vue'
import { Head } from '@inertiajs/inertia-vue3'
import ContactItem from '@/Shared/Components/ContactItem.vue'
import { NoSymbolIcon } from '@heroicons/vue/24/outline'

defineProps({
title: String,
name: String,
email: String,
department: String,
university: String,
universityLogo: String,
sectionSettings: Object,
about: Array,
counters: Array,
contactInfos: Array,
})
</script>

<template>
<Head title="Kontakt" />

<PublicLayout>
<div class="relative isolate bg-white">
<BackgroundGrid />
<div class="py-24 sm:py-32">
<div class="mx-auto max-w-7xl px-6 lg:px-8">
<SectionHeader>
<template #header>
Kontakt
</template>
<template #subheader>
Informacje kontaktowe.
</template>
</SectionHeader>
<img src="/cwup.png" alt="" class="pointer-events-none absolute right-0 z-0 hidden w-1/2 opacity-10 lg:mt-16 lg:block xl:mt-10 2xl:mt-0">
<div class="mx-auto mt-10 border-t border-gray-200 pt-10 sm:mt-16 sm:pt-16 lg:mx-0 lg:max-w-none lg:grid-cols-3">
<div class="mx-auto max-w-7xl text-center lg:mx-0 lg:flex-auto ">
<div v-if="email" class="mx-auto max-w-2xl py-6 text-left lg:mx-0 xl:py-3">
<label class="text-sm">
E-mail
</label>
<a :href="'mailto:' + email"
class="flex w-full items-center text-center text-xl font-bold tracking-tight text-gray-900 sm:text-2xl"
>
{{ email.split('@')[0] }}
<span class="font-normal">@{{ email.split('@')[1] }}</span>
</a>
</div>
<div v-for="(contactInfo, index) in contactInfos" :key="index" class="mx-auto flex max-w-2xl py-6 lg:mx-0 xl:py-3">
<ContactItem :contact="contactInfo" />
</div>

<div v-if="!email && contactInfos.length === 0" class="text-center">
<NoSymbolIcon class="mx-auto size-12 text-gray-400" />
<h3 class="mt-2 text-sm font-semibold text-gray-900">
Brak danych kontaktowych
</h3>
</div>
</div>
</div>
</div>
</div>
</div>
</PublicLayout>
</template>
29 changes: 29 additions & 0 deletions resources/js/Shared/Components/ContactItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script setup>
defineProps({
contact: Object,
})

const isMailable = (contact) => {
return contact.identifier.includes('@')
}
</script>

<template>
<div class="text-left">
<label class="text-sm">
{{ contact.label }}
</label>
<a v-if="isMailable(contact)"
:href="'mailto:' + contact.identifier"
class="flex w-full items-center justify-center text-center text-xl font-bold tracking-tight text-gray-900 sm:text-2xl"
>
{{ contact.identifier }}
</a>
<a v-else
:href="contact.identifier"
class="flex w-full items-center justify-center text-center text-xl font-bold tracking-tight text-gray-900 sm:text-2xl"
>
{{ contact.identifier }}
</a>
</div>
</template>
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Keating\Http\Controllers\Dashboard\SemesterController;
use Keating\Http\Controllers\Dashboard\SettingController;
use Keating\Http\Controllers\Dashboard\StudentController;
use Keating\Http\Controllers\Public\ContactController;
use Keating\Http\Controllers\Public\CourseController as PublicCourseController;
use Keating\Http\Controllers\Public\GradeController as PublicGradeController;
use Keating\Http\Controllers\Public\HomeController;
Expand All @@ -32,6 +33,7 @@
Route::get("/oceny/{semester?}/{course?}/{group?}/{index?}", PublicGradeController::class);
Route::get("/kursy", [PublicCourseController::class, "index"]);
Route::get("/kursy/{slug}", [PublicCourseController::class, "get"]);
Route::get("/kontakt", ContactController::class);

Route::middleware("guest")->group(function (): void {
Route::get("/login", [LoginController::class, "create"])->name("login");
Expand Down
Loading