/**
 * Set the footer's social row to the accounts the academy actually has.
 *
 *     ./tk cms-tools npx payload run src/seed/social.ts
 *
 * The row is replaced wholesale rather than appended to, so running it twice leaves one clean set
 * and no duplicates. Only accounts that exist are listed: a network with no row simply has no icon,
 * which is the honest state — a guessed handle is either a dead link or somebody else's page, in
 * the footer of every page on the site.
 *
 * WhatsApp is deliberately NOT in this row. It already sits in the footer's «تواصل معانا» column
 * with the number written out, built from `contact.whatsapp` and `contact.waText`, and the same
 * channel twice in one footer reads as an oversight. It is a way to reach us, not a feed to follow.
 *
 * The list is not localized: one address serves both editions.
 */
import { getPayload } from 'payload'
import config from '@payload-config'

const SOCIAL = [
  { network: 'youtube', url: 'https://www.youtube.com/@Thinkera.Academy' },
  { network: 'facebook', url: 'https://www.facebook.com/profile.php?id=61594667785112' },
  { network: 'tiktok', url: 'https://www.tiktok.com/@thinkera.academy' },
  { network: 'telegram', url: 'https://t.me/+zAqR9z7EaqE2MzNk' },
  // The public company page. The «?viewAsMember=true» the owner copied is a preview flag from
  // LinkedIn's own admin view and means nothing to a visitor, so it is not carried into the link.
  { network: 'linkedin', url: 'https://www.linkedin.com/company/thinkera-academy/' },
]

const payload = await getPayload({ config })
const before = (await payload.findGlobal({ slug: 'settings', depth: 0 })) as unknown as {
  social?: { network?: string }[]
}
await payload.updateGlobal({ slug: 'settings', data: { social: SOCIAL } as never })
payload.logger.info(
  `social: ${(before.social || []).length} row(s) -> ${SOCIAL.map((s) => s.network).join(', ')}`,
)
