- {heading && (
-
- {heading}
-
- )}
- {description && (
-
{description}
+ /* ---- Form content ---- */
+
+ const formContent = (
+ <>
+ {heading && (
+
+ {heading}
+
+ )}
+ {description && (
+
{description}
+ )}
+
+
+ >
+ )
-
+ if (isCard) {
+ return (
+
+ )
+ }
- {hasSideImage && (
+ /* ---- Layout: With image ---- */
+
+ if (hasSideImage) {
+ return (
+
+ )
+ }
+
+ /* ---- Layout: Standard (full width) ---- */
+
+ return (
+
)
diff --git a/src/blocks/FDContactFormBlock/config.ts b/src/blocks/FDContactFormBlock/config.ts
index d723c9b..a8dec7f 100644
--- a/src/blocks/FDContactFormBlock/config.ts
+++ b/src/blocks/FDContactFormBlock/config.ts
@@ -4,10 +4,11 @@ export const FDContactFormBlock: Block = {
slug: 'fdContactForm',
interfaceName: 'FDContactFormBlock',
labels: {
- singular: 'FD Contact Form',
- plural: 'FD Contact Forms',
+ singular: 'FD Kontaktformulär',
+ plural: 'FD Kontaktformulär',
},
fields: [
+ // --- Content ---
{
name: 'form',
type: 'relationship',
@@ -30,7 +31,7 @@ export const FDContactFormBlock: Block = {
type: 'textarea',
label: 'Beskrivning',
defaultValue:
- 'Tell us about your goals, our team will reach out to you and help you achieve the right solution.',
+ 'Berätta om era mål — vårt team kontaktar er och hjälper er hitta rätt lösning.',
},
{
name: 'submitText',
@@ -38,6 +39,50 @@ export const FDContactFormBlock: Block = {
label: 'Skicka-knapp text',
defaultValue: 'Skicka förfrågan',
},
+
+ // --- Layout ---
+ {
+ type: 'row',
+ fields: [
+ {
+ name: 'background',
+ type: 'select',
+ label: 'Bakgrund',
+ defaultValue: 'white',
+ options: [
+ { label: 'Vit', value: 'white' },
+ { label: 'Ljusgrå', value: 'gray' },
+ { label: 'Navy (mörk)', value: 'navy' },
+ { label: 'Navy gradient', value: 'navyGradient' },
+ ],
+ admin: { width: '50%' },
+ },
+ {
+ name: 'layout',
+ type: 'select',
+ label: 'Layout',
+ defaultValue: 'standard',
+ options: [
+ { label: 'Standard (helbredd)', value: 'standard' },
+ { label: 'Med sidobild', value: 'withImage' },
+ { label: 'Kort (centrerat)', value: 'card' },
+ ],
+ admin: { width: '50%' },
+ },
+ ],
+ },
+ {
+ name: 'sideImage',
+ type: 'upload',
+ relationTo: 'media',
+ label: 'Sidobild',
+ admin: {
+ description: 'Visas till höger om formuläret på desktop',
+ condition: (_, siblingData) => siblingData?.layout === 'withImage',
+ },
+ },
+
+ // --- Privacy ---
{
name: 'privacyText',
type: 'textarea',
@@ -46,34 +91,58 @@ export const FDContactFormBlock: Block = {
'Vi använder din kontaktinformation för att svara på din förfrågan och dela detaljer om våra produkter och tjänster. Du kan när som helst avregistrera dig.',
},
{
- name: 'privacyLinkText',
- type: 'text',
- label: 'Integritetslänk text',
- defaultValue: 'integritetspolicy',
+ type: 'row',
+ fields: [
+ {
+ name: 'privacyLinkText',
+ type: 'text',
+ label: 'Integritetslänk text',
+ defaultValue: 'integritetspolicy',
+ admin: { width: '50%' },
+ },
+ {
+ name: 'privacyLinkUrl',
+ type: 'text',
+ label: 'Integritetslänk URL',
+ defaultValue: '/integritetspolicy',
+ admin: { width: '50%' },
+ },
+ ],
},
+
+ // --- External API (optional) ---
{
- name: 'privacyLinkUrl',
- type: 'text',
- label: 'Integritetslänk URL',
- defaultValue: '/integritetspolicy',
- },
- {
- name: 'sideImage',
- type: 'upload',
- relationTo: 'media',
- label: 'Sidobild (valfri)',
+ name: 'externalApi',
+ type: 'group',
+ label: 'Extern API-integration (valfri)',
admin: {
- description: 'Bild som visas till höger om formuläret',
+ description: 'Skicka formulärdata till ett externt system (t.ex. Lime CRM) utöver Payload',
},
- },
- {
- name: 'background',
- type: 'select',
- label: 'Bakgrund',
- defaultValue: 'white',
- options: [
- { label: 'Vit', value: 'white' },
- { label: 'Grå', value: 'gray' },
+ fields: [
+ {
+ name: 'enabled',
+ type: 'checkbox',
+ label: 'Aktivera extern API',
+ defaultValue: false,
+ },
+ {
+ name: 'endpoint',
+ type: 'text',
+ label: 'API-URL',
+ admin: {
+ description: 'T.ex. https://api.lime-crm.se/webhook/forms',
+ condition: (_, siblingData) => Boolean(siblingData?.enabled),
+ },
+ },
+ {
+ name: 'authToken',
+ type: 'text',
+ label: 'Auth-token (Bearer)',
+ admin: {
+ description: 'Skickas som Authorization: Bearer {token}',
+ condition: (_, siblingData) => Boolean(siblingData?.enabled),
+ },
+ },
],
},
],
diff --git a/src/payload-types.ts b/src/payload-types.ts
index c2548f4..9bd55ef 100644
--- a/src/payload-types.ts
+++ b/src/payload-types.ts
@@ -75,7 +75,6 @@ export interface Config {
redirects: Redirect;
forms: Form;
'form-submissions': FormSubmission;
- search: Search;
'payload-kv': PayloadKv;
'payload-jobs': PayloadJob;
'payload-locked-documents': PayloadLockedDocument;
@@ -92,7 +91,6 @@ export interface Config {
redirects: RedirectsSelect
| RedirectsSelect;
forms: FormsSelect | FormsSelect;
'form-submissions': FormSubmissionsSelect | FormSubmissionsSelect;
- search: SearchSelect | SearchSelect;
'payload-kv': PayloadKvSelect | PayloadKvSelect;
'payload-jobs': PayloadJobsSelect | PayloadJobsSelect;
'payload-locked-documents': PayloadLockedDocumentsSelect | PayloadLockedDocumentsSelect;
@@ -758,14 +756,29 @@ export interface FDContactFormBlock {
heading: string;
description?: string | null;
submitText?: string | null;
+ background?: ('white' | 'gray' | 'navy' | 'navyGradient') | null;
+ layout?: ('standard' | 'withImage' | 'card') | null;
+ /**
+ * Visas till höger om formuläret på desktop
+ */
+ sideImage?: (number | null) | Media;
privacyText?: string | null;
privacyLinkText?: string | null;
privacyLinkUrl?: string | null;
/**
- * Bild som visas till höger om formuläret
+ * Skicka formulärdata till ett externt system (t.ex. Lime CRM) utöver Payload
*/
- sideImage?: (number | null) | Media;
- background?: ('white' | 'gray') | null;
+ externalApi?: {
+ enabled?: boolean | null;
+ /**
+ * T.ex. https://api.lime-crm.se/webhook/forms
+ */
+ endpoint?: string | null;
+ /**
+ * Skickas som Authorization: Bearer {token}
+ */
+ authToken?: string | null;
+ };
id?: string | null;
blockName?: string | null;
blockType: 'fdContactForm';
@@ -1364,37 +1377,6 @@ export interface FormSubmission {
updatedAt: string;
createdAt: string;
}
-/**
- * This is a collection of automatically created search results. These results are used by the global site search and will be updated automatically as documents in the CMS are created or updated.
- *
- * This interface was referenced by `Config`'s JSON-Schema
- * via the `definition` "search".
- */
-export interface Search {
- id: number;
- title?: string | null;
- priority?: number | null;
- doc: {
- relationTo: 'posts';
- value: number | Post;
- };
- slug?: string | null;
- meta?: {
- title?: string | null;
- description?: string | null;
- image?: (number | null) | Media;
- };
- categories?:
- | {
- relationTo?: string | null;
- categoryID?: string | null;
- title?: string | null;
- id?: string | null;
- }[]
- | null;
- updatedAt: string;
- createdAt: string;
-}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv".
@@ -1542,10 +1524,6 @@ export interface PayloadLockedDocument {
| ({
relationTo: 'form-submissions';
value: number | FormSubmission;
- } | null)
- | ({
- relationTo: 'search';
- value: number | Search;
} | null);
globalSlug?: string | null;
user: {
@@ -1952,11 +1930,19 @@ export interface FDContactFormBlockSelect {
heading?: T;
description?: T;
submitText?: T;
+ background?: T;
+ layout?: T;
+ sideImage?: T;
privacyText?: T;
privacyLinkText?: T;
privacyLinkUrl?: T;
- sideImage?: T;
- background?: T;
+ externalApi?:
+ | T
+ | {
+ enabled?: T;
+ endpoint?: T;
+ authToken?: T;
+ };
id?: T;
blockName?: T;
}
@@ -2520,33 +2506,6 @@ export interface FormSubmissionsSelect {
updatedAt?: T;
createdAt?: T;
}
-/**
- * This interface was referenced by `Config`'s JSON-Schema
- * via the `definition` "search_select".
- */
-export interface SearchSelect {
- title?: T;
- priority?: T;
- doc?: T;
- slug?: T;
- meta?:
- | T
- | {
- title?: T;
- description?: T;
- image?: T;
- };
- categories?:
- | T
- | {
- relationTo?: T;
- categoryID?: T;
- title?: T;
- id?: T;
- };
- updatedAt?: T;
- createdAt?: T;
-}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv_select".
diff --git a/src/plugins/index.ts b/src/plugins/index.ts
index d7a29a0..e84d387 100644
--- a/src/plugins/index.ts
+++ b/src/plugins/index.ts
@@ -3,12 +3,9 @@ import { FixedToolbarFeature, HeadingFeature, lexicalEditor } from '@payloadcms/
import { nestedDocsPlugin } from '@payloadcms/plugin-nested-docs'
import { redirectsPlugin } from '@payloadcms/plugin-redirects'
import { seoPlugin } from '@payloadcms/plugin-seo'
-import { searchPlugin } from '@payloadcms/plugin-search'
import { Plugin } from 'payload'
import { revalidateRedirects } from '@/hooks/revalidateRedirects'
import { GenerateTitle, GenerateURL } from '@payloadcms/plugin-seo/types'
-import { searchFields } from '@/search/fieldOverrides'
-import { beforeSyncWithSearch } from '@/search/beforeSync'
import { Page, Post } from '@/payload-types'
import { getServerSideURL } from '@/utilities/getURL'
@@ -79,13 +76,4 @@ export const plugins: Plugin[] = [
},
},
}),
- searchPlugin({
- collections: ['posts'],
- beforeSync: beforeSyncWithSearch,
- searchOverrides: {
- fields: ({ defaultFields }) => {
- return [...defaultFields, ...searchFields]
- },
- },
- }),
]