Skip to content

Commit

Permalink
Merge pull request #203 from codeanker/feature/landing-settings
Browse files Browse the repository at this point in the history
Feature/landing settings
  • Loading branch information
danielswiatek authored Feb 4, 2025
2 parents a7ef244 + 7aaf507 commit 789146c
Show file tree
Hide file tree
Showing 53 changed files with 1,442 additions and 462 deletions.
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"reveal": "always",
"revealProblems": "onProblem",
"panel": "new",
"close": true
"close": false
}
},
{
Expand Down
43 changes: 0 additions & 43 deletions api/prisma/migrations/20250201222528_faqs/migration.sql

This file was deleted.

104 changes: 104 additions & 0 deletions api/prisma/migrations/20250203181204_public_landing/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
-- DropForeignKey
ALTER TABLE "Person" DROP CONSTRAINT "Person_photoId_fkey";

-- CreateTable
CREATE TABLE "faq_categories" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"unterveranstaltungId" INTEGER NOT NULL,

CONSTRAINT "faq_categories_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "faqs" (
"id" SERIAL NOT NULL,
"question" TEXT NOT NULL,
"answer" TEXT NOT NULL,
"categoryId" INTEGER NOT NULL,

CONSTRAINT "faqs_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "UnterveranstaltungLandingSettings" (
"unterveranstaltungId" SERIAL NOT NULL,
"heroTitle" TEXT NOT NULL,
"heroSubtitle" TEXT NOT NULL,
"eventDetailsTitle" TEXT NOT NULL,
"eventDetailsContent" TEXT NOT NULL,
"miscellaneousVisible" BOOLEAN,
"miscellaneousTitle" TEXT,
"faqVisible" BOOLEAN,
"faqEmail" TEXT,
"instagramVisible" BOOLEAN,
"instagramUrl" TEXT,
"facebookVisible" BOOLEAN,
"facebookUrl" TEXT,

CONSTRAINT "UnterveranstaltungLandingSettings_pkey" PRIMARY KEY ("unterveranstaltungId")
);

-- CreateTable
CREATE TABLE "UnterveranstaltungLandingImages" (
"id" SERIAL NOT NULL,
"name" TEXT,
"unterveranstaltungLandingSettingsId" INTEGER,
"fileId" TEXT NOT NULL,

CONSTRAINT "UnterveranstaltungLandingImages_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "UnterveranstaltungLandingMiscellaneous" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"content" TEXT NOT NULL,
"unterveranstaltungLandingSettingsId" INTEGER,

CONSTRAINT "UnterveranstaltungLandingMiscellaneous_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "_FaqToUnterveranstaltung" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL,

CONSTRAINT "_FaqToUnterveranstaltung_AB_pkey" PRIMARY KEY ("A","B")
);

-- CreateIndex
CREATE UNIQUE INDEX "faq_categories_name_unterveranstaltungId_key" ON "faq_categories"("name", "unterveranstaltungId");

-- CreateIndex
CREATE UNIQUE INDEX "UnterveranstaltungLandingImages_fileId_key" ON "UnterveranstaltungLandingImages"("fileId");

-- CreateIndex
CREATE INDEX "_FaqToUnterveranstaltung_B_index" ON "_FaqToUnterveranstaltung"("B");

