import { env } from "@/env/server"

import { isEmployeeLinked } from "@/utils/user"

import DigitalTeamMemberCardClient from "./Client"

import type { User } from "@scandic-hotels/trpc/types/user"

interface DigitalTeamMemberCardProps {
  user: User
  children: React.ReactElement
}

export default async function DigitalTeamMemberCard({
  user,
  children,
}: DigitalTeamMemberCardProps) {
  if (!env.ENABLE_DTMC) {
    return null
  }

  const hasEmploymentData = isEmployeeLinked(user)
  if (!hasEmploymentData) {
    return null
  }
  return (
    <DigitalTeamMemberCardClient user={user}>
      {children}
    </DigitalTeamMemberCardClient>
  )
}
