From 259df06a6ce803f849601ba2311570ac6872343b Mon Sep 17 00:00:00 2001 From: Mikael Brevik Date: Thu, 12 Dec 2024 21:09:56 +0100 Subject: [PATCH] feat: adds link to employees on employee page --- messages/en.json | 4 +- messages/no.json | 3 +- messages/se.json | 3 +- src/app/(main)/[locale]/[...path]/page.tsx | 4 +- src/components/employeePage/EmployeePage.tsx | 55 ++++++++++++++----- .../employeePage/employeePage.module.css | 37 +++++-------- 6 files changed, 65 insertions(+), 41 deletions(-) diff --git a/messages/en.json b/messages/en.json index dedc34154..e6aff85e7 100644 --- a/messages/en.json +++ b/messages/en.json @@ -46,7 +46,6 @@ "master": "Master" } }, - "employee_card": { "show": "Showing", "of": "out of", @@ -59,7 +58,8 @@ "Prosjekt- og produktledelse": "Project and product management", "Strategi": "Strategy", "field": "Field", - "showMore": "Show all" + "showMore": "Show all", + "see_all_employees": "See all people" }, "job_posting": { "office": "Office", diff --git a/messages/no.json b/messages/no.json index 29d66c73b..6bf2433ec 100644 --- a/messages/no.json +++ b/messages/no.json @@ -58,7 +58,8 @@ "Prosjekt- og produktledelse": "Prosjekt- og produktledelse", "Strategi": "Strategi", "field": "Fag", - "showMore": "Vis alle" + "showMore": "Vis alle", + "see_all_employees": "Se alle folk" }, "job_posting": { "office": "Kontor", diff --git a/messages/se.json b/messages/se.json index bc2305655..0172c8005 100644 --- a/messages/se.json +++ b/messages/se.json @@ -58,7 +58,8 @@ "Ledelse": "Ledelse", "Strategi": "Strategi", "field": "Fält", - "showMore": "Vis alla" + "showMore": "Vis alla", + "see_all_employees": "Se alla folk" }, "job_posting": { "office": "Kontor", diff --git a/src/app/(main)/[locale]/[...path]/page.tsx b/src/app/(main)/[locale]/[...path]/page.tsx index ea5caf95b..af3a02f41 100644 --- a/src/app/(main)/[locale]/[...path]/page.tsx +++ b/src/app/(main)/[locale]/[...path]/page.tsx @@ -138,7 +138,9 @@ async function Page({ params }: Props) { ); case "employee": - return ; + return ( + + ); } return Page404; })()} diff --git a/src/components/employeePage/EmployeePage.tsx b/src/components/employeePage/EmployeePage.tsx index b85793e4a..60a77a347 100644 --- a/src/components/employeePage/EmployeePage.tsx +++ b/src/components/employeePage/EmployeePage.tsx @@ -1,19 +1,26 @@ -import Image from "next/image"; -import { useTranslations } from "next-intl"; - import Text from "src/components/text/Text"; import formatPhoneNumber from "src/components/utils/formatPhoneNumber"; import { ChewbaccaEmployee } from "src/types/employees"; +import { getTranslations } from "next-intl/server"; +import { EMPLOYEE_PAGE_SLUG_QUERY } from "studio/lib/queries/siteSettings"; +import { loadStudioQuery } from "studio/lib/store"; +import { SanityImage } from "../image/SanityImage"; +import LinkButton from "../linkButton/LinkButton"; import styles from "./employeePage.module.css"; export interface EmployeePageProps { employee: ChewbaccaEmployee; + language: string; } -export default function EmployeePage({ employee }: EmployeePageProps) { +export default async function EmployeePage({ + employee, + language, +}: EmployeePageProps) { + const employeePageSlug = await getEmployeePageSlug(language); const image = employee.imageUrl ?? employee.imageThumbUrl ?? null; - const t = useTranslations("employee_card"); + const t = await getTranslations("employee_card"); return ( employee.name && ( @@ -22,11 +29,11 @@ export default function EmployeePage({ employee }: EmployeePageProps) {
{image != null && (
- {employee.name}
)} @@ -34,12 +41,14 @@ export default function EmployeePage({ employee }: EmployeePageProps) { {employee.name} {employee.email && ( - {employee.email} + {employee.email} )} {employee.telephone && ( - {formatPhoneNumber(employee.telephone)} + + {formatPhoneNumber(employee.telephone)} + )} {employee.officeName && ( @@ -49,13 +58,33 @@ export default function EmployeePage({ employee }: EmployeePageProps) { )} {employee.competences.map((competence) => ( - {t(competence)} + {t.has(competence) ? t(competence) : competence} ))}
+ +
+ +
) ); } + +export async function getEmployeePageSlug(language: string) { + const employeePageSlug = + ( + await loadStudioQuery<{ slug: string } | null>(EMPLOYEE_PAGE_SLUG_QUERY, { + language, + }) + ).data?.slug ?? ""; + + return employeePageSlug; +} diff --git a/src/components/employeePage/employeePage.module.css b/src/components/employeePage/employeePage.module.css index 2b52d1bff..869ff659b 100644 --- a/src/components/employeePage/employeePage.module.css +++ b/src/components/employeePage/employeePage.module.css @@ -7,7 +7,7 @@ .content { width: 100%; - max-width: 1200px; + max-width: var(--max-content-width-small); display: flex; flex-direction: column; align-items: center; @@ -15,33 +15,16 @@ } .employee { - display: flex; + display: grid; gap: 3rem; - flex-direction: column; - margin: 1rem; - - @media (min-width: 1024px) { - flex-direction: row; - align-items: center; - } + width: 100%; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } .employeeImage { - display: flex; - flex-direction: column; - align-items: center; background-color: var(--Dark-500); - border-radius: 12px; - width: 300px; - height: 300px; - padding: 1rem; - position: relative; - - @media (max-width: 1024px) { - flex-direction: column; - width: 200px; - height: 200px; - } + border-radius: var(--radius-medium); + overflow: hidden; } .employeeInfo { @@ -66,3 +49,11 @@ color: var(--Dark-500); font-weight: 300; } + +.backToEmployees { + display: flex; + justify-content: center; + width: 100%; + + margin-top: var(--padding-l); +}