-- AddForeignKey
ALTER TABLE "faq_categories" ADD CONSTRAINT "faq_categories_unterveranstaltungId_fkey" FOREIGN KEY ("unterveranstaltungId") REFERENCES "Unterveranstaltung"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "faqs" ADD CONSTRAINT "faqs_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "faq_categories"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Person" ADD CONSTRAINT "Person_photoId_fkey" FOREIGN KEY ("photoId") REFERENCES "File"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UnterveranstaltungLandingSettings" ADD CONSTRAINT "UnterveranstaltungLandingSettings_unterveranstaltungId_fkey" FOREIGN KEY ("unterveranstaltungId") REFERENCES "Unterveranstaltung"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UnterveranstaltungLandingImages" ADD CONSTRAINT "UnterveranstaltungLandingImages_unterveranstaltungLandingS_fkey" FOREIGN KEY ("unterveranstaltungLandingSettingsId") REFERENCES "UnterveranstaltungLandingSettings"("unterveranstaltungId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UnterveranstaltungLandingImages" ADD CONSTRAINT "UnterveranstaltungLandingImages_fileId_fkey" FOREIGN KEY ("fileId") REFERENCES "File"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UnterveranstaltungLandingMiscellaneous" ADD CONSTRAINT "UnterveranstaltungLandingMiscellaneous_unterveranstaltungL_fkey" FOREIGN KEY ("unterveranstaltungLandingSettingsId") REFERENCES "UnterveranstaltungLandingSettings"("unterveranstaltungId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_FaqToUnterveranstaltung" ADD CONSTRAINT "_FaqToUnterveranstaltung_A_fkey" FOREIGN KEY ("A") REFERENCES "faqs"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_FaqToUnterveranstaltung" ADD CONSTRAINT "_FaqToUnterveranstaltung_B_fkey" FOREIGN KEY ("B") REFERENCES "Unterveranstaltung"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Warnings:
- The primary key for the `_AnmeldungToMahlzeit` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `_FaqToUnterveranstaltung` table will be changed. If it partially fails, the table could be left without primary key constraint.
- A unique constraint covering the columns `[landingSettingsId]` on the table `Unterveranstaltung` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[A,B]` on the table `_AnmeldungToMahlzeit` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[A,B]` on the table `_FaqToUnterveranstaltung` will be added. If there are existing duplicate values, this will fail.
- Added the required column `landingSettingsId` to the `Unterveranstaltung` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "UnterveranstaltungLandingSettings" DROP CONSTRAINT "UnterveranstaltungLandingSettings_unterveranstaltungId_fkey";

-- AlterTable
ALTER TABLE "Unterveranstaltung" ADD COLUMN "landingSettingsId" INTEGER NOT NULL;

-- AlterTable
ALTER TABLE "_AnmeldungToMahlzeit" DROP CONSTRAINT "_AnmeldungToMahlzeit_AB_pkey";

-- AlterTable
ALTER TABLE "_FaqToUnterveranstaltung" DROP CONSTRAINT "_FaqToUnterveranstaltung_AB_pkey";

-- CreateIndex
CREATE UNIQUE INDEX "Unterveranstaltung_landingSettingsId_key" ON "Unterveranstaltung"("landingSettingsId");

-- CreateIndex
CREATE UNIQUE INDEX "_AnmeldungToMahlzeit_AB_unique" ON "_AnmeldungToMahlzeit"("A", "B");

-- CreateIndex
CREATE UNIQUE INDEX "_FaqToUnterveranstaltung_AB_unique" ON "_FaqToUnterveranstaltung"("A", "B");

-- AddForeignKey
ALTER TABLE "Unterveranstaltung" ADD CONSTRAINT "Unterveranstaltung_landingSettingsId_fkey" FOREIGN KEY ("landingSettingsId") REFERENCES "UnterveranstaltungLandingSettings"("unterveranstaltungId") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "UnterveranstaltungLandingSettings" ADD COLUMN "miscellaneousSubtitle" TEXT;
2 changes: 1 addition & 1 deletion api/prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
22 changes: 16 additions & 6 deletions api/prisma/schema/Faq.prisma
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
model FaqCategory {
id Int @id @default(autoincrement())
name String
FAQ Faq[]
unterveranstaltungId Int
unterveranstaltung Unterveranstaltung @relation(fields: [unterveranstaltungId], references: [id])
faqs Faq[]
@@unique([name, unterveranstaltungId])
@@map("faq_categories")
}

model Faq {
id Int @id @default(autoincrement())
categoryId Int
category FaqCategory @relation(fields: [categoryId], references: [id])
question String
answer String
id Int @id @default(autoincrement())
question String
answer String
categoryId Int
category FaqCategory @relation(fields: [categoryId], references: [id])
unterveranstaltung Unterveranstaltung[]
@@map("faqs")
}
21 changes: 11 additions & 10 deletions api/prisma/schema/File.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ enum FileProvider {
}

model File {
id String @id @unique @default(uuid())
createdAt DateTime @default(now())
uploaded Boolean @default(false)
uploadedAt DateTime?
provider FileProvider
key String @unique()
filename String?
mimetype String?
UnterveranstaltungDocument UnterveranstaltungDocument?
Persons Person[]
id String @id @unique @default(uuid())
createdAt DateTime @default(now())
uploaded Boolean @default(false)
uploadedAt DateTime?
provider FileProvider
key String @unique()
filename String?
mimetype String?
UnterveranstaltungDocument UnterveranstaltungDocument?
Persons Person[]
UnterveranstaltungLandingImages UnterveranstaltungLandingImages[]
}
46 changes: 46 additions & 0 deletions api/prisma/schema/PublicLanding.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
model UnterveranstaltungLandingSettings {
unterveranstaltungId Int @id @default(autoincrement())
unterveranstaltung Unterveranstaltung?
heroTitle String
heroSubtitle String
heroImages UnterveranstaltungLandingImages[]
eventDetailsTitle String
eventDetailsContent String
miscellaneousVisible Boolean?
miscellaneousTitle String?
miscellaneousSubtitle String?
miscellaneousItems UnterveranstaltungLandingMiscellaneous[]
faqVisible Boolean?
faqEmail String?
instagramVisible Boolean?
instagramUrl String?
facebookVisible Boolean?
facebookUrl String?
}

model UnterveranstaltungLandingImages {
id Int @id @default(autoincrement())
name String?
UnterveranstaltungLandingSettings UnterveranstaltungLandingSettings? @relation(fields: [unterveranstaltungLandingSettingsId], references: [unterveranstaltungId])
unterveranstaltungLandingSettingsId Int?
file File @relation(fields: [fileId], references: [id])
fileId String @unique
}

model UnterveranstaltungLandingMiscellaneous {
id Int @id @default(autoincrement())
title String
content String
UnterveranstaltungLandingSettings UnterveranstaltungLandingSettings? @relation(fields: [unterveranstaltungLandingSettingsId], references: [unterveranstaltungId])
unterveranstaltungLandingSettingsId Int?
}
7 changes: 6 additions & 1 deletion api/prisma/schema/Unterveranstaltung.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ model Unterveranstaltung {
type UnterveranstaltungType @default(GLIEDERUNG)
customFields CustomField[]
documents UnterveranstaltungDocument[]
faq Faq[]
faqs Faq[]
faqCategories FaqCategory[]
landingSettings UnterveranstaltungLandingSettings? @relation(fields: [landingSettingsId], references: [unterveranstaltungId], onDelete: Cascade)
landingSettingsId Int @unique
}

model UnterveranstaltungDocument {
Expand Down
54 changes: 53 additions & 1 deletion api/prisma/seeders/veranstaltung.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PrismaClient } from '@prisma/client'
import logActivity from '../../src/util/activity.js'

import type { Seeder } from './index.js'
import {dayjs} from '@codeanker/helpers'
import { dayjs } from '@codeanker/helpers'

const createVeranstaltung: Seeder = async (prisma: PrismaClient) => {
const beginn = dayjs().add(1, 'month')
Expand Down Expand Up @@ -55,11 +55,63 @@ const createVeranstaltung: Seeder = async (prisma: PrismaClient) => {
edv: '1205013',
},
},
landingSettings: {
create: {
heroTitle: faker.lorem.sentence(),
heroSubtitle: faker.lorem.sentence(),
eventDetailsTitle: faker.lorem.sentence(),
eventDetailsContent: faker.lorem.paragraph(),
miscellaneousVisible: true,
miscellaneousTitle: faker.lorem.sentence(),
miscellaneousItems: {
create: Array(3)
.fill(0)
.map(() => ({
title: faker.lorem.sentence(),
content: faker.lorem.paragraph(),
})),
},
faqVisible: true,
faqEmail: faker.internet.email(),

instagramVisible: true,
instagramUrl: 'https://www.instagram.com/dlrgjugendsh',

facebookVisible: true,
facebookUrl: 'https://www.facebook.com/DLRGJugendSH/?locale=de_DE',
},
},
},
},
},
select: {
id: true,
unterveranstaltungen: {
select: {
id: true,
},
},
},
})

const faqCategories = await prisma.faqCategory.createManyAndReturn({
data: Array(3)
.fill(0)
.map(() => ({
name: faker.color.human(),
unterveranstaltungId: veranstaltung.unterveranstaltungen[0]!.id,
})),
})
await prisma.faq.createMany({
data: Array(9)
.fill(0)
.map(() => ({
question: faker.commerce.productAdjective(),
answer: faker.commerce.productDescription(),
categoryId: faqCategories[Math.floor(Math.random() * faqCategories.length)]!.id,
})),
})

await prisma.customField.create({
data: {
name: 'Rolle',
Expand Down
Loading

0 comments on commit 789146c

Please sign in to comment.