diff --git a/src/admin/components/calendar/Calendar.tsx b/src/admin/components/calendar/Calendar.tsx new file mode 100644 index 0000000..7417e12 --- /dev/null +++ b/src/admin/components/calendar/Calendar.tsx @@ -0,0 +1,40 @@ +'use client' + +import { useEffect, useState } from 'react' +import moment from 'moment' +import Day from '@/admin/components/calendar/Day' + + +const Calendar = () => { + const weekNr = moment().isoWeek(); + const [week, setWeek] = useState(weekNr.toString()) + const [days, setDays] = useState([]) + + // on week change => sey days + useEffect(() => { + const date = moment().isoWeek(Number(week)); + const newDays = []; + + for(let i=0; i<7; i++) { + let day = date.weekday(i).toISOString(); + newDays.push(day) + } + + setDays(newDays) + }, [week, setDays]) + + return ( +
+
+ +
+ + + {days.map(day => )} +
+ ) +} + +export default Calendar \ No newline at end of file diff --git a/src/admin/components/calendar/ChurchSelect/ChurchSelect.tsx b/src/admin/components/calendar/ChurchSelect/ChurchSelect.tsx new file mode 100644 index 0000000..c69ee4c --- /dev/null +++ b/src/admin/components/calendar/ChurchSelect/ChurchSelect.tsx @@ -0,0 +1,22 @@ +import { useSyncExternalStore } from 'react' +import { churchStore } from '@/admin/components/calendar/ChurchSelect/churchStore' + +type ChurchSelectProps = { + value: string, + className?: string, + onChange: (value: string) => void, +} + +export const ChurchSelect = ({value, onChange, className}: ChurchSelectProps) => { + const churches = useSyncExternalStore(churchStore.subscribe, churchStore.getSnapshot) + + return ( + + ) +} \ No newline at end of file diff --git a/src/admin/components/calendar/ChurchSelect/churchStore.ts b/src/admin/components/calendar/ChurchSelect/churchStore.ts new file mode 100644 index 0000000..05834b4 --- /dev/null +++ b/src/admin/components/calendar/ChurchSelect/churchStore.ts @@ -0,0 +1,42 @@ +import { fetchChurches } from '@/fetch/churches' + +type Church = { + id: string, + name: string +} + +let churches: Church[] = []; +const listeners = new Set<() => void>(); + +/** + * ChurchStore to use with Reacts `useSyncExternalStore` + */ +export const churchStore = { + // fetch all churches from API + async init() { + const data = await fetchChurches(); + + if (data) { + churches = data.docs.map(c => { + return { id: c.id, name: c.name } + }); + + emitChange() + } + }, + subscribe: (listener: () => void) => { + listeners.add(listener); + return () => listeners.delete(listener); + }, + getSnapshot() { + return churches; + } +} + +function emitChange() { + for (let listener of listeners) { + listener(); + } +} + +await churchStore.init(); \ No newline at end of file diff --git a/src/admin/components/calendar/Day.tsx b/src/admin/components/calendar/Day.tsx new file mode 100644 index 0000000..2678a79 --- /dev/null +++ b/src/admin/components/calendar/Day.tsx @@ -0,0 +1,36 @@ +import { liturgicalDayName } from '@/hooks/liturgicalDayName' +import styles from "./styles.module.scss" +import MassForm from '@/admin/components/calendar/MassForm' + +type DayProps = { + date: string, + mass: Mass[] +} + +type Mass = { + id: string, + +} + +export const Day = ({date}: DayProps) => { + const dayName = liturgicalDayName(date) + const dateObj = new Date(date); + + + return ( +
+
+ {dateObj.toLocaleDateString("de-De", {weekday: "long"})}
+ {dayName} +
+
+ {date.substring(8, 10)} +
+
+ +
+
+ ) +} + +export default Day \ No newline at end of file diff --git a/src/admin/components/calendar/MassForm.tsx b/src/admin/components/calendar/MassForm.tsx new file mode 100644 index 0000000..d8411f2 --- /dev/null +++ b/src/admin/components/calendar/MassForm.tsx @@ -0,0 +1,54 @@ +import styles from "./form.module.scss" +import { ChurchSelect } from '@/admin/components/calendar/ChurchSelect/ChurchSelect' + +const MassForm = () => { + return ( +
+
+
+ +
+
+ console.log("chage")} + /> +
+
+ +
+ +
+ + + + + + + + +
+ +
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+ ) +} + +export default MassForm \ No newline at end of file diff --git a/src/admin/components/calendar/form.module.scss b/src/admin/components/calendar/form.module.scss new file mode 100644 index 0000000..11943f4 --- /dev/null +++ b/src/admin/components/calendar/form.module.scss @@ -0,0 +1,30 @@ +.container { + display: flex; +} + +.time { + width: 130px; + text-align: center; +} + +.formRow { + margin-bottom: 5px; +} + +.input { + font-size: 12px; + padding: 3px; + width: 350px; + border: 1px solid #ababab; + border-radius: 4px; +} + +.select { + font-size: 12px; + padding: 3px; + border: 1px solid #ababab; + border-radius: 4px; + width: 100px; + background-color: #ffffff; + font-family: inherit; +} \ No newline at end of file diff --git a/src/admin/components/calendar/styles.module.scss b/src/admin/components/calendar/styles.module.scss new file mode 100644 index 0000000..0778b31 --- /dev/null +++ b/src/admin/components/calendar/styles.module.scss @@ -0,0 +1,13 @@ +.container { + display: flex; + margin-bottom: 20px; +} + +.day { + width: 300px; +} + +.date { + font-size: 18px; + font-weight: bold; +} \ No newline at end of file diff --git a/src/admin/components/test/TestView.tsx b/src/admin/components/test/TestView.tsx new file mode 100644 index 0000000..8075c3d --- /dev/null +++ b/src/admin/components/test/TestView.tsx @@ -0,0 +1,40 @@ +import { Gutter } from '@payloadcms/ui' +import { DefaultTemplate } from '@payloadcms/next/templates' +import { AdminViewServerProps } from 'payload' +import Calendar from '@/admin/components/calendar/Calendar' + +export default function TestPage({ + initPageResult, + params, + searchParams, + }: AdminViewServerProps) { + const { + req: { + user + } + } = initPageResult + + if (!user) { + return

You must be logged in to view this page.

+ } + + return ( + + +

Gottesdiensten

+

This view uses the Default Template.

+ + +
+
+ ) +} diff --git a/src/app/(payload)/admin/importMap.js b/src/app/(payload)/admin/importMap.js index bf0b4f9..8f1ff82 100644 --- a/src/app/(payload)/admin/importMap.js +++ b/src/app/(payload)/admin/importMap.js @@ -9,6 +9,8 @@ import { HeadingFeatureClient as HeadingFeatureClient_e70f5e05f09f93e00b997edb1e import { UnderlineFeatureClient as UnderlineFeatureClient_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 { default as default_9bcae99938dc292be0063ce32055e14c } from 'src/components/Logo/Logo' +import { default as default_da280595b8aff80d788c3701c6162e87 } from 'src/admin/components/test/TestView' export const importMap = { "@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell": RscEntryLexicalCell_44fe37237e0ebf4470c9990d8cb7b07e, @@ -21,5 +23,7 @@ export const importMap = { "@payloadcms/richtext-lexical/client#HeadingFeatureClient": HeadingFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, "@payloadcms/richtext-lexical/client#UnderlineFeatureClient": UnderlineFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, "@payloadcms/richtext-lexical/client#BoldFeatureClient": BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, - "@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 + "@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864, + "/components/Logo/Logo#default": default_9bcae99938dc292be0063ce32055e14c, + "/admin/components/test/TestView#default": default_da280595b8aff80d788c3701c6162e87 } diff --git a/src/collections/Highlight.ts b/src/collections/Highlight.ts index 85207be..27f5533 100644 --- a/src/collections/Highlight.ts +++ b/src/collections/Highlight.ts @@ -42,7 +42,12 @@ export const Highlight: CollectionConfig = { relationTo: ['event', 'blog', 'worship'], admin: { allowCreate: false, - allowEdit: false + allowEdit: false, + sortOptions: { + "event": "-createdAt", + "blog": "-createdAt", + "worship": "-date", + } }, required: false }, diff --git a/src/components/Logo/Logo.tsx b/src/components/Logo/Logo.tsx index f622321..772a1a3 100644 --- a/src/components/Logo/Logo.tsx +++ b/src/components/Logo/Logo.tsx @@ -421,4 +421,6 @@ export const Logo = ({withText = false, color = "#000000", height = 75, textColo ) -} \ No newline at end of file +} + +export default Logo \ No newline at end of file diff --git a/src/fetch/churches.ts b/src/fetch/churches.ts new file mode 100644 index 0000000..63acc08 --- /dev/null +++ b/src/fetch/churches.ts @@ -0,0 +1,17 @@ +import { Church } from '@/payload-types' +import { PaginatedDocs } from 'payload' +import { stringify } from 'qs-esm' + +export const fetchChurches = async (): Promise | undefined> => { + const stringifiedQuery = stringify( + { + sort: "name", + limit: 50 + }, + { addQueryPrefix: true }, + ) + + const resp = await fetch(`http://localhost:3000/api/church`); + if (!resp.ok) return undefined; + return resp.json(); +} \ No newline at end of file diff --git a/src/payload-types.ts b/src/payload-types.ts index bd0c994..8e1020c 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -6,10 +6,65 @@ * and re-run `payload generate:types` to regenerate this file. */ +/** + * Supported timezones in IANA format. + * + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "supportedTimezones". + */ +export type SupportedTimezones = + | 'Pacific/Midway' + | 'Pacific/Niue' + | 'Pacific/Honolulu' + | 'Pacific/Rarotonga' + | 'America/Anchorage' + | 'Pacific/Gambier' + | 'America/Los_Angeles' + | 'America/Tijuana' + | 'America/Denver' + | 'America/Phoenix' + | 'America/Chicago' + | 'America/Guatemala' + | 'America/New_York' + | 'America/Bogota' + | 'America/Caracas' + | 'America/Santiago' + | 'America/Buenos_Aires' + | 'America/Sao_Paulo' + | 'Atlantic/South_Georgia' + | 'Atlantic/Azores' + | 'Atlantic/Cape_Verde' + | 'Europe/London' + | 'Europe/Berlin' + | 'Africa/Lagos' + | 'Europe/Athens' + | 'Africa/Cairo' + | 'Europe/Moscow' + | 'Asia/Riyadh' + | 'Asia/Dubai' + | 'Asia/Baku' + | 'Asia/Karachi' + | 'Asia/Tashkent' + | 'Asia/Calcutta' + | 'Asia/Dhaka' + | 'Asia/Almaty' + | 'Asia/Jakarta' + | 'Asia/Bangkok' + | 'Asia/Shanghai' + | 'Asia/Singapore' + | 'Asia/Tokyo' + | 'Asia/Seoul' + | 'Australia/Sydney' + | 'Pacific/Guam' + | 'Pacific/Noumea' + | 'Pacific/Auckland' + | 'Pacific/Fiji'; + export interface Config { auth: { users: UserAuthOperations; }; + blocks: {}; collections: { parish: Parish; church: Church; diff --git a/src/payload.config.ts b/src/payload.config.ts index ab1c09d..5b1efdb 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -42,6 +42,36 @@ const dirname = path.dirname(filename) export default buildConfig({ admin: { user: Users.slug, + meta: { + title: 'Dashboard', + titleSuffix: '- Heilige Drei Könige' + }, + importMap: { + baseDir: dirname, + }, + components: { + views: { + testCustomView: { + Component: '/admin/components/test/TestView', + path: '/test' + }, + }, + graphics: { + Logo: { + path: '/components/Logo/Logo', + serverProps: { + withText: true, + height: 90 + } + }, + Icon: { + path: '/components/Logo/Logo', + serverProps: { + height: 18 + } + } + } + } }, collections: [ Parish,