diff --git a/src/lib/components/CmsForm.svelte b/src/lib/components/CmsForm.svelte
index 47304d7e1..733f67a00 100644
--- a/src/lib/components/CmsForm.svelte
+++ b/src/lib/components/CmsForm.svelte
@@ -14,9 +14,11 @@
fullScreen: boolean;
hideFromSEO?: boolean;
hasMobileContent?: boolean;
+ hasEmployeeContent?: boolean;
maintenanceDisplay: boolean;
content: string;
mobileContent?: string;
+ employeeContent?: string;
metas?: {
name: string;
content: string;
@@ -32,7 +34,10 @@
let hideFromSEO = cmsPage?.hideFromSEO || false;
let hasCustomMeta = !!cmsPage?.metas?.length;
let hasMobileContent = cmsPage?.hasMobileContent || false;
+ let hasEmployeeContent = cmsPage?.hasEmployeeContent || false;
let mobileContent = cmsPage?.mobileContent || '';
+ let employeeContent = cmsPage?.employeeContent || '';
+
function confirmDelete(event: Event) {
if (!confirm('Would you like to delete this CMS page?')) {
event.preventDefault();
@@ -276,6 +281,37 @@
/>
{/if}
+
+ {#if hasEmployeeContent}
+
+ {/if}
{#if cmsPage}
diff --git a/src/lib/types/CmsPage.ts b/src/lib/types/CmsPage.ts
index c4a11c21e..927e00350 100644
--- a/src/lib/types/CmsPage.ts
+++ b/src/lib/types/CmsPage.ts
@@ -6,6 +6,7 @@ export interface CMSPageTranslatableFields {
shortDescription: string;
content: string;
mobileContent?: string;
+ employeeContent?: string;
}
export interface CMSPage extends Timestamps, CMSPageTranslatableFields {
@@ -14,6 +15,7 @@ export interface CMSPage extends Timestamps, CMSPageTranslatableFields {
maintenanceDisplay: boolean;
hideFromSEO?: boolean;
hasMobileContent?: boolean;
+ hasEmployeeContent?: boolean;
metas?: {
name: string;
content: string;
diff --git a/src/routes/(app)/+page.server.ts b/src/routes/(app)/+page.server.ts
index 505cd4ee8..788206323 100644
--- a/src/routes/(app)/+page.server.ts
+++ b/src/routes/(app)/+page.server.ts
@@ -4,6 +4,7 @@ import { load as catalogLoad } from './catalog/+page.server';
import { cmsFromContent } from '$lib/server/cms';
import { redirect } from '@sveltejs/kit';
import { addYears } from 'date-fns';
+import { CUSTOMER_ROLE_ID } from '$lib/types/User';
export const load = async ({ locals }) => {
const cmsPage = await collections.cmsPages.findOne(
@@ -16,6 +17,10 @@ export const load = async ({ locals }) => {
mobileContent: {
$ifNull: [`$translations.${locals.language}.mobileContent`, '$mobileContent']
},
+ employeeContent: {
+ $ifNull: [`$translations.${locals.language}.employeeContent`, '$employeeContent']
+ },
+ hasEmployeeContent: 1,
title: { $ifNull: [`$translations.${locals.language}.title`, '$title'] },
shortDescription: {
$ifNull: [`$translations.${locals.language}.shortDescription`, '$shortDescription']
@@ -36,7 +41,15 @@ export const load = async ({ locals }) => {
return {
cmsPage: omit(cmsPage, ['content']),
cmsData: cmsFromContent(
- { content: cmsPage.content, mobileContent: cmsPage.mobileContent },
+ {
+ content:
+ locals.user?.roleId !== CUSTOMER_ROLE_ID &&
+ cmsPage.hasEmployeeContent &&
+ cmsPage.employeeContent
+ ? cmsPage.employeeContent
+ : cmsPage.content,
+ mobileContent: cmsPage.mobileContent
+ },
locals
),
layoutReset: cmsPage.fullScreen
diff --git a/src/routes/(app)/[slug]/+page.server.ts b/src/routes/(app)/[slug]/+page.server.ts
index b2422fc3c..5f2e7c345 100644
--- a/src/routes/(app)/[slug]/+page.server.ts
+++ b/src/routes/(app)/[slug]/+page.server.ts
@@ -2,6 +2,7 @@ import { collections } from '$lib/server/database';
import { omit } from 'lodash-es';
import { cmsFromContent } from '$lib/server/cms.js';
import { error } from '@sveltejs/kit';
+import { CUSTOMER_ROLE_ID } from '$lib/types/User';
export async function load({ params, locals, url }) {
let cmsPage = await collections.cmsPages.findOne(
@@ -18,11 +19,15 @@ export async function load({ params, locals, url }) {
shortDescription: {
$ifNull: [`$translations.${locals.language}.shortDescription`, '$shortDescription']
},
+ employeeContent: {
+ $ifNull: [`$translations.${locals.language}.employeeContent`, '$employeeContent']
+ },
fullScreen: 1,
maintenanceDisplay: 1,
hideFromSEO: 1,
hasMobileContent: 1,
- metas: 1
+ metas: 1,
+ hasEmployeeContent: 1
}
}
);
@@ -56,15 +61,30 @@ export async function load({ params, locals, url }) {
}
return {
- cmsPage: omit(cmsPage, ['content', 'mobileContent']),
+ cmsPage: omit(cmsPage, ['content', 'mobileContent', 'employeeContent']),
cmsData: cmsFromContent(
url.searchParams.get('content') === 'desktop' ||
!cmsPage.hasMobileContent ||
!cmsPage.mobileContent
- ? { content: cmsPage.content }
+ ? {
+ content:
+ locals.user?.roleId !== CUSTOMER_ROLE_ID &&
+ cmsPage.hasEmployeeContent &&
+ cmsPage.employeeContent
+ ? cmsPage.employeeContent
+ : cmsPage.content
+ }
: url.searchParams.get('content') === 'mobile'
? { content: cmsPage.mobileContent }
- : { content: cmsPage.content, mobileContent: cmsPage.mobileContent },
+ : {
+ content:
+ locals.user?.roleId !== CUSTOMER_ROLE_ID &&
+ cmsPage.hasEmployeeContent &&
+ cmsPage.employeeContent
+ ? cmsPage.employeeContent
+ : cmsPage.content,
+ mobileContent: cmsPage.mobileContent
+ },
locals
),
layoutReset: cmsPage.fullScreen,
diff --git a/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/+page.server.ts b/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/+page.server.ts
index 3ff72c037..91eb5b222 100644
--- a/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/+page.server.ts
+++ b/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/+page.server.ts
@@ -32,6 +32,8 @@ export const actions = {
hideFromSEO,
hasMobileContent,
mobileContent,
+ hasEmployeeContent,
+ employeeContent,
metas
} = z
.object({
@@ -40,8 +42,8 @@ export const actions = {
maintenanceDisplay: z.boolean({ coerce: true }),
hideFromSEO: z.boolean({ coerce: true }),
desktopDisplayOnly: z.boolean({ coerce: true }),
- mobileDisplaySubstitution: z.boolean({ coerce: true }),
hasMobileContent: z.boolean({ coerce: true }),
+ hasEmployeeContent: z.boolean({ coerce: true }),
metas: z
.array(
z.object({
@@ -67,7 +69,9 @@ export const actions = {
maintenanceDisplay,
hideFromSEO,
hasMobileContent,
- ...(hasMobileContent && mobileContent && { mobileContent }),
+ ...(hasMobileContent && { mobileContent }),
+ hasEmployeeContent,
+ ...(hasEmployeeContent && { employeeContent }),
...(metas.length && { metas: metas.filter((meta) => meta.name && meta.content) }),
updatedAt: new Date()
},
diff --git a/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/cms-schema.ts b/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/cms-schema.ts
index b94044b0f..056fcb6e8 100644
--- a/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/cms-schema.ts
+++ b/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/cms-schema.ts
@@ -6,5 +6,6 @@ export const cmsTranslatableSchema = {
title: z.string().min(1).max(MAX_NAME_LIMIT),
content: z.string().max(MAX_CONTENT_LIMIT),
shortDescription: z.string().max(MAX_SHORT_DESCRIPTION_LIMIT),
- mobileContent: z.string().max(MAX_CONTENT_LIMIT).optional()
+ mobileContent: z.string().max(MAX_CONTENT_LIMIT).optional(),
+ employeeContent: z.string().max(MAX_CONTENT_LIMIT).optional()
};
diff --git a/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/translations/+page.svelte b/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/translations/+page.svelte
index 816494d9a..90a9931a6 100644
--- a/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/translations/+page.svelte
+++ b/src/routes/(app)/admin[[hash=admin_hash]]/cms/[slug]/translations/+page.svelte
@@ -52,6 +52,17 @@
value={data.cmsPage.translations?.[language]?.mobileContent ?? ''}
/>
+