Guest User

Untitled

a guest
Sep 5th, 2024
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TypeScript 2.19 KB | Source Code | 0 0
  1. import { getAllContacts } from '@/actions/contact.action'
  2. import { ContactProps } from '@/types'
  3. import {
  4.   Card,
  5.   CardContent,
  6.   CardDescription,
  7.   CardHeader,
  8.   CardTitle,
  9. } from './ui/card'
  10. import { Locale } from '@/i18n.config'
  11. import Link from 'next/link'
  12. import Image from 'next/image'
  13.  
  14. export default async function Contacts({ lang }: { lang: Locale }) {
  15.   const fetchedContacts = await getAllContacts(lang)
  16.  
  17.   const visibleContacts = fetchedContacts
  18.     .filter((contact) => contact.isVisible)
  19.     .sort((a, b) => b.priority - a.priority)
  20.  
  21.   return (
  22.     <>
  23.       <h2 className="mb-4 text-3xl font-extrabold sm:text-4xl">Kontakty</h2>
  24.  
  25.       {visibleContacts.length === 0 && (
  26.         <p className="text-xl font-semibold">Žádné kontakty</p>
  27.       )}
  28.  
  29.       <div className="grid grid-cols-2 gap-4 sm:grid-cols-4 xl:grid-cols-6">
  30.         {visibleContacts.map((contact, i) => (
  31.           <Contact key={i} {...contact} />
  32.         ))}
  33.       </div>
  34.     </>
  35.   )
  36. }
  37.  
  38. function Contact({
  39.   position,
  40.   description,
  41.   email,
  42.   phone,
  43.   isDrylock,
  44. }: ContactProps) {
  45.   return (
  46.     <Card className="relative col-span-2 sm:last:col-start-2 xl:last:col-start-auto">
  47.       {isDrylock && (
  48.         <div>
  49.           <Image
  50.             width={175}
  51.             height={40}
  52.             src={'/drylock.png'}
  53.             alt="drylock"
  54.             className="absolute right-[20px] top-[-12.5px] h-[25px] w-auto rounded-sm border bg-background px-1 py-0.5"
  55.           />
  56.         </div>
  57.       )}
  58.       <CardHeader className="pb-3">
  59.         <CardTitle>{position}</CardTitle>
  60.         <CardDescription>{description}</CardDescription>
  61.       </CardHeader>
  62.       <CardContent>
  63.         <p>
  64.           E-mail:{' '}
  65.           <Link
  66.             href={`mailto:${email}`}
  67.             className="md:transition-colors md:duration-100 md:hover:text-primary"
  68.           >
  69.             {email}
  70.           </Link>
  71.         </p>
  72.         <p>
  73.           Telefon:{' '}
  74.           <Link
  75.             href={`tel:${phone}`}
  76.             className="md:transition-colors md:duration-100 md:hover:text-primary"
  77.           >
  78.             {phone}
  79.           </Link>
  80.         </p>
  81.       </CardContent>
  82.     </Card>
  83.   )
  84. }
Advertisement
Add Comment
Please, Sign In to add comment