diff --git a/apps/civicsignalblog/payload.config.ts b/apps/civicsignalblog/payload.config.ts index 8a20c6005..98b9cea96 100644 --- a/apps/civicsignalblog/payload.config.ts +++ b/apps/civicsignalblog/payload.config.ts @@ -25,6 +25,9 @@ import Actions from "./src/payload/components/actions"; import Publication from "./src/payload/globals/Publication"; import Main from "./src/payload/globals/Site/main"; import Research from "./src/payload/globals/Site/research"; +import Login from "./src/payload/globals/Forms/login"; +import PasswordReset from "./src/payload/globals/Forms/resetPassword"; +import Registration from "./src/payload/globals/Forms/registration"; import { applicationPages } from "./src/payload/lib/data/common/applications"; import { defaultLocale, locales } from "./src/payload/utils/locales"; @@ -74,7 +77,14 @@ export default buildConfig({ MediaData, Users, ] as CollectionConfig[], - globals: [Publication, Research, Main] as GlobalConfig[], + globals: [ + Publication, + Research, + Main, + Login, + Registration, + PasswordReset, + ] as GlobalConfig[], ...(locales?.length ? { localization: { diff --git a/apps/civicsignalblog/src/payload/fields/formInputFieldGroup.js b/apps/civicsignalblog/src/payload/fields/formInputFieldGroup.js new file mode 100644 index 000000000..c02670cd3 --- /dev/null +++ b/apps/civicsignalblog/src/payload/fields/formInputFieldGroup.js @@ -0,0 +1,55 @@ +function formInputFieldGroup({ + label, + name, + includeHintField = false, + includeErrorMessageField = true, + defaultLabelValue = "", + defaultErrorMessage = "", + defaultHint = "", + additionalFields = [], +}) { + const fields = [ + { + name: `${name}Label`, + label: "Label", + type: "text", + defaultValue: defaultLabelValue, + required: true, + }, + ]; + + if (includeHintField) { + fields.push({ + name: `${name}Hint`, + label: "Hint", + type: "text", + defaultValue: defaultHint, + required: true, + }); + } + + if (includeErrorMessageField) { + fields.push({ + name: `${name}ErrorMessage`, + type: "text", + label: "Error Message", + defaultValue: defaultErrorMessage, + required: true, + }); + } + + fields.push(...additionalFields); + + return { + type: "collapsible", + label, + fields: [ + { + type: "row", + fields, + }, + ], + }; +} + +export default formInputFieldGroup; diff --git a/apps/civicsignalblog/src/payload/globals/Forms/login/LoginTab.js b/apps/civicsignalblog/src/payload/globals/Forms/login/LoginTab.js new file mode 100644 index 000000000..121254a07 --- /dev/null +++ b/apps/civicsignalblog/src/payload/globals/Forms/login/LoginTab.js @@ -0,0 +1,90 @@ +import formInputFieldGroup from "#civicsignalblog/payload/fields/formInputFieldGroup"; +import richText from "#civicsignalblog/payload/fields/richText"; + +const LoginTab = { + label: "Login Form", + fields: [ + { + type: "collapsible", + label: "Title & Description", + fields: [ + { + name: "title", + type: "text", + defaultValue: "Login", + required: true, + localized: true, + }, + ], + }, + { + type: "collapsible", + label: "Fields", + fields: [ + formInputFieldGroup({ + label: "E-mail", + name: "email", + defaultLabelValue: "Email", + defaultErrorMessage: "You need to enter your email address.", + }), + formInputFieldGroup({ + label: "Password", + name: "password", + defaultLabelValue: "Password", + defaultErrorMessage: "You need to enter your password.", + }), + ], + }, + { + type: "collapsible", + label: "Messages", + fields: [ + { + name: "loginFailed", + type: "text", + defaultValue: "Your email or password was wrong.", + required: true, + }, + richText({ + name: "needsToActivate", + required: true, + localized: true, + }), + ], + }, + { + type: "collapsible", + label: "Actions", + fields: [ + { + type: "row", + fields: [ + { + name: "loginButton", + type: "text", + defaultValue: "Login", + required: true, + localized: true, + }, + { + name: "registrationButton", + type: "text", + defaultValue: "No Account ? Register Now!", + required: true, + localized: true, + }, + { + name: "forgotPasswordButton", + type: "text", + defaultValue: "Forgot your password ?", + required: true, + localized: true, + }, + ], + }, + ], + }, + ], +}; + +export default LoginTab; diff --git a/apps/civicsignalblog/src/payload/globals/Forms/login/index.js b/apps/civicsignalblog/src/payload/globals/Forms/login/index.js new file mode 100644 index 000000000..0ecdb0eda --- /dev/null +++ b/apps/civicsignalblog/src/payload/globals/Forms/login/index.js @@ -0,0 +1,15 @@ +import LoginTab from "./LoginTab"; + +import settings from "#civicsignalblog/payload/utils/createGlobalSettings"; + +const Login = settings({ + slug: `login-form`, + label: "Login", + group: "Forms", + access: { + read: () => true, + }, + tabs: [LoginTab], +}); + +export default Login; diff --git a/apps/civicsignalblog/src/payload/globals/Forms/registration/RegistrationTab.js b/apps/civicsignalblog/src/payload/globals/Forms/registration/RegistrationTab.js new file mode 100644 index 000000000..d614967a9 --- /dev/null +++ b/apps/civicsignalblog/src/payload/globals/Forms/registration/RegistrationTab.js @@ -0,0 +1,146 @@ +import formInputFieldGroup from "#civicsignalblog/payload/fields/formInputFieldGroup"; +import richText from "#civicsignalblog/payload/fields/richText"; + +const RegisterTab = { + label: "Registration Form", + fields: [ + { + type: "collapsible", + label: "Title & Description", + fields: [ + { + name: "title", + type: "text", + defaultValue: "Sign Up", + required: true, + localized: true, + }, + { + name: "description", + type: "text", + defaultValue: "Create an account to use all our tools for free.", + required: true, + localized: true, + }, + ], + }, + { + type: "collapsible", + label: "Fields", + fields: [ + formInputFieldGroup({ + label: "E-mail", + name: "email", + defaultLabelValue: "Email", + defaultErrorMessage: "You need to enter a valid email address.", + }), + formInputFieldGroup({ + label: "Full Name", + name: "fullName", + includeErrorMessageField: false, + defaultLabelValue: "Full Name", + }), + formInputFieldGroup({ + label: "Password", + name: "password", + defaultLabelValue: "Password", + defaultErrorMessage: "You need to enter your password.", + additionalFields: [ + { + name: "passwordsMismatch", + type: "text", + required: true, + defaultValue: "You need to enter your password.", + localized: true, + }, + { + name: "passwordTooShort", + type: "text", + required: true, + defaultValue: "Passwords must be at least 8 characters long.", + localized: true, + }, + ], + }), + formInputFieldGroup({ + label: "Confirm Password", + name: "confirmPassword", + defaultLabelValue: "Confirm Password", + includeErrorMessageField: false, + }), + formInputFieldGroup({ + label: "Notes", + name: "notes", + defaultHint: + "Tell us a little about what you want to use Media Cloud for", + defaultLabelValue: "Notes", + defaultErrorMessage: + "You have to tell us a little about why you want to use Media Cloud.", + includeHintField: true, + }), + { + type: "collapsible", + label: "Consent", + fields: [ + richText({ + name: "consentLabel", + label: "Label", + required: true, + localized: true, + }), + { + name: "consentError", + type: "text", + defaultValue: "You must agree to our Terms and Policies", + required: true, + localized: true, + }, + ], + }, + ], + }, + { + type: "collapsible", + label: "Messages", + fields: [ + { + name: "successFeedback", + type: "text", + defaultValue: "Successfully signed up.", + required: true, + localized: true, + }, + richText({ + name: "userAlreadyExists", + required: true, + localized: true, + }), + richText({ + name: "signupSuccess", + required: true, + localized: true, + }), + ], + }, + { + type: "collapsible", + label: "Actions", + fields: [ + { + type: "row", + fields: [ + { + name: "signUpButton", + type: "text", + defaultValue: "Sign Up", + required: true, + localized: true, + }, + ], + }, + ], + }, + ], +}; + +export default RegisterTab; diff --git a/apps/civicsignalblog/src/payload/globals/Forms/registration/index.js b/apps/civicsignalblog/src/payload/globals/Forms/registration/index.js new file mode 100644 index 000000000..eafd559a9 --- /dev/null +++ b/apps/civicsignalblog/src/payload/globals/Forms/registration/index.js @@ -0,0 +1,15 @@ +import RegistrationTab from "./RegistrationTab"; + +import settings from "#civicsignalblog/payload/utils/createGlobalSettings"; + +const Registration = settings({ + slug: `registration-form`, + label: "Registration", + group: "Forms", + access: { + read: () => true, + }, + tabs: [RegistrationTab], +}); + +export default Registration; diff --git a/apps/civicsignalblog/src/payload/globals/Forms/resetPassword/ResetPasswordTab.js b/apps/civicsignalblog/src/payload/globals/Forms/resetPassword/ResetPasswordTab.js new file mode 100644 index 000000000..dc1a0862c --- /dev/null +++ b/apps/civicsignalblog/src/payload/globals/Forms/resetPassword/ResetPasswordTab.js @@ -0,0 +1,87 @@ +import formInputFieldGroup from "#civicsignalblog/payload/fields/formInputFieldGroup"; + +const ResetPassword = { + label: "Reset Password Form", + fields: [ + { + type: "collapsible", + label: "Title & Description", + fields: [ + { + name: "title", + type: "text", + defaultValue: "Forgot Your Password?", + required: true, + localized: true, + }, + { + name: "description", + type: "text", + defaultValue: + "Enter your email address and we will send you a link to reset your password.", + required: true, + localized: true, + }, + ], + }, + { + type: "collapsible", + label: "Fields", + fields: [ + formInputFieldGroup({ + label: "E-mail", + name: "email", + defaultLabelValue: "Email", + defaultErrorMessage: "You need to enter a valid email address.", + }), + ], + }, + { + type: "collapsible", + label: "Messages", + fields: [ + { + name: "passwordResetFailed", + type: "text", + defaultValue: "Sorry, something went wrong.", + required: true, + }, + { + name: "passwordResetSuccessTitle", + type: "text", + defaultValue: "We Reset Your Password", + required: true, + localized: true, + }, + { + name: "passwordResetSuccessDescription", + type: "text", + defaultValue: + "We have reset your password. We emailed you just to confirm that you did this on purpose - don't be suprised.", + required: true, + localized: true, + }, + ], + }, + { + type: "collapsible", + label: "Actions", + fields: [ + { + type: "row", + fields: [ + { + name: "passwordResetButton", + type: "text", + defaultValue: "Send Password Reset Email", + required: true, + localized: true, + }, + ], + }, + ], + }, + ], +}; + +export default ResetPassword; diff --git a/apps/civicsignalblog/src/payload/globals/Forms/resetPassword/index.js b/apps/civicsignalblog/src/payload/globals/Forms/resetPassword/index.js new file mode 100644 index 000000000..35bacf457 --- /dev/null +++ b/apps/civicsignalblog/src/payload/globals/Forms/resetPassword/index.js @@ -0,0 +1,15 @@ +import ResetPasswordTab from "./ResetPasswordTab"; + +import settings from "#civicsignalblog/payload/utils/createGlobalSettings"; + +const ResetPassword = settings({ + slug: `reset-password-form`, + label: "Password Reset", + group: "Forms", + access: { + read: () => true, + }, + tabs: [ResetPasswordTab], +}); + +export default ResetPassword; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3097b61e5..4092d5d33 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -671,7 +671,7 @@ importers: version: 0.84.0(prop-types@15.8.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@payloadcms/bundler-webpack': specifier: 'catalog:' - version: 1.0.7(@swc/core@1.8.0(@swc/helpers@0.5.5))(ajv@8.17.1)(payload@2.30.3(@swc/helpers@0.5.5)(@types/react@18.3.12)(encoding@0.1.13)(typescript@5.6.3)(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.5))(webpack-cli@4.10.0)))(sass@1.69.4) + version: 1.0.7(@swc/core@1.8.0(@swc/helpers@0.5.5))(ajv@6.12.6)(payload@2.30.3(@swc/helpers@0.5.5)(@types/react@18.3.12)(encoding@0.1.13)(typescript@5.6.3)(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.5))(webpack-cli@4.10.0)))(sass@1.69.4) '@payloadcms/db-mongodb': specifier: 'catalog:' version: 1.7.3(@aws-sdk/client-sso-oidc@3.682.0(@aws-sdk/client-sts@3.682.0))(payload@2.30.3(@swc/helpers@0.5.5)(@types/react@18.3.12)(encoding@0.1.13)(typescript@5.6.3)(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.5))(webpack-cli@4.10.0))) @@ -6589,13 +6589,11 @@ packages: '@swc/register@0.1.10': resolution: {integrity: sha512-6STwH/q4dc3pitXLVkV7sP0Hiy+zBsU2wOF1aXpXR95pnH3RYHKIsDC+gvesfyB7jxNT9OOZgcqOp9RPxVTx9A==} + deprecated: Use @swc-node/register instead hasBin: true peerDependencies: '@swc/core': ^1.0.46 - '@swc/types@0.1.12': - resolution: {integrity: sha512-wBJA+SdtkbFhHjTMYH+dEH1y4VpfGdAc2Kw/LK09i9bXd/K6j6PkDcFCEzb6iVfZMkPRrl/q0e3toqTAJdkIVA==} - '@swc/types@0.1.14': resolution: {integrity: sha512-PbSmTiYCN+GMrvfjrMo9bdY+f2COnwbdnoMw7rqU/PI5jXpKjxOGZ0qqZCImxnT81NkNsKnmEpvu+hRXLBeCJg==} @@ -18025,9 +18023,9 @@ snapshots: '@panva/hkdf@1.2.1': {} - '@payloadcms/bundler-webpack@1.0.7(@swc/core@1.8.0(@swc/helpers@0.5.5))(ajv@8.17.1)(payload@2.30.3(@swc/helpers@0.5.5)(@types/react@18.3.12)(encoding@0.1.13)(typescript@5.6.3)(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.5))(webpack-cli@4.10.0)))(sass@1.69.4)': + '@payloadcms/bundler-webpack@1.0.7(@swc/core@1.8.0(@swc/helpers@0.5.5))(ajv@6.12.6)(payload@2.30.3(@swc/helpers@0.5.5)(@types/react@18.3.12)(encoding@0.1.13)(typescript@5.6.3)(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.5))(webpack-cli@4.10.0)))(sass@1.69.4)': dependencies: - ajv: 8.17.1 + ajv: 6.12.6 compression: 1.7.4 connect-history-api-fallback: 1.6.0 css-loader: 5.2.7(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.5))(webpack-cli@4.10.0)) @@ -19993,7 +19991,7 @@ snapshots: '@swc/core@1.6.1(@swc/helpers@0.5.5)': dependencies: '@swc/counter': 0.1.3 - '@swc/types': 0.1.12 + '@swc/types': 0.1.14 optionalDependencies: '@swc/core-darwin-arm64': 1.6.1 '@swc/core-darwin-x64': 1.6.1 @@ -20038,10 +20036,6 @@ snapshots: pirates: 4.0.6 source-map-support: 0.5.21 - '@swc/types@0.1.12': - dependencies: - '@swc/counter': 0.1.3 - '@swc/types@0.1.14': dependencies: '@swc/counter': 0.1.3