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

#27 - faq page #134

Merged
merged 8 commits into from
Sep 10, 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
20 changes: 20 additions & 0 deletions app/Http/Controllers/Public/FaqController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Keating\Http\Controllers\Public;

use Inertia\Response;
use Keating\Models\Faq;

class FaqController
{
public function __invoke(): Response
{
$faqs = Faq::query()->get();

return inertia("Public/Faq", [
"faqs" => $faqs,
]);
}
}
9 changes: 8 additions & 1 deletion resources/js/Pages/Public/Course/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import PublicLayout from '@/Layouts/PublicLayout.vue'
import BackgroundGrid from '@/Components/BackgroundGrid.vue'
import SectionHeader from '@/Components/SectionHeader.vue'
import { ArrowRightCircleIcon } from '@heroicons/vue/24/outline'
import { ArrowRightCircleIcon, NoSymbolIcon } from '@heroicons/vue/24/outline'
import TableWrapper from '@/Shared/Components/Table/Public/TableWrapper.vue'
import TableHeader from '@/Shared/Components/Table/Public/TableHeader.vue'
import TableRow from '@/Shared/Components/Table/Public/TableRow.vue'
Expand Down Expand Up @@ -76,6 +76,13 @@ defineProps({
</template>
</TableWrapper>
</div>

<div v-if="courses.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 kursów
</h3>
</div>
krzysztofrewak marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
</div>
Expand Down
73 changes: 73 additions & 0 deletions resources/js/Pages/Public/Faq.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<script setup>
import PublicLayout from '@/Layouts/PublicLayout.vue'
import BackgroundGrid from '@/Components/BackgroundGrid.vue'
import SectionHeader from '@/Components/SectionHeader.vue'
import { PlusCircleIcon, MinusCircleIcon, NoSymbolIcon } from '@heroicons/vue/24/outline'
import { Head } from '@inertiajs/inertia-vue3'
import { ref } from 'vue'
import DOMPurify from 'dompurify'

defineProps({
faqs: Object,
})

const openedIndex = ref(null)

function toggleAnswer(index) {
openedIndex.value = openedIndex.value === index ? null : index
}
</script>

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

<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>
FAQ
</template>
<template #subheader>
Pytania i odpowiedzi na najczęściej zadawane pytania
kamilpiech97 marked this conversation as resolved.
Show resolved Hide resolved
</template>
</SectionHeader>

<div
class="mx-auto mt-10 grid max-w-2xl grid-cols-1 gap-x-8 gap-y-4 border-t border-gray-200 pt-10 sm:mt-16 sm:pt-16 lg:mx-0 lg:max-w-none"
>
<div v-for="(faq, index) in faqs" :key="index" class="cursor-pointer" @click="toggleAnswer(index)">
<div class="flex items-center justify-between bg-[#FAFAFC] p-4 text-lg font-semibold text-gray-600">
<div class="w-[90%]">
{{ faq.question }}
</div>
<div v-if="openedIndex !== index" class="ml-5 cursor-pointer">
<PlusCircleIcon class="size-8 text-gray-600" />
</div>
<div v-else class="ml-5 cursor-pointer">
<MinusCircleIcon class="size-8 text-gray-600" />
</div>
</div>
<div v-if="openedIndex === index"
class="text-md flex items-center justify-between bg-white px-4 py-5 font-normal text-gray-600"
>
<!-- eslint-disable vue/no-v-html -->
<p class="prose text-gray-600" v-html="DOMPurify.sanitize(faq.answer)" />
<!-- eslint-enable vue/no-v-html -->
</div>
</div>

<div v-if="faqs.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 pytań i odpowiedzi
</h3>
</div>
</div>
</div>
</div>
</div>
</PublicLayout>
</template>
4 changes: 2 additions & 2 deletions resources/js/Pages/Public/News/News.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import PublicLayout from '@/Layouts/PublicLayout.vue'
import BackgroundGrid from '../../../Components/BackgroundGrid.vue'
import SectionHeader from '../../../Components/SectionHeader.vue'
import BackgroundGrid from '@/Components/BackgroundGrid.vue'
import SectionHeader from '@/Components/SectionHeader.vue'
import { Head } from '@inertiajs/inertia-vue3'
import DOMPurify from 'dompurify'

Expand Down
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Keating\Http\Controllers\Dashboard\SettingController;
use Keating\Http\Controllers\Dashboard\StudentController;
use Keating\Http\Controllers\Public\CourseController as PublicCourseController;
use Keating\Http\Controllers\Public\FaqController as PublicFaqController;
use Keating\Http\Controllers\Public\GradeController as PublicGradeController;
use Keating\Http\Controllers\Public\HomeController;
use Keating\Http\Controllers\Public\LoginController;
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("/faq", PublicFaqController::class);

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