feat: add @payloadcms/translations, enable i18n and localization, update collections and globals and add "Menu" group

- Fix `format` files glob
main
RaviAnand Mohabir 3 months ago
parent e03c6a1067
commit c3dd300769

12726
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -14,7 +14,7 @@
"lint": "cross-env NODE_OPTIONS=--no-deprecation next lint",
"payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
"start": "cross-env NODE_OPTIONS=--no-deprecation next start",
"format": "prettier 'src/**/*.{js,jsx,ts,tsx}'"
"format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx}\""
},
"dependencies": {
"@ark-ui/react": "^3.9.0",
@ -22,6 +22,7 @@
"@payloadcms/next": "beta",
"@payloadcms/plugin-cloud": "beta",
"@payloadcms/richtext-lexical": "beta",
"@payloadcms/translations": "beta",
"cross-env": "^7.0.3",
"graphql": "^16.8.1",
"localbites": "file:",

@ -1 +1,49 @@
export const importMap = {};
import { RichTextCell as RichTextCell_0 } from '@payloadcms/richtext-lexical/client'
import { RichTextField as RichTextField_1 } from '@payloadcms/richtext-lexical/client'
import { getGenerateComponentMap as getGenerateComponentMap_2 } from '@payloadcms/richtext-lexical/generateComponentMap'
import { InlineToolbarFeatureClient as InlineToolbarFeatureClient_3 } from '@payloadcms/richtext-lexical/client'
import { HorizontalRuleFeatureClient as HorizontalRuleFeatureClient_4 } from '@payloadcms/richtext-lexical/client'
import { UploadFeatureClient as UploadFeatureClient_5 } from '@payloadcms/richtext-lexical/client'
import { BlockquoteFeatureClient as BlockquoteFeatureClient_6 } from '@payloadcms/richtext-lexical/client'
import { RelationshipFeatureClient as RelationshipFeatureClient_7 } from '@payloadcms/richtext-lexical/client'
import { LinkFeatureClient as LinkFeatureClient_8 } from '@payloadcms/richtext-lexical/client'
import { ChecklistFeatureClient as ChecklistFeatureClient_9 } from '@payloadcms/richtext-lexical/client'
import { OrderedListFeatureClient as OrderedListFeatureClient_10 } from '@payloadcms/richtext-lexical/client'
import { UnorderedListFeatureClient as UnorderedListFeatureClient_11 } from '@payloadcms/richtext-lexical/client'
import { IndentFeatureClient as IndentFeatureClient_12 } from '@payloadcms/richtext-lexical/client'
import { AlignFeatureClient as AlignFeatureClient_13 } from '@payloadcms/richtext-lexical/client'
import { HeadingFeatureClient as HeadingFeatureClient_14 } from '@payloadcms/richtext-lexical/client'
import { ParagraphFeatureClient as ParagraphFeatureClient_15 } from '@payloadcms/richtext-lexical/client'
import { InlineCodeFeatureClient as InlineCodeFeatureClient_16 } from '@payloadcms/richtext-lexical/client'
import { SuperscriptFeatureClient as SuperscriptFeatureClient_17 } from '@payloadcms/richtext-lexical/client'
import { SubscriptFeatureClient as SubscriptFeatureClient_18 } from '@payloadcms/richtext-lexical/client'
import { StrikethroughFeatureClient as StrikethroughFeatureClient_19 } from '@payloadcms/richtext-lexical/client'
import { UnderlineFeatureClient as UnderlineFeatureClient_20 } from '@payloadcms/richtext-lexical/client'
import { BoldFeatureClient as BoldFeatureClient_21 } from '@payloadcms/richtext-lexical/client'
import { ItalicFeatureClient as ItalicFeatureClient_22 } from '@payloadcms/richtext-lexical/client'
export const importMap = {
"@payloadcms/richtext-lexical/client#RichTextCell": RichTextCell_0,
"@payloadcms/richtext-lexical/client#RichTextField": RichTextField_1,
"@payloadcms/richtext-lexical/generateComponentMap#getGenerateComponentMap": getGenerateComponentMap_2,
"@payloadcms/richtext-lexical/client#InlineToolbarFeatureClient": InlineToolbarFeatureClient_3,
"@payloadcms/richtext-lexical/client#HorizontalRuleFeatureClient": HorizontalRuleFeatureClient_4,
"@payloadcms/richtext-lexical/client#UploadFeatureClient": UploadFeatureClient_5,
"@payloadcms/richtext-lexical/client#BlockquoteFeatureClient": BlockquoteFeatureClient_6,
"@payloadcms/richtext-lexical/client#RelationshipFeatureClient": RelationshipFeatureClient_7,
"@payloadcms/richtext-lexical/client#LinkFeatureClient": LinkFeatureClient_8,
"@payloadcms/richtext-lexical/client#ChecklistFeatureClient": ChecklistFeatureClient_9,
"@payloadcms/richtext-lexical/client#OrderedListFeatureClient": OrderedListFeatureClient_10,
"@payloadcms/richtext-lexical/client#UnorderedListFeatureClient": UnorderedListFeatureClient_11,
"@payloadcms/richtext-lexical/client#IndentFeatureClient": IndentFeatureClient_12,
"@payloadcms/richtext-lexical/client#AlignFeatureClient": AlignFeatureClient_13,
"@payloadcms/richtext-lexical/client#HeadingFeatureClient": HeadingFeatureClient_14,
"@payloadcms/richtext-lexical/client#ParagraphFeatureClient": ParagraphFeatureClient_15,
"@payloadcms/richtext-lexical/client#InlineCodeFeatureClient": InlineCodeFeatureClient_16,
"@payloadcms/richtext-lexical/client#SuperscriptFeatureClient": SuperscriptFeatureClient_17,
"@payloadcms/richtext-lexical/client#SubscriptFeatureClient": SubscriptFeatureClient_18,
"@payloadcms/richtext-lexical/client#StrikethroughFeatureClient": StrikethroughFeatureClient_19,
"@payloadcms/richtext-lexical/client#UnderlineFeatureClient": UnderlineFeatureClient_20,
"@payloadcms/richtext-lexical/client#BoldFeatureClient": BoldFeatureClient_21,
"@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_22
}

@ -0,0 +1,43 @@
import type { CollectionConfig } from "payload";
export const MenuCategory: CollectionConfig = {
slug: "opening-time",
access: {
read: () => true,
},
admin: {
useAsTitle: "title",
},
fields: [
{
name: "title",
type: "text",
localized: true,
},
{
name: "description",
type: "richText",
localized: true,
},
{
name: "from",
type: "date",
admin: {
date: {
pickerAppearance: "dayOnly",
displayFormat: "d MMM yyy",
},
},
},
{
name: "to",
type: "date",
admin: {
date: {
pickerAppearance: "dayOnly",
displayFormat: "d MMM yyy",
},
},
},
],
};

@ -0,0 +1,26 @@
import type { CollectionConfig } from "payload";
import { Menu } from "../groups/Menu";
export const FoodDeclaration: CollectionConfig = {
slug: "food-declaration",
access: {
read: () => true,
},
admin: {
useAsTitle: "title",
group: Menu,
},
fields: [
{
name: "title",
type: "text",
required: true,
localized: true,
},
{
name: "description",
type: "richText",
localized: true,
},
],
};

@ -0,0 +1,20 @@
import type { CollectionConfig } from "payload";
import { Menu } from "../groups/Menu";
export const MenuCategory: CollectionConfig = {
slug: "menu-category",
access: {
read: () => true,
},
admin: {
useAsTitle: "name",
group: Menu,
},
fields: [
{
name: "name",
type: "text",
localized: true,
},
],
};

@ -0,0 +1,42 @@
import type { CollectionConfig } from "payload";
import { Menu } from "../groups/Menu";
export const MenuItem: CollectionConfig = {
slug: "menu-item",
access: {
read: () => true,
},
admin: {
useAsTitle: "name",
group: Menu,
},
fields: [
{
name: "name",
type: "text",
required: true,
localized: true,
},
{
name: "description",
type: "richText",
localized: true,
},
{
name: "image",
type: "relationship",
relationTo: "media",
},
{
name: "category",
type: "relationship",
relationTo: "menu-category",
},
{
name: "tags",
type: "relationship",
relationTo: "menu-item-tag",
hasMany: true,
},
],
};

@ -0,0 +1,26 @@
import type { CollectionConfig } from "payload";
import { Menu } from "../groups/Menu";
export const MenuItemTag: CollectionConfig = {
slug: "menu-item-tag",
access: {
read: () => true,
},
admin: {
useAsTitle: "name",
group: Menu,
},
fields: [
{
name: "name",
type: "text",
required: true,
localized: true,
},
{
name: "description",
type: "richText",
localized: true,
},
],
};

@ -0,0 +1,77 @@
import type { CollectionConfig, Option } from "payload";
export const DayOptions: Option[] = [
{
label: "Monday",
value: "0",
},
{
label: "Tuesday",
value: "1",
},
{
label: "Wednesday",
value: "2",
},
{
label: "Thursday",
value: "3",
},
{
label: "Friday",
value: "4",
},
{
label: "Saturday",
value: "5",
},
{
label: "Sunday",
value: "6",
},
];
export const OpeningTime: CollectionConfig = {
slug: "opening-time",
access: {
read: () => true,
},
admin: {
defaultColumns: ["from", "to", "timeOpen", "timeClose"],
},
fields: [
{
name: "from",
type: "select",
options: DayOptions,
required: true,
},
{
name: "to",
type: "select",
options: DayOptions,
},
{
name: "timeOpen",
type: "date",
required: true,
admin: {
date: {
pickerAppearance: "timeOnly",
displayFormat: "h:mm:ss a",
},
},
},
{
name: "timeClose",
type: "date",
required: true,
admin: {
date: {
pickerAppearance: "timeOnly",
displayFormat: "h:mm:ss a",
},
},
},
],
};

@ -2,6 +2,16 @@ import type { CollectionConfig } from "payload";
export const Users: CollectionConfig = {
slug: "users",
labels: {
singular: {
en: "User",
de: "Benutzer",
},
plural: {
en: "Users",
de: "Benutzer",
},
},
admin: {
useAsTitle: "email",
},

@ -0,0 +1,20 @@
import type { GlobalConfig } from "payload";
export const About: GlobalConfig = {
slug: "about",
access: {
read: () => true,
},
fields: [
{
name: "name",
type: "text",
required: true,
},
{
name: "text",
type: "richText",
localized: true,
},
],
};

@ -0,0 +1,46 @@
import type { GlobalConfig } from "payload";
export const Contact: GlobalConfig = {
slug: "contact",
access: {
read: () => true,
},
fields: [
{
name: "address",
type: "group",
fields: [
{
type: "row",
fields: [
{
name: "street",
type: "text",
required: true,
},
{
name: "number",
type: "number",
required: true,
},
],
},
{
type: "row",
fields: [
{
name: "zip",
type: "number",
required: true,
},
{
name: "area",
type: "text",
required: true,
},
],
},
],
},
],
};

@ -0,0 +1,15 @@
import type { GlobalConfig } from "payload";
export const Menu: GlobalConfig = {
slug: "menu",
access: {
read: () => true,
},
fields: [
{
name: "file",
type: "relationship",
relationTo: "media",
},
],
};

@ -0,0 +1,4 @@
export const Menu: Record<string, string> = {
en: "Menu",
de: "Menü",
};

@ -13,16 +13,25 @@ export interface Config {
collections: {
users: User;
media: Media;
"payload-preferences": PayloadPreference;
"payload-migrations": PayloadMigration;
'opening-time': OpeningTime;
'menu-item': MenuItem;
'menu-category': MenuCategory;
'menu-item-tag': MenuItemTag;
'food-declaration': FoodDeclaration;
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
};
db: {
defaultIDType: string;
};
globals: {};
locale: null;
globals: {
about: About;
contact: Contact;
menu: Menu;
};
locale: 'de' | 'fr' | 'it' | 'en';
user: User & {
collection: "users";
collection: 'users';
};
}
export interface UserAuthOperations {
@ -79,6 +88,107 @@ export interface Media {
focalX?: number | null;
focalY?: number | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "opening-time".
*/
export interface OpeningTime {
id: string;
from: '0' | '1' | '2' | '3' | '4' | '5' | '6';
to?: ('0' | '1' | '2' | '3' | '4' | '5' | '6') | null;
timeOpen: string;
timeClose: string;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "menu-item".
*/
export interface MenuItem {
id: string;
name: string;
description?: {
root: {
type: string;
children: {
type: string;
version: number;
[k: string]: unknown;
}[];
direction: ('ltr' | 'rtl') | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
indent: number;
version: number;
};
[k: string]: unknown;
} | null;
image?: (string | null) | Media;
category?: (string | null) | MenuCategory;
tags?: (string | MenuItemTag)[] | null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "menu-category".
*/
export interface MenuCategory {
id: string;
name?: string | null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "menu-item-tag".
*/
export interface MenuItemTag {
id: string;
name: string;
description?: {
root: {
type: string;
children: {
type: string;
version: number;
[k: string]: unknown;
}[];
direction: ('ltr' | 'rtl') | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
indent: number;
version: number;
};
[k: string]: unknown;
} | null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "food-declaration".
*/
export interface FoodDeclaration {
id: string;
title: string;
description?: {
root: {
type: string;
children: {
type: string;
version: number;
[k: string]: unknown;
}[];
direction: ('ltr' | 'rtl') | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
indent: number;
version: number;
};
[k: string]: unknown;
} | null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-preferences".
@ -86,7 +196,7 @@ export interface Media {
export interface PayloadPreference {
id: string;
user: {
relationTo: "users";
relationTo: 'users';
value: string | User;
};
key?: string | null;
@ -113,6 +223,56 @@ export interface PayloadMigration {
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "about".
*/
export interface About {
id: string;
name: string;
text?: {
root: {
type: string;
children: {
type: string;
version: number;
[k: string]: unknown;
}[];
direction: ('ltr' | 'rtl') | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
indent: number;
version: number;
};
[k: string]: unknown;
} | null;
updatedAt?: string | null;
createdAt?: string | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "contact".
*/
export interface Contact {
id: string;
address: {
street: string;
number: number;
zip: number;
area: string;
};
updatedAt?: string | null;
createdAt?: string | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "menu".
*/
export interface Menu {
id: string;
file?: (string | null) | Media;
updatedAt?: string | null;
createdAt?: string | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "auth".
@ -121,6 +281,7 @@ export interface Auth {
[k: string]: unknown;
}
declare module "payload" {
declare module 'payload' {
export interface GeneratedTypes extends Config {}
}
}

@ -1,14 +1,27 @@
import { DefaultTranslationsObject, Language } from "@payloadcms/translations";
import { About } from "./globals/About";
import { Contact } from "./globals/Contact";
import { FoodDeclaration } from "./collections/FoodDeclaration";
import { Media } from "./collections/Media";
import { Menu } from "./globals/Menu";
import { MenuCategory } from "./collections/MenuCategory";
import { MenuItem } from "./collections/MenuItem";
import { MenuItemTag } from "./collections/MenuItemTag";
import { OpeningTime } from "./collections/OpeningTime";
import { Users } from "./collections/Users";
import { buildConfig } from "payload";
import { de } from "@payloadcms/translations/languages/de";
import { en } from "@payloadcms/translations/languages/en";
import { fileURLToPath } from "url";
import { fr } from "@payloadcms/translations/languages/fr";
import { it } from "@payloadcms/translations/languages/it";
import { lexicalEditor } from "@payloadcms/richtext-lexical";
// storage-adapter-import-placeholder
import { mongooseAdapter } from "@payloadcms/db-mongodb";
import { lexicalEditor } from "@payloadcms/richtext-lexical";
import path from "path";
import { buildConfig } from "payload";
import { fileURLToPath } from "url";
import sharp from "sharp";
import { Users } from "./collections/Users";
import { Media } from "./collections/Media";
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
@ -19,7 +32,8 @@ export default buildConfig({
baseDir: path.resolve(dirname),
},
},
collections: [Users, Media],
collections: [Users, Media, OpeningTime, MenuItem, MenuCategory, MenuItemTag, FoodDeclaration],
globals: [About, Contact, Menu],
editor: lexicalEditor(),
secret: process.env.PAYLOAD_SECRET || "",
typescript: {
@ -32,4 +46,49 @@ export default buildConfig({
plugins: [
// storage-adapter-placeholder
],
i18n: {
fallbackLanguage: "de",
supportedLanguages: {
en: en as Language<DefaultTranslationsObject>,
de: de as Language<DefaultTranslationsObject>,
fr: fr as Language<DefaultTranslationsObject>,
it: it as Language<DefaultTranslationsObject>,
},
},
localization: {
locales: [
{
label: {
de: "Deutsch",
en: "German",
},
code: "de",
},
{
label: {
fr: "Français",
en: "French",
de: "Französisch",
},
code: "fr",
},
{
label: {
it: "Italiano",
de: "Italienisch",
en: "Italian",
},
code: "it",
},
{
label: {
de: "Englisch",
en: "English",
},
code: "en",
},
],
defaultLocale: "de",
fallback: true,
},
});

@ -2140,6 +2140,18 @@
dependencies:
date-fns "3.3.1"
"@payloadcms/translations@^3.0.0-beta.29":
version "3.0.0-beta.29"
resolved "https://registry.yarnpkg.com/@payloadcms/translations/-/translations-3.0.0-beta.29.tgz#fadad9423bb37143909efc4612f2171f28a449ed"
integrity sha512-mkjniP89wZiYKK6RbVavOlpu8kqKGG8VGGJC8KgEaYoLGHofIW8aDQwHuqjMBFfqhP6I5HFCeqZnZLKCRjuEvQ==
"@payloadcms/translations@^3.0.0-beta.90":
version "3.0.0-beta.90"
resolved "https://registry.yarnpkg.com/@payloadcms/translations/-/translations-3.0.0-beta.90.tgz#367859025479c5e4096ba52a894f99dcb2e5572b"
integrity sha512-AievZitNsKUDDG9TPQuqYOyBxzJl2F3K3NjbMvZTSgNM99T02T7MTpvPJ7UylIA7LP58qMP6hV7uj4LQQ06NDw==
dependencies:
date-fns "3.3.1"
"@payloadcms/ui@3.0.0-beta.90":
version "3.0.0-beta.90"
resolved "https://registry.npmjs.org/@payloadcms/ui/-/ui-3.0.0-beta.90.tgz"
@ -5834,11 +5846,6 @@ is-typed-array@^1.1.13:
dependencies:
which-typed-array "^1.1.14"
is-unicode-supported@*:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-2.0.0.tgz#fdf32df9ae98ff6ab2cedc155a5a6e895701c451"
integrity sha512-FRdAyx5lusK1iHG0TWpVtk9+1i+GjrzRffhDg4ovQ7mcidMQ6mj+MhKPmvh7Xwyv5gIS06ns49CA7Sqg7lC22Q==
is-weakmap@^2.0.2:
version "2.0.2"
resolved "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz"
@ -6202,13 +6209,15 @@ lines-and-columns@^1.1.6:
"localbites@file:.":
version "1.0.0"
dependencies:
"@ark-ui/react" "^3.9.0"
"@payloadcms/db-mongodb" beta
"@payloadcms/next" beta
"@payloadcms/plugin-cloud" beta
"@payloadcms/richtext-lexical" beta
"@payloadcms/translations" "^3.0.0-beta.29"
cross-env "^7.0.3"
graphql "^16.8.1"
localbites "file:../../../AppData/Local/Yarn/Cache/v6/npm-localbites-1.0.0-7acd8e58-fa8a-4df3-a714-9143487e973a-1724409143875/node_modules/localbites"
localbites "file:../../../AppData/Local/Yarn/Cache/v6/npm-localbites-1.0.0-7520c274-de3b-4759-9b37-8dea80be0182-1724413843592/node_modules/localbites"
next "15.0.0-canary.104"
payload beta
react "19.0.0-rc-06d0b89e-20240801"

Loading…
Cancel
Save