v1.0 working #1
@@ -1,51 +1,5 @@
|
|||||||
import { RscEntryLexicalCell as RscEntryLexicalCell_44fe37237e0ebf4470c9990d8cb7b07e } from '@payloadcms/richtext-lexical/rsc'
|
|
||||||
import { RscEntryLexicalField as RscEntryLexicalField_44fe37237e0ebf4470c9990d8cb7b07e } from '@payloadcms/richtext-lexical/rsc'
|
|
||||||
import { InlineToolbarFeatureClient as InlineToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { FixedToolbarFeatureClient as FixedToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { BoldFeatureClient as BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { ItalicFeatureClient as ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { UnderlineFeatureClient as UnderlineFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { StrikethroughFeatureClient as StrikethroughFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { SubscriptFeatureClient as SubscriptFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { SuperscriptFeatureClient as SuperscriptFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { InlineCodeFeatureClient as InlineCodeFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { ParagraphFeatureClient as ParagraphFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { HeadingFeatureClient as HeadingFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { AlignFeatureClient as AlignFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { IndentFeatureClient as IndentFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { UnorderedListFeatureClient as UnorderedListFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { OrderedListFeatureClient as OrderedListFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { ChecklistFeatureClient as ChecklistFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { LinkFeatureClient as LinkFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { RelationshipFeatureClient as RelationshipFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { BlockquoteFeatureClient as BlockquoteFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { UploadFeatureClient as UploadFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { HorizontalRuleFeatureClient as HorizontalRuleFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
|
||||||
import { SignInWithAuthjsButton as SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
|
import { SignInWithAuthjsButton as SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
|
||||||
|
|
||||||
export const importMap = {
|
export const importMap = {
|
||||||
"@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell": RscEntryLexicalCell_44fe37237e0ebf4470c9990d8cb7b07e,
|
|
||||||
"@payloadcms/richtext-lexical/rsc#RscEntryLexicalField": RscEntryLexicalField_44fe37237e0ebf4470c9990d8cb7b07e,
|
|
||||||
"@payloadcms/richtext-lexical/client#InlineToolbarFeatureClient": InlineToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#FixedToolbarFeatureClient": FixedToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#BoldFeatureClient": BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#UnderlineFeatureClient": UnderlineFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#StrikethroughFeatureClient": StrikethroughFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#SubscriptFeatureClient": SubscriptFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#SuperscriptFeatureClient": SuperscriptFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#InlineCodeFeatureClient": InlineCodeFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#ParagraphFeatureClient": ParagraphFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#HeadingFeatureClient": HeadingFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#AlignFeatureClient": AlignFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#IndentFeatureClient": IndentFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#UnorderedListFeatureClient": UnorderedListFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#OrderedListFeatureClient": OrderedListFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#ChecklistFeatureClient": ChecklistFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#LinkFeatureClient": LinkFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#RelationshipFeatureClient": RelationshipFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#BlockquoteFeatureClient": BlockquoteFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#UploadFeatureClient": UploadFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"@payloadcms/richtext-lexical/client#HorizontalRuleFeatureClient": HorizontalRuleFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
|
||||||
"payload-authjs/components#SignInWithAuthjsButton": SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e
|
"payload-authjs/components#SignInWithAuthjsButton": SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e
|
||||||
}
|
}
|
||||||
|
|||||||
40
src/app/(payload)/api/insert-papers/route.ts
Normal file
40
src/app/(payload)/api/insert-papers/route.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
import { getPayload } from 'payload';
|
||||||
|
import config from '@payload-config';
|
||||||
|
|
||||||
|
const payload = await getPayload({ config });
|
||||||
|
|
||||||
|
export async function POST(req: NextRequest) {
|
||||||
|
try {
|
||||||
|
const papersJson = await req.json();
|
||||||
|
|
||||||
|
const mapPaperData = (paper) => ({
|
||||||
|
title: paper.title,
|
||||||
|
department: paper.Abteilung.includes('WI') ? 'WI' : paper.Abteilung.includes('CI') ? 'CI' : 'MD',
|
||||||
|
year: paper.id.toString().slice(0, 4),
|
||||||
|
issue: paper.Ausgangslage,
|
||||||
|
goal: paper.Zielsetzung,
|
||||||
|
result: paper["Geplantes Ergebnis der Prüfungskandidatin/des Prüfungskandidaten"],
|
||||||
|
mentor: paper["Betreuer/innen"].replace("Hauptverantwortlich: ", ""),
|
||||||
|
authors: paper.Projektteam.split(",").map((author) => {
|
||||||
|
const isLeader = author.includes("(Hauptverantwortlich)");
|
||||||
|
return {
|
||||||
|
name: author.replace("(Hauptverantwortlich)", "").trim(),
|
||||||
|
position: isLeader ? "leader" : "member",
|
||||||
|
};
|
||||||
|
}).filter(author => author.name.length > 0),
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const paper of papersJson) {
|
||||||
|
await payload.create({
|
||||||
|
collection: "papers",
|
||||||
|
data: mapPaperData(paper),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json({ message: "Papers successfully inserted!" });
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Insertion error:", err);
|
||||||
|
return NextResponse.json({ error: "Failed to insert papers." }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,9 @@ const dirname = path.dirname(filename)
|
|||||||
export const Media: CollectionConfig = {
|
export const Media: CollectionConfig = {
|
||||||
slug: 'media',
|
slug: 'media',
|
||||||
access: {
|
access: {
|
||||||
|
create: ({ req: { user } }) => Boolean(user),
|
||||||
|
update: ({ req: { user } }) => Boolean(user && user.role === 'admin'),
|
||||||
|
delete: ({ req: { user } }) => Boolean(user && user.role === 'admin'),
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import type { CollectionConfig } from "payload";
|
import type { CollectionConfig } from "payload";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const Papers: CollectionConfig = {
|
export const Papers: CollectionConfig = {
|
||||||
slug: "papers",
|
slug: "papers",
|
||||||
labels: {
|
labels: {
|
||||||
@@ -18,49 +15,61 @@ export const Papers: CollectionConfig = {
|
|||||||
if (!user || !id) return false; // Explicitly handle missing ID
|
if (!user || !id) return false; // Explicitly handle missing ID
|
||||||
|
|
||||||
const paper = await payload.findByID({
|
const paper = await payload.findByID({
|
||||||
collection: 'papers',
|
collection: "papers",
|
||||||
id,
|
id,
|
||||||
depth: 1,
|
depth: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!paper) return false;
|
if (!paper) return false;
|
||||||
|
|
||||||
return paper.authors.some((author: any) => author.user.id === user.id);
|
return paper.authors.some((author: any) => author.user.name === user.name);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
admin: {
|
admin: {
|
||||||
useAsTitle: "title",
|
useAsTitle: "title",
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
|
{
|
||||||
|
name: "published",
|
||||||
|
type: "checkbox",
|
||||||
|
defaultValue: false,
|
||||||
|
label: "Veröffentlicht",
|
||||||
|
access: {
|
||||||
|
update: ({ req: { user } }) => Boolean(user?.type === "admin"),
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "title",
|
name: "title",
|
||||||
type: "text",
|
type: "text",
|
||||||
required: true,
|
unique: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "department",
|
||||||
|
type: "select",
|
||||||
|
options: [
|
||||||
|
{ label: "WI", value: "WI" },
|
||||||
|
{ label: "CI", value: "CI" },
|
||||||
|
{ label: "MD", value: "MD" },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "year",
|
name: "year",
|
||||||
type: "text",
|
type: "text",
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "issue",
|
name: "issue",
|
||||||
label: "Problemstellung",
|
label: "Problemstellung",
|
||||||
type: "textarea",
|
type: "textarea",
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "goal",
|
name: "goal",
|
||||||
label: "Zielsetzung",
|
label: "Zielsetzung",
|
||||||
type: "textarea",
|
type: "textarea",
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "result",
|
name: "result",
|
||||||
label: "Ergebnis",
|
label: "Ergebnis",
|
||||||
type: "textarea",
|
type: "textarea",
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "technologies",
|
name: "technologies",
|
||||||
@@ -75,7 +84,6 @@ export const Papers: CollectionConfig = {
|
|||||||
{
|
{
|
||||||
name: "description",
|
name: "description",
|
||||||
type: "text",
|
type: "text",
|
||||||
required: true,
|
|
||||||
admin: {
|
admin: {
|
||||||
placeholder: "... wurde für das Frontend verwendet",
|
placeholder: "... wurde für das Frontend verwendet",
|
||||||
},
|
},
|
||||||
@@ -90,32 +98,26 @@ export const Papers: CollectionConfig = {
|
|||||||
name: "image",
|
name: "image",
|
||||||
type: "upload",
|
type: "upload",
|
||||||
relationTo: "media",
|
relationTo: "media",
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "description",
|
name: "description",
|
||||||
type: "text",
|
type: "text",
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "mentor",
|
||||||
|
type: "text",
|
||||||
|
label: "Betreuer",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "authors",
|
name: "authors",
|
||||||
type: "array",
|
type: "array",
|
||||||
label: "Projektmitglieder",
|
label: "Projektmitglieder",
|
||||||
required: true,
|
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "profilePicture",
|
name: "name",
|
||||||
type: "upload",
|
type: "text",
|
||||||
relationTo: "media",
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "user",
|
|
||||||
type: "relationship",
|
|
||||||
relationTo: "users",
|
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -136,7 +138,6 @@ export const Papers: CollectionConfig = {
|
|||||||
{
|
{
|
||||||
name: "description",
|
name: "description",
|
||||||
type: "text",
|
type: "text",
|
||||||
required: true,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
validate: (authors) => {
|
validate: (authors) => {
|
||||||
|
|||||||
@@ -1,20 +1,52 @@
|
|||||||
import type { CollectionConfig } from 'payload'
|
import type { CollectionConfig } from 'payload';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const filename = fileURLToPath(import.meta.url);
|
||||||
|
const dirname = path.dirname(filename);
|
||||||
|
|
||||||
export const Users: CollectionConfig = {
|
export const Users: CollectionConfig = {
|
||||||
slug: 'users',
|
slug: 'users',
|
||||||
admin: {
|
admin: {
|
||||||
useAsTitle: 'email',
|
useAsTitle: 'email',
|
||||||
},
|
},
|
||||||
|
access: {
|
||||||
|
create: ({ req: { user } }) => Boolean(user && user.type === 'admin'),
|
||||||
|
update: ({ req: { user } }) => {
|
||||||
|
if (!user) return false;
|
||||||
|
if(user.type === 'admin') return true;
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
delete: ({ req: { user } }) => Boolean(user && user.type === 'admin'),
|
||||||
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'type',
|
name: 'type',
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'Admin', value: 'admin' },
|
{ label: 'Admin', value: 'admin' },
|
||||||
{ label: 'Schüler', value: 'student' },
|
{ label: 'Schüler', value: 'student' },
|
||||||
],
|
],
|
||||||
}
|
defaultValue: 'student',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'email',
|
||||||
|
type: 'email',
|
||||||
|
required: true,
|
||||||
|
unique: true,
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'emailVerified',
|
||||||
|
type: 'date',
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'image',
|
||||||
|
type: 'text',
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
// Email added by default
|
// Email added by default
|
||||||
// Add more fields as needed
|
// Add more fields as needed
|
||||||
],
|
],
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -123,29 +123,33 @@ export interface UserAuthOperations {
|
|||||||
*/
|
*/
|
||||||
export interface Paper {
|
export interface Paper {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
published?: boolean | null;
|
||||||
year: string;
|
title?: string | null;
|
||||||
issue: string;
|
department?: ('WI' | 'CI' | 'MD') | null;
|
||||||
goal: string;
|
year?: string | null;
|
||||||
result: string;
|
issue?: string | null;
|
||||||
|
goal?: string | null;
|
||||||
|
result?: string | null;
|
||||||
technologies?:
|
technologies?:
|
||||||
| {
|
| {
|
||||||
technology: number | Technology;
|
technology: number | Technology;
|
||||||
description: string;
|
description?: string | null;
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
}[]
|
}[]
|
||||||
| null;
|
| null;
|
||||||
prototype: {
|
prototype?: {
|
||||||
image: number | Media;
|
image?: (number | null) | Media;
|
||||||
description: string;
|
description?: string | null;
|
||||||
};
|
};
|
||||||
authors: {
|
mentor?: string | null;
|
||||||
profilePicture: number | Media;
|
authors?:
|
||||||
user: string | User;
|
| {
|
||||||
position: 'leader' | 'member';
|
name: string;
|
||||||
description: string;
|
position: 'leader' | 'member';
|
||||||
id?: string | null;
|
description?: string | null;
|
||||||
}[];
|
id?: string | null;
|
||||||
|
}[]
|
||||||
|
| null;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
@@ -356,7 +360,9 @@ export interface PayloadMigration {
|
|||||||
* via the `definition` "papers_select".
|
* via the `definition` "papers_select".
|
||||||
*/
|
*/
|
||||||
export interface PapersSelect<T extends boolean = true> {
|
export interface PapersSelect<T extends boolean = true> {
|
||||||
|
published?: T;
|
||||||
title?: T;
|
title?: T;
|
||||||
|
department?: T;
|
||||||
year?: T;
|
year?: T;
|
||||||
issue?: T;
|
issue?: T;
|
||||||
goal?: T;
|
goal?: T;
|
||||||
@@ -374,11 +380,11 @@ export interface PapersSelect<T extends boolean = true> {
|
|||||||
image?: T;
|
image?: T;
|
||||||
description?: T;
|
description?: T;
|
||||||
};
|
};
|
||||||
|
mentor?: T;
|
||||||
authors?:
|
authors?:
|
||||||
| T
|
| T
|
||||||
| {
|
| {
|
||||||
profilePicture?: T;
|
name?: T;
|
||||||
user?: T;
|
|
||||||
position?: T;
|
position?: T;
|
||||||
description?: T;
|
description?: T;
|
||||||
id?: T;
|
id?: T;
|
||||||
|
|||||||
Reference in New Issue
Block a user