Axil_Accountants/src/lib/seed.ts
Vadym Samoilenko 3f6dfe36b1 feat: full CMS integration — connect all content to Payload admin panel
- Connect homepage, blog, services, header, footer to Payload CMS via local API
- Add HomePage global with 7 editorial sections (hero, painPoints, solution, whyAxil, audience, process, finalCta)
- Add ServerHeader/ServerFooter async wrappers with unstable_cache + tag-based ISR revalidation
- Rewrite blog/[slug] and services/[slug] pages to fetch from CMS with fallbacks
- Add seed script (src/lib/seed.ts) to populate all collections and globals from hardcoded defaults
- Restructure app into (site)/ route group to fix Payload admin hydration conflicts
- Make root layout a passthrough; (site)/layout.tsx owns html/body/fonts
- Restrict user creation/update/delete to admin role only
- Fix migration imports: type MigrateUpArgs/Down from @payloadcms/db-postgres
- Wrap revalidateTag dynamic imports in try/catch for seed/CLI compatibility
- Skip migrations in dev mode (Payload handles schema push automatically)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 21:19:44 +00:00

765 lines
29 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* CMS Seed Script
* Populates all Payload CMS collections and globals from current hardcoded values.
*
* Run once after a fresh database:
* DATABASE_URI="postgresql://axil:axil_dev@localhost:5432/axil" \
* NODE_OPTIONS="--experimental-strip-types --no-require-module" \
* npx tsx src/lib/seed.ts
*/
import { getPayload } from 'payload';
import config from '../payload.config.ts';
// ─── Lexical helpers ────────────────────────────────────────────────────────
function lexicalParagraph(text: string) {
return {
root: {
type: 'root',
direction: 'ltr' as const,
format: '' as const,
indent: 0,
version: 1,
children: [
{
type: 'paragraph',
version: 1,
direction: 'ltr' as const,
format: '' as const,
indent: 0,
children: [
{
type: 'text',
version: 1,
text,
format: 0,
detail: 0,
mode: 'normal' as const,
style: '',
},
],
},
],
},
};
}
// ─── Main ────────────────────────────────────────────────────────────────────
async function seed() {
const payload = await getPayload({ config });
console.log('\n🌱 Seeding CMS data...\n');
// ── 1. Categories ──────────────────────────────────────────────────────────
console.log('─ Categories');
const CATEGORY_NAMES = ['Tax', 'HMRC', 'Payroll', 'Finance', 'Business'];
const categoryIds: Record<string, number> = {};
for (const name of CATEGORY_NAMES) {
const existing = await payload.find({
collection: 'categories',
where: { name: { equals: name } },
limit: 1,
});
if (existing.docs.length) {
categoryIds[name] = existing.docs[0].id as number;
console.log(` ✓ '${name}' exists`);
} else {
const cat = await payload.create({
collection: 'categories',
data: { name, slug: name.toLowerCase().replace(/\s+/g, '-') },
});
categoryIds[name] = cat.id as number;
console.log(` + Created '${name}'`);
}
}
// ── 2. Services ────────────────────────────────────────────────────────────
console.log('\n─ Services');
const SERVICES = [
{
title: 'Bookkeeping',
slug: 'bookkeeping',
icon: 'bookkeeping' as const,
tagline: 'Accurate records, zero stress',
descText:
'Up-to-date books every month, cloud-based and always accessible. We reconcile every transaction so your accounts are always audit-ready — and you always know where you stand.',
whatsIncluded: [
'Monthly bank reconciliation',
'Expense categorisation & receipts',
'Accounts payable & receivable tracking',
'Cloud accounting software setup (Xero/QuickBooks)',
'Monthly management accounts',
'Real-time financial dashboard access',
],
howItWorks: [
{
step: 1,
title: 'Save 10+ hours per month',
description:
'Stop wrestling with spreadsheets. We handle every transaction so you never have to.',
},
{
step: 2,
title: 'Always audit-ready',
description:
'Clean, HMRC-compliant records mean no panic when a filing deadline arrives.',
},
{
step: 3,
title: 'Real-time visibility',
description:
'Log in any time to see exactly how your business is performing, with no surprises.',
},
],
faq: [
{
question: 'Which accounting software do you use?',
answerText:
"We work with Xero, QuickBooks and Sage. We'll recommend the best option for your business and handle the setup.",
},
{
question: 'How do I send you my receipts?',
answerText:
'Via a simple mobile app — just photograph receipts on your phone. No more shoeboxes.',
},
{
question: 'How quickly are transactions recorded?',
answerText:
'All transactions are reconciled within 48 hours of your bank feed updating, usually faster.',
},
],
},
{
title: 'Tax Returns',
slug: 'tax-returns',
icon: 'tax' as const,
tagline: 'Every allowance claimed',
descText:
'From self-assessment to corporation tax, we handle every filing and actively look for every allowance, deduction and relief your business is entitled to.',
whatsIncluded: [
'Self-assessment tax return preparation & filing',
'Corporation tax (CT600) preparation & filing',
'Capital allowances review',
'R&D tax credits (if applicable)',
'HMRC correspondence management',
'Tax planning & year-end strategy',
],
howItWorks: [
{
step: 1,
title: 'Never miss a deadline',
description:
"We track every HMRC deadline and file well in advance — you'll never pay a late filing penalty.",
},
{
step: 2,
title: 'Maximum allowances',
description:
'Our tax specialists review every available allowance and relief to legally minimise your tax bill.',
},
{
step: 3,
title: 'HMRC as a proxy',
description:
'We handle all correspondence with HMRC. You never have to speak to them directly unless you want to.',
},
],
faq: [
{
question: 'When do you start my tax return?',
answerText:
"We begin collecting information 34 months before your filing deadline so there's never a rush.",
},
{
question: 'What if HMRC investigates me?',
answerText:
'We represent you fully and handle the entire process. Our fee protection cover is included as standard.',
},
{
question: 'Can you do R&D tax credits?',
answerText:
"Yes — if your business conducts qualifying R&D activities, we'll identify and claim the relief on your behalf.",
},
],
},
{
title: 'Payroll',
slug: 'payroll',
icon: 'payroll' as const,
tagline: 'On time, every time',
descText:
'Fully managed payroll for businesses of any size. We handle PAYE, National Insurance, pension auto-enrolment, RTI filings and payslips — so you never have to think about it.',
whatsIncluded: [
'Monthly payroll processing',
'PAYE & National Insurance calculations',
'Auto-enrolment pension management',
'Real Time Information (RTI) submissions',
'Payslips for every employee',
'P60s, P45s and P11Ds',
],
howItWorks: [
{
step: 1,
title: 'Zero errors',
description:
'Manual payroll errors are costly. Our systems double-check every calculation before submission.',
},
{
step: 2,
title: 'Full compliance',
description:
'RTI submissions, auto-enrolment, NMW compliance — all handled on time, every time.',
},
{
step: 3,
title: 'Scales with you',
description:
'Whether you have 1 employee or 100, our payroll service scales effortlessly as your team grows.',
},
],
faq: [
{
question: "What's the deadline for running payroll?",
answerText:
'We ask for any changes (new starters, leavers, salary changes) by the 20th of each month and process by the 25th.',
},
{
question: 'Do you handle auto-enrolment pensions?',
answerText:
'Yes — we set up and manage your workplace pension scheme, handle all enrolment communications and submissions.',
},
{
question: 'What if I need to add a new employee?',
answerText:
'Just email us the details. We add them to the next payroll run and handle all the HMRC notifications.',
},
],
},
{
title: 'VAT Returns',
slug: 'vat-returns',
icon: 'vat' as const,
tagline: 'MTD-compliant filing',
descText:
'Making Tax Digital-compliant VAT returns filed accurately and on time, every quarter. We also advise on the most tax-efficient VAT scheme for your business.',
whatsIncluded: [
'Quarterly VAT return preparation & filing',
'Making Tax Digital (MTD) compliance',
'VAT scheme assessment & advice',
'Input & output VAT reconciliation',
'HMRC VAT correspondence',
'VAT registration & deregistration',
],
howItWorks: [
{
step: 1,
title: 'Never miss a VAT deadline',
description:
'Late VAT returns trigger automatic penalties. We file every return well before the deadline.',
},
{
step: 2,
title: 'Right scheme for your business',
description:
"Flat Rate, Cash Accounting or Standard — we make sure you're on the scheme that minimises your VAT bill.",
},
{
step: 3,
title: 'MTD fully handled',
description:
"HMRC's Making Tax Digital requirements are completely managed by us. No software headaches.",
},
],
faq: [
{
question: 'Do I need to register for VAT?',
answerText:
"You must register once your taxable turnover exceeds £90,000. We'll advise on timing and handle the registration.",
},
{
question: 'What is Making Tax Digital?',
answerText:
'MTD requires businesses to keep digital records and submit VAT returns using approved software. We handle this entirely.',
},
{
question: 'Can you help with a VAT investigation?',
answerText:
'Yes — we represent you fully in any HMRC VAT enquiry and our fee protection covers the cost.',
},
],
},
];
for (const svc of SERVICES) {
const existing = await payload.find({
collection: 'services',
where: { slug: { equals: svc.slug } },
limit: 1,
});
if (existing.docs.length) {
console.log(` ✓ '${svc.title}' exists`);
continue;
}
await payload.create({
collection: 'services',
data: {
title: svc.title,
slug: svc.slug,
icon: svc.icon,
tagline: svc.tagline,
description: lexicalParagraph(svc.descText),
whatsIncluded: svc.whatsIncluded.map((item) => ({ item })),
howItWorks: svc.howItWorks,
faq: svc.faq.map((f) => ({
question: f.question,
answer: lexicalParagraph(f.answerText),
})),
status: 'published',
publishedAt: new Date().toISOString(),
},
});
console.log(` + Created '${svc.title}'`);
}
// ── 3. Testimonials ────────────────────────────────────────────────────────
console.log('\n─ Testimonials');
const TESTIMONIALS = [
{
clientName: 'Sarah T.',
businessName: 'Limited Company Director',
quote:
'Axil saved us over £8,000 in our first year alone. They spotted allowances our previous accountant had missed for three years running.',
rating: '5' as const,
featured: true,
},
{
clientName: 'James K.',
businessName: 'Sole Trader',
quote:
'Finally an accountant who speaks plain English. I actually understand my finances now, and my tax bill has never been lower.',
rating: '5' as const,
featured: true,
},
{
clientName: 'Emma R.',
businessName: 'Startup Founder',
quote:
"Payroll used to take me half a day every month. Now it takes zero minutes. Axil handles it completely and it's always perfect.",
rating: '5' as const,
featured: true,
},
{
clientName: 'Michael B.',
businessName: 'Limited Company Director',
quote:
'The dedicated account manager is worth every penny. She proactively flagged a VAT issue that would have cost us £4,000 in penalties.',
rating: '5' as const,
featured: true,
},
{
clientName: 'David O.',
businessName: 'Sole Trader',
quote:
'Switched from a Big 4 firm to Axil and never looked back. Same quality, half the price, ten times more personal service.',
rating: '5' as const,
featured: true,
},
{
clientName: 'Rachel M.',
businessName: 'E-commerce Brand Owner',
quote:
'MTD compliance, quarterly VAT, company accounts — Axil handles everything and I get a clean dashboard showing exactly how my business is doing.',
rating: '5' as const,
featured: true,
},
{
clientName: 'Tom H.',
businessName: 'Consulting Ltd',
quote:
'I was dreading my first year of corporation tax as a limited company. Axil made it completely painless and saved me significantly on my first filing.',
rating: '5' as const,
featured: true,
},
{
clientName: 'Priya S.',
businessName: 'Retail Business Owner',
quote:
"Three years with Axil and I've recommended them to five other business owners. Genuinely the best decision I made when starting my company.",
rating: '5' as const,
featured: true,
},
];
for (const t of TESTIMONIALS) {
const existing = await payload.find({
collection: 'testimonials',
where: { clientName: { equals: t.clientName } },
limit: 1,
});
if (existing.docs.length) {
console.log(` ✓ '${t.clientName}' exists`);
continue;
}
await payload.create({
collection: 'testimonials',
data: { ...t, publishedAt: new Date().toISOString() },
});
console.log(` + Created '${t.clientName}'`);
}
// ── 4. Blog Posts ──────────────────────────────────────────────────────────
console.log('\n─ Blog Posts');
const POSTS = [
{
title: 'How to Legally Reduce Your Tax Bill in 2026',
slug: 'reduce-tax-bill-2026',
excerpt:
'From pension contributions to trading allowances, these are the most overlooked ways UK business owners cut their tax liability — all HMRC-approved.',
categoryName: 'Tax',
contentText:
'Many UK business owners overpay tax simply because they are unaware of the allowances and reliefs available to them. This guide covers the most commonly missed deductions, from pension contributions and home office expenses to capital allowances and R&D tax credits. All of these strategies are fully HMRC-approved and legally reduce your tax liability.',
publishedAt: '2026-02-14T09:00:00.000Z',
},
{
title: 'Making Tax Digital: What Every Business Must Know',
slug: 'making-tax-digital-2026',
excerpt:
"MTD for income tax is expanding in April 2026. Here's exactly what changes, who's affected, and what you need to do before the deadline.",
categoryName: 'HMRC',
contentText:
'Making Tax Digital (MTD) for Income Tax Self Assessment is expanding from April 2026, requiring sole traders and landlords with income over £50,000 to submit quarterly digital returns. This article explains exactly who is affected, what software you need, and the steps to take before the deadline to ensure compliance.',
publishedAt: '2026-02-07T09:00:00.000Z',
},
{
title: 'Hiring Your First Employee? A Complete Payroll Guide',
slug: 'first-employee-payroll-guide',
excerpt:
'RTI submissions, auto-enrolment, P60s — setting up payroll correctly from day one avoids costly mistakes and HMRC penalties down the line.',
categoryName: 'Payroll',
contentText:
'Taking on your first employee is an exciting milestone, but it comes with significant payroll obligations. This guide walks you through everything you need to set up: PAYE registration with HMRC, Real Time Information (RTI) submissions, auto-enrolment pension duties, and the various year-end forms like P60s and P11Ds. Getting this right from day one avoids costly penalties.',
publishedAt: '2026-02-01T09:00:00.000Z',
},
];
for (const post of POSTS) {
const existing = await payload.find({
collection: 'posts',
where: { slug: { equals: post.slug } },
limit: 1,
});
if (existing.docs.length) {
console.log(` ✓ '${post.title}' exists`);
continue;
}
await payload.create({
collection: 'posts',
data: {
title: post.title,
slug: post.slug,
excerpt: post.excerpt,
category: categoryIds[post.categoryName] ?? undefined,
content: lexicalParagraph(post.contentText),
status: 'published',
publishedAt: post.publishedAt,
readingTime: Math.ceil(post.contentText.split(' ').length / 200) || 1,
},
});
console.log(` + Created '${post.title}'`);
}
// ── 5. Navigation Global ───────────────────────────────────────────────────
console.log('\n─ Navigation global');
await payload.updateGlobal({
slug: 'navigation',
data: {
items: [
{ label: 'Home', href: '/', isDropdown: false },
{
label: 'Services',
href: '/services',
isDropdown: true,
children: [
{
label: 'Bookkeeping',
href: '/services/bookkeeping',
icon: 'bookkeeping',
description: 'Accurate records, zero stress',
},
{
label: 'Tax Returns',
href: '/services/tax-returns',
icon: 'tax',
description: 'Every allowance claimed',
},
{
label: 'Payroll',
href: '/services/payroll',
icon: 'payroll',
description: 'On time, every time',
},
{
label: 'VAT Returns',
href: '/services/vat-returns',
icon: 'vat',
description: 'MTD-compliant filing',
},
],
},
{ label: 'Blog', href: '/blog', isDropdown: false },
{ label: 'About', href: '/about', isDropdown: false },
],
},
});
console.log(' + Navigation updated');
// ── 6. Footer Global ───────────────────────────────────────────────────────
console.log('\n─ Footer global');
await payload.updateGlobal({
slug: 'footer',
data: {
columns: [
{
heading: 'Services',
links: [
{ label: 'Bookkeeping', href: '/services/bookkeeping' },
{ label: 'Tax Returns', href: '/services/tax-returns' },
{ label: 'Payroll', href: '/services/payroll' },
{ label: 'VAT Returns', href: '/services/vat-returns' },
],
},
{
heading: 'Company',
links: [
{ label: 'About Us', href: '/about' },
{ label: 'Blog', href: '/blog' },
{ label: 'Contact', href: '/contact' },
],
},
],
contactInfo: {
address: 'London, United Kingdom',
phone: '+44 (0) 20 0000 0000',
email: 'hello@axilaccountants.co.uk',
},
socialLinks: {
linkedIn: 'https://linkedin.com/company/axil-accountants',
facebook: '',
instagram: '',
},
legalLinks: [
{ label: 'Privacy Policy', href: '/privacy' },
{ label: 'Terms of Service', href: '/terms' },
],
copyrightText: `© ${new Date().getFullYear()} Axil Accountants Ltd. All rights reserved.`,
},
});
console.log(' + Footer updated');
// ── 7. HomePage Global ─────────────────────────────────────────────────────
console.log('\n─ HomePage global');
await payload.updateGlobal({
slug: 'home-page',
data: {
hero: {
eyebrow: 'Trusted by 500+ UK Businesses',
body: 'ICAEW-certified accountants with fixed monthly fees, a dedicated account manager, and zero HMRC surprises.',
ctaPrimary: 'Book a Free Consultation',
ctaSecondary: 'See Our Services',
statsRating: '4.9/5',
statsSource: 'Google Reviews',
trustItems: [
{ item: 'ICAEW Member' },
{ item: 'ACCA Certified' },
{ item: '500+ UK Businesses' },
{ item: 'No lock-in contracts' },
],
trustStrip: [
{ item: '🇬🇧 UK-Based Team' },
{ item: 'ICAEW Member · ACCA Certified' },
{ item: 'Fixed monthly fees — no hidden charges' },
{ item: 'Serving UK businesses since 2012' },
],
},
painPoints: {
overline: 'The problem',
headline: 'Most businesses are losing money to bad accounting.',
statValue: '73%',
statDescription:
'of UK small businesses overpay tax due to unclaimed allowances and poor financial planning.',
statSource: '* HMRC data and independent SME research, 2024',
pains: [
{
title: 'HMRC penalties for missed deadlines',
body: 'Self-assessment, VAT, corporation tax — the dates stack up. One missed deadline can cost hundreds in fines.',
},
{
title: 'Tax rules that change every year',
body: 'Making Tax Digital, dividend tax hikes, NICs changes — staying compliant feels like a full-time job.',
},
{
title: 'Hours lost on bookkeeping',
body: 'Reconciling bank feeds, chasing receipts, producing reports — time you should be spending on your business.',
},
],
},
solution: {
overline: 'The Axil way',
headline: 'We found a better way to do accounting.',
body: "Proactive, transparent, and technology-first. We don't wait for you to ask — we spot savings, flag issues, and keep you compliant before problems arise.",
checklist: [
{ item: 'Onboarded within 48 hours' },
{ item: 'We handle the HMRC transition' },
{ item: 'MTD-compliant from day one' },
{ item: 'Real-time financial dashboard' },
],
features: [
{
title: 'Fixed monthly fee',
body: 'No surprise invoices. You know exactly what you pay on the 1st of every month — nothing more, ever.',
},
{
title: 'Your dedicated account manager',
body: 'A real person who knows your business, answers your calls, and proactively saves you money.',
},
{
title: '100% cloud-based',
body: 'All your accounts in one place, accessible anytime. We connect to your bank and automate the boring parts.',
},
],
},
whyAxil: {
overline: 'Why choose Axil',
headline: 'Numbers that speak for themselves',
stats: [
{ prefix: '', value: 500, suffix: '+', label: 'Businesses Served' },
{ prefix: '', value: 98, suffix: '%', label: 'Client Retention' },
{ prefix: '£', value: 2, suffix: 'M+', label: 'Tax Saved for Clients' },
{ prefix: '', value: 12, suffix: '+', label: 'Years of Experience' },
],
usps: [
{
icon: 'shield-check',
title: 'ICAEW & ACCA Qualified',
body: "Our accountants hold the highest professional qualifications in the UK. You're in expert hands.",
},
{
icon: 'receipt',
title: 'Fixed Monthly Engagement',
body: 'One predictable fee covers everything. No extra charges for emails, calls, or ad-hoc advice.',
},
{
icon: 'person-circle',
title: 'Dedicated Account Manager',
body: 'One person who knows you and your business. No call centres, no being passed around.',
},
{
icon: 'cloud',
title: 'Cloud-Based & Paper-Free',
body: 'We connect to Xero, QuickBooks, and your bank. Everything is digital, accessible, and automated.',
},
],
},
audience: {
overline: 'Built for businesses like yours',
headline: 'Who we work with',
cards: [
{
title: 'Sole Traders',
tagline: 'Self-assessment made simple',
body: 'From freelancers to consultants, we handle your self-assessment, expenses, and tax planning so you keep more of what you earn.',
perks: [
{ perk: 'Self-assessment filing' },
{ perk: 'Expense optimisation' },
{ perk: 'National Insurance planning' },
],
featured: false,
href: '/services',
cta: 'For sole traders',
},
{
title: 'Limited Companies',
tagline: 'Full-service company accounting',
body: 'Corporation tax, payroll, dividends, R&D credits — we manage your entire financial picture and help you extract value tax-efficiently.',
perks: [
{ perk: 'Corporation tax' },
{ perk: 'Dividend planning' },
{ perk: "Directors' payroll" },
],
featured: true,
href: '/services',
cta: 'For limited companies',
},
{
title: 'Startups & Scaleups',
tagline: 'Built for fast-growing businesses',
body: 'SEIS/EIS compliance, R&D tax credits, investor-ready accounts — we understand startup finance and help you grow without financial friction.',
perks: [
{ perk: 'R&D tax credits' },
{ perk: 'SEIS/EIS compliance' },
{ perk: 'Investor accounts' },
],
featured: false,
href: '/services',
cta: 'For startups',
},
],
},
process: {
overline: 'How we do it',
headline: 'From sign-up to sorted in days',
body: "We've made switching accountants effortless. Most clients are fully onboarded within a week — then we handle everything so you never have to think about tax again.",
ctaLabel: 'Get started',
steps: [
{
icon: 'phone',
title: 'Free Consultation',
description:
'Tell us about your business, current finances and goals. No pressure, no commitment — just an honest conversation.',
},
{
icon: 'zap',
title: 'Quick Onboarding',
description:
'We migrate your accounts and set up your Axil dashboard in under a week, with zero disruption to your business.',
},
{
icon: 'file-check',
title: 'We Handle Everything',
description:
'Bookkeeping, tax, payroll, VAT — handled every month with zero input from you, filed on time, every time.',
},
{
icon: 'trending-up',
title: 'You Focus on Growth',
description:
'Monthly reports, proactive tax advice, and a dedicated account manager who knows your business inside out.',
},
],
},
finalCta: {
overline: 'Ready to start?',
headline: 'Take the stress out of your finances — today.',
body: 'Book a free 30-minute consultation with one of our accountants. No commitment, no hard sell — just honest advice for your business.',
ctaPrimary: 'Book a Free Consultation',
ctaSecondary: 'See Our Services',
reassurances: [
{ item: '4.9/5 on Google' },
{ item: 'No lock-in contracts' },
{ item: 'ICAEW & ACCA Certified' },
{ item: 'Free 30-min consultation' },
],
},
},
});
console.log(' + HomePage updated');
console.log('\n✅ Seed complete!\n');
process.exit(0);
}
seed().catch((err) => {
console.error('\n❌ Seed failed:', err);
process.exit(1);
});