/**
 * Content update, 1 October 2026: the last three blocks on the home page that still spoke for one course.
 *
 * «السبع وحدات» counted the units of the programming syllabus as though every course had seven. What is true
 * of every course is its shape — units, lessons, and a lesson in four steps, the next one opening when the one
 * before it is passed — so the heading says that and the unit list below it is named as the example it is.
 *
 * «مين ورا المحتوى» introduced the people. Who writes a course matters less to a parent than how it is checked,
 * and the check is the same in every subject: an academic committee for the content, then a committee of
 * practitioners who read it against the work the student will actually do. The second committee is where the
 * extra lessons come from — the ones that sit inside the unit carrying «درس إضافي» and are not examined — so
 * the block now says that plainly instead of leaving a student to wonder what the badge means.
 *
 * The FAQ answered for one syllabus: four lessons free, one price, one textbook, a Python lab. Each answer is
 * now about the academy, with the course's own page carrying what belongs to that course (its price, its
 * stage). One question is added, because the catalogue now spans stages and nothing on the page said so.
 *
 *   ./tk cms-tools npx tsx src/scripts/2026-10-01-home-generic.ts
 *
 * Safe to re-run. Writes src/scripts/backup-2026-10-01-home-generic.json first.
 */
import fs from 'node:fs'
import path from 'node:path'
import { getPayload } from 'payload'
import config from '@payload-config'

type L = 'ar' | 'en'
const payload = await getPayload({ config })
const get = (slug: string, locale: L) => payload.findGlobal({ slug: slug as never, locale, depth: 0 }) as Promise<any>
const set = (slug: string, locale: L, data: any) =>
  payload.updateGlobal({ slug: slug as never, locale, data, depth: 0 }) as Promise<any>

const backup: Record<string, unknown> = {}
for (const locale of ['ar', 'en'] as L[]) backup[`home.${locale}`] = await get('home', locale)
const file = path.join(process.cwd(), 'src/scripts/backup-2026-10-01-home-generic.json')
fs.writeFileSync(file, JSON.stringify(backup, null, 2), 'utf8')
console.log(`backup → ${file}`)

const AR = {
  unitsTitle: 'شكل أي منهج عندنا',
  unitsLead:
    'كل منهج متقسّم وحدات، وكل وحدة دروس، والدرس الواحد بيمشي على أربع خطوات: الشرح، وملفات الدرس، ' +
    'والتقييمات، والتدريب. والدرس اللي بعده بيتفتح لما تثبت إنك فهمت اللي قبله. تحت وحدات واحد من المناهج ' +
    'كمثال على الشكل ده.',

  peopleTitle: 'إزاي بيتبني المحتوى',
  people: [
    {
      name: 'أولاً: تأليف وتدقيق أكاديمي',
      text:
        'المحتوى بيتكتب من المقرر الرسمي ونواتج تعلّمه، وبعدين بتراجعه لجنة أكاديمية متخصصة في المادة: ' +
        'دقّة المعلومة، وتغطية المقرر درس بدرس، وترتيب البناء من الأسهل للأصعب. اللي ما يعديش المراجعة ' +
        'ما ينزلش للطالب.',
    },
    {
      name: 'ثانياً: ربط بسوق العمل',
      text:
        'بعدها لجنة استشاريين ومتخصصين في المجال بتقرا المنهج بعين الشغل: إيه اللي السوق بيطلبه وناقص، ' +
        'وإيه اللي محتاج تحسين. اقتراحاتهم بتبقى دروس إضافية جوّه الوحدة نفسها وعليها علامة ' +
        '«درس إضافي» — الطالب مش بيتختبر فيها، فهي زيادة في الفهم مش زيادة في المذاكرة.',
    },
  ],

  faqTitle: 'أسئلة متكرّرة',
  faq: [
    {
      q: 'أول وحدة مجانية بجد؟',
      text:
        'أيوه، وفي كل منهج. الوحدة الأولى كاملة بدروسها: الفيديو، وملفات الدرس، والتقييمات، والتدريب، ' +
        'من غير أي دفع ومن غير بيانات دفع.',
    },
    {
      q: 'المناهج دي لأنهي مراحل؟',
      text:
        'من الإعدادي لتالتة ثانوي، وبنضيف مواد جديدة أول بأول. كل منهج مكتوب على بطاقته مرحلته، ' +
        'وتقدر تفلتر الكتالوج بالمرحلة اللي تخصّك.',
    },
    {
      q: 'ليه بتطلبوا رقم وليّ الأمر؟',
      text: 'عشان نتواصل معاه بخصوص دراسة الطالب واشتراكه بس، ومابنشاركش الرقم مع أي جهة.',
    },
    {
      q: 'الدروس الإضافية هتلخبطني في الامتحان؟',
      text:
        'لأ. اللي من المقرر الرسمي مالوش علامة، والزيادة اللي اقترحها متخصصو المجال عليها علامة ' +
        '«درس إضافي» وإنها مش داخلة الامتحان. ذاكر اللي من غير علامة، وارجع للباقي وقت ما تحب.',
    },
    {
      q: 'المنهج يكفيني للامتحان؟',
      text:
        'كل منهج ماشي مع مقرّره الرسمي ونواتج تعلّمه درس بدرس، وأسئلته بنمط الامتحان ومعاها إجابات ' +
        'نموذجية. والكتاب المدرسي يفضل هو المرجع.',
    },
    {
      q: 'الشرح بأي لغة؟',
      text:
        'الصوت بالعامية المصرية، والمصطلحات بالإنجليزي زي ما المقرر كاتبها. ومناهج اللغات شرحها بلغتها، ' +
        'وفي النسخ العربية الشاشات عربية والمصطلح الإنجليزي بين قوسين.',
    },
    {
      q: 'محتاج كمبيوتر قوي؟',
      text: 'لأ. كل حاجة شغّالة على الموبايل، والمناهج اللي فيها معمل برمجة بيشتغل في المتصفح من غير تثبيت.',
    },
    {
      q: 'ينفع للمعلم؟',
      text:
        'أيوه. كل درس معاه ملفاته وبنك أسئلة وإجابات نموذجية، وتقدر تعرض الفيديو في الحصة، ' +
        'وتتابع درجات طلبتك من المنصة.',
    },
    {
      q: 'أدفع إزاي؟',
      text:
        'من المنصة بإنستاباي: تحوّل قيمة المنهج، وترفع صورة الإيصال، وإحنا بنفتحه لك بعد المراجعة. ' +
        'سعر كل منهج مكتوب في صفحته، والوحدة الأولى مفتوحة قبل أي دفع.',
    },
  ],
}

const EN = {
  unitsTitle: 'How a course is built',
  unitsLead:
    'Every course is split into units, every unit into lessons, and a lesson runs in four steps: the ' +
    'explanation, the lesson files, the assessments and the practice. The next lesson opens once you show you ' +
    'have understood the one before it. Below are the units of one of the courses, as an example of that shape.',

  peopleTitle: 'How the content is built',
  people: [
    {
      name: 'Stage 1: written and checked academically',
      text:
        'The content is written from the official syllabus and its learning outcomes, then reviewed by an ' +
        'academic committee for that subject: the accuracy of each fact, the coverage of the syllabus lesson ' +
        'by lesson, and the order it builds in. What does not pass the review does not reach a student.',
    },
    {
      name: 'Stage 2: tied to the work students will do',
      text:
        'A committee of practising specialists then reads the course against real work: what the field asks ' +
        'for and the course does not yet give, and what needs sharpening. What they propose becomes extra ' +
        'lessons inside the unit itself, marked «extra lesson» — a student is not examined on them, so they ' +
        'add understanding rather than revision.',
    },
  ],

  faqTitle: 'Questions',
  faq: [
    {
      q: 'Is the first unit really free?',
      text:
        'Yes, in every course. The whole first unit with all its lessons: the video, the lesson files, the ' +
        'assessments and the practice, with no payment and no payment details.',
    },
    {
      q: 'Which school stages are these courses for?',
      text:
        'From preparatory school to the third secondary year, and we add new subjects as they are built. Each ' +
        'course states its stage on its card, and you can filter the catalogue by the stage you need.',
    },
    {
      q: "Why do you ask for a parent's number?",
      text:
        "To contact the parent about the student's studies and subscription only. We do not share the number " +
        'with anyone.',
    },
    {
      q: 'Will the extra lessons confuse me in the exam?',
      text:
        'No. What comes from the official syllabus carries no badge; what the specialists added is marked ' +
        '«extra lesson» and stated not to be in the exam. Study what has no badge, and come back to the rest ' +
        'whenever you like.',
    },
    {
      q: 'Is the course enough for the exam?',
      text:
        'Each course follows its official syllabus and its learning outcomes lesson by lesson, and its ' +
        'questions follow the exam style, with model answers. The textbook remains the reference.',
    },
    {
      q: 'What language is it in?',
      text:
        'The voice is Egyptian Arabic and the terms stay in English as the syllabus writes them. Language ' +
        'courses are taught in their own language; in the Arabic editions the screens are Arabic with the ' +
        'English term in brackets.',
    },
    {
      q: 'Do I need a powerful computer?',
      text:
        'No. Everything runs on a phone, and where a course has a programming lab it runs in the browser with ' +
        'nothing to install.',
    },
    {
      q: 'Is it useful for teachers?',
      text:
        'Yes. Every lesson comes with its files, a question bank and model answers, the video can be shown in ' +
        'class, and you can follow your students’ marks from the platform.',
    },
    {
      q: 'How do I pay?',
      text:
        'On the platform with InstaPay: transfer the price of the course, upload the receipt, and we open it ' +
        'for you after the review. Each course states its own price on its page, and the first unit is open ' +
        'before any payment.',
    },
  ],
}

await set('home', 'ar', AR)
await set('home', 'en', EN)
console.log('home: units, the authoring process and the FAQ now speak for the academy, not for one course')
