Feat/i18n crowdin (#752)
* feat: add crowdin and supported languages * fix: main branch name * feat: test crowdin integration * feat: add crowdin config skeleton * feat: update crowdin.yml * fix: remove ro translation * test: en translation * test: en translation * New Crowdin translations by Github Action (#735) Co-authored-by: Crowdin Bot <[email protected]> * test: en translation * fix: separate upload/download workflows * wip * New Crowdin translations by Github Action (#738) Co-authored-by: Crowdin Bot <[email protected]> * wip * wip * wip * wip * wip * typo * wip * wip * update crowdin config * update * chore: support i18n de,es,fr,it,pt,ru,ro,en * chore: extract i18n strings * chore: extract booking components strings for i18n * wip * extract more strings * wip * fallback to getServerSideProps for now * New Crowdin translations by Github Action (#874) Co-authored-by: Crowdin Bot <[email protected]> * fix: minor fixes on the datepicker * fix: add dutch lang * fix: linting issues * fix: string * fix: update GHA * cleanup trpc * fix linting Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Crowdin Bot <[email protected]> Co-authored-by: Bailey Pumfleet <[email protected]>
This commit is contained in:
46 files changed
+2805
-1876
No files matched your search
+74
-45
@@ -1,29 +1,23 @@
|
||||
import { ArrowRightIcon } from "@heroicons/react/outline";
|
||||
import { GetStaticPaths, GetStaticPropsContext } from "next";
|
||||
import { GetServerSidePropsContext } from "next";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import Link from "next/link";
|
||||
import React from "react";
|
||||
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import { useLocale } from "@lib/hooks/useLocale";
|
||||
import useTheme from "@lib/hooks/useTheme";
|
||||
import prisma from "@lib/prisma";
|
||||
import { trpc } from "@lib/trpc";
|
||||
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
import EventTypeDescription from "@components/eventtype/EventTypeDescription";
|
||||
import { HeadSeo } from "@components/seo/head-seo";
|
||||
import Avatar from "@components/ui/Avatar";
|
||||
|
||||
import { ssg } from "@server/ssg";
|
||||
|
||||
export default function User(props: inferSSRProps<typeof getStaticProps>) {
|
||||
const { username } = props;
|
||||
// data of query below will be will be prepopulated b/c of `getStaticProps`
|
||||
const query = trpc.useQuery(["booking.userEventTypes", { username }]);
|
||||
const { isReady } = useTheme(query.data?.user.theme);
|
||||
if (!query.data) {
|
||||
// this shold never happen as we do `blocking: true`
|
||||
return <>...</>;
|
||||
}
|
||||
const { user, eventTypes } = query.data;
|
||||
export default function User(props: inferSSRProps<typeof getServerSideProps>) {
|
||||
const { isReady } = useTheme(props.user.theme);
|
||||
const { user, localeProp, eventTypes } = props;
|
||||
const { t, locale } = useLocale({ localeProp });
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -56,7 +50,7 @@ export default function User(props: inferSSRProps<typeof getStaticProps>) {
|
||||
<Link href={`/${user.username}/${type.slug}`}>
|
||||
<a className="block px-6 py-4">
|
||||
<h2 className="font-semibold text-neutral-900 dark:text-white">{type.title}</h2>
|
||||
<EventTypeDescription eventType={type} />
|
||||
<EventTypeDescription localeProp={locale} eventType={type} />
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
@@ -65,8 +59,10 @@ export default function User(props: inferSSRProps<typeof getStaticProps>) {
|
||||
{eventTypes.length === 0 && (
|
||||
<div className="shadow overflow-hidden rounded-sm">
|
||||
<div className="p-8 text-center text-gray-400 dark:text-white">
|
||||
<h2 className="font-cal font-semibold text-3xl text-gray-600 dark:text-white">Uh oh!</h2>
|
||||
<p className="max-w-md mx-auto">This user hasn't set up any event types yet.</p>
|
||||
<h2 className="font-cal font-semibold text-3xl text-gray-600 dark:text-white">
|
||||
{t("uh_oh")}
|
||||
</h2>
|
||||
<p className="max-w-md mx-auto">{t("no_event_types_have_been_setup")}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
@@ -77,43 +73,76 @@ export default function User(props: inferSSRProps<typeof getStaticProps>) {
|
||||
);
|
||||
}
|
||||
|
||||
export const getStaticPaths: GetStaticPaths = async () => {
|
||||
const allUsers = await prisma.user.findMany({
|
||||
select: {
|
||||
username: true,
|
||||
},
|
||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||
const username = (context.query.user as string).toLowerCase();
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
// will statically render everyone on the PRO plan
|
||||
// the rest will be statically rendered on first visit
|
||||
plan: "PRO",
|
||||
username: username.toLowerCase(),
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
email: true,
|
||||
name: true,
|
||||
bio: true,
|
||||
avatar: true,
|
||||
theme: true,
|
||||
plan: true,
|
||||
},
|
||||
});
|
||||
const usernames = allUsers.flatMap((u) => (u.username ? [u.username] : []));
|
||||
return {
|
||||
paths: usernames.map((user) => ({
|
||||
params: { user },
|
||||
})),
|
||||
|
||||
// https://nextjs.org/docs/basic-features/data-fetching#fallback-blocking
|
||||
fallback: "blocking",
|
||||
};
|
||||
};
|
||||
|
||||
export async function getStaticProps(context: GetStaticPropsContext<{ user: string }>) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const username = context.params!.user;
|
||||
const data = await ssg.fetchQuery("booking.userEventTypes", { username });
|
||||
|
||||
if (!data) {
|
||||
if (!user) {
|
||||
return {
|
||||
notFound: true,
|
||||
};
|
||||
}
|
||||
|
||||
const eventTypesWithHidden = await prisma.eventType.findMany({
|
||||
where: {
|
||||
AND: [
|
||||
{
|
||||
teamId: null,
|
||||
},
|
||||
{
|
||||
OR: [
|
||||
{
|
||||
userId: user.id,
|
||||
},
|
||||
{
|
||||
users: {
|
||||
some: {
|
||||
id: user.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
slug: true,
|
||||
title: true,
|
||||
length: true,
|
||||
description: true,
|
||||
hidden: true,
|
||||
schedulingType: true,
|
||||
price: true,
|
||||
currency: true,
|
||||
},
|
||||
take: user.plan === "FREE" ? 1 : undefined,
|
||||
});
|
||||
|
||||
const eventTypes = eventTypesWithHidden.filter((evt) => !evt.hidden);
|
||||
|
||||
return {
|
||||
props: {
|
||||
trpcState: ssg.dehydrate(),
|
||||
username,
|
||||
localeProp: locale,
|
||||
user,
|
||||
eventTypes,
|
||||
...(await serverSideTranslations(locale, ["common"])),
|
||||
},
|
||||
revalidate: 1,
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -3,7 +3,7 @@ import { GetServerSidePropsContext } from "next";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
|
||||
import { asStringOrNull } from "@lib/asStringOrNull";
|
||||
import { extractLocaleInfo } from "@lib/core/i18n/i18n.utils";
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import prisma from "@lib/prisma";
|
||||
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
@@ -16,7 +16,9 @@ export default function Type(props: AvailabilityPageProps) {
|
||||
}
|
||||
|
||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||
const locale = await extractLocaleInfo(context.req);
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
// get query params and typecast them to string
|
||||
// (would be even better to assert them instead of typecasting)
|
||||
const userParam = asStringOrNull(context.query.user);
|
||||
const typeParam = asStringOrNull(context.query.type);
|
||||
const dateParam = asStringOrNull(context.query.date);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { GetServerSidePropsContext } from "next";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
|
||||
import { asStringOrThrow } from "@lib/asStringOrNull";
|
||||
import { extractLocaleInfo } from "@lib/core/i18n/i18n.utils";
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import prisma from "@lib/prisma";
|
||||
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function Book(props: BookPageProps) {
|
||||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
const locale = await extractLocaleInfo(context.req);
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
|
||||
@@ -37,7 +37,8 @@ import {
|
||||
import { getSession } from "@lib/auth";
|
||||
import classNames from "@lib/classNames";
|
||||
import { HttpError } from "@lib/core/http/error";
|
||||
import { extractLocaleInfo } from "@lib/core/i18n/i18n.utils";
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import { useLocale } from "@lib/hooks/useLocale";
|
||||
import getIntegrations, { hasIntegration } from "@lib/integrations/getIntegrations";
|
||||
import { LocationType } from "@lib/location";
|
||||
import deleteEventType from "@lib/mutations/event-types/delete-event-type";
|
||||
@@ -84,6 +85,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
|
||||
const { eventType, locationOptions, availability, team, teamMembers, hasPaymentIntegration, currency } =
|
||||
props;
|
||||
|
||||
const { locale } = useLocale({ localeProp: props.localeProp });
|
||||
const router = useRouter();
|
||||
const [successModalOpen, setSuccessModalOpen] = useState(false);
|
||||
|
||||
@@ -983,6 +985,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
|
||||
Delete
|
||||
</DialogTrigger>
|
||||
<ConfirmationDialogContent
|
||||
localeProp={locale}
|
||||
variety="danger"
|
||||
title="Delete Event Type"
|
||||
confirmBtnText="Yes, delete event type"
|
||||
@@ -1097,7 +1100,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
|
||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||
const { req, query } = context;
|
||||
const session = await getSession({ req });
|
||||
const locale = await extractLocaleInfo(context.req);
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
|
||||
const typeParam = parseInt(asStringOrThrow(query.type));
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import { asStringOrNull } from "@lib/asStringOrNull";
|
||||
import { getSession } from "@lib/auth";
|
||||
import classNames from "@lib/classNames";
|
||||
import { HttpError } from "@lib/core/http/error";
|
||||
import { extractLocaleInfo } from "@lib/core/i18n/i18n.utils";
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import { ONBOARDING_INTRODUCED_AT } from "@lib/getting-started";
|
||||
import { useLocale } from "@lib/hooks/useLocale";
|
||||
import { useToggleQuery } from "@lib/hooks/useToggleQuery";
|
||||
@@ -56,10 +56,7 @@ type Profile = PageProps["profiles"][number];
|
||||
type MembershipCount = EventType["metadata"]["membershipCount"];
|
||||
|
||||
const EventTypesPage = (props: PageProps) => {
|
||||
const { locale } = useLocale({
|
||||
localeProp: props.localeProp,
|
||||
namespaces: "event-types-page",
|
||||
});
|
||||
const { locale } = useLocale({ localeProp: props.localeProp });
|
||||
|
||||
const CreateFirstEventTypeView = () => (
|
||||
<div className="md:py-20">
|
||||
@@ -164,7 +161,7 @@ const EventTypesPage = (props: PageProps) => {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<EventTypeDescription eventType={type} />
|
||||
<EventTypeDescription localeProp={locale} eventType={type} />
|
||||
</a>
|
||||
</Link>
|
||||
|
||||
@@ -379,13 +376,13 @@ const CreateNewEventDialog = ({
|
||||
disabled: true,
|
||||
})}
|
||||
StartIcon={PlusIcon}>
|
||||
{t("new-event-type-btn")}
|
||||
{t("new_event_type_btn")}
|
||||
</Button>
|
||||
)}
|
||||
{profiles.filter((profile) => profile.teamId).length > 0 && (
|
||||
<Dropdown>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button EndIcon={ChevronDownIcon}>{t("new-event-type-btn")}</Button>
|
||||
<Button EndIcon={ChevronDownIcon}>{t("new_event_type_btn")}</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuLabel>Create an event type under your name or a team.</DropdownMenuLabel>
|
||||
@@ -563,7 +560,7 @@ const CreateNewEventDialog = ({
|
||||
|
||||
export async function getServerSideProps(context) {
|
||||
const session = await getSession(context);
|
||||
const locale = await extractLocaleInfo(context.req);
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
|
||||
if (!session?.user?.id) {
|
||||
return { redirect: { permanent: false, destination: "/auth/login" } };
|
||||
|
||||
@@ -7,7 +7,12 @@ import TimezoneSelect from "react-timezone-select";
|
||||
|
||||
import { asStringOrNull, asStringOrUndefined } from "@lib/asStringOrNull";
|
||||
import { getSession } from "@lib/auth";
|
||||
import { extractLocaleInfo, localeLabels, localeOptions, OptionType } from "@lib/core/i18n/i18n.utils";
|
||||
import {
|
||||
getOrSetUserLocaleFromHeaders,
|
||||
localeLabels,
|
||||
localeOptions,
|
||||
OptionType,
|
||||
} from "@lib/core/i18n/i18n.utils";
|
||||
import { useLocale } from "@lib/hooks/useLocale";
|
||||
import { isBrandingHidden } from "@lib/isBrandingHidden";
|
||||
import prisma from "@lib/prisma";
|
||||
@@ -416,7 +421,7 @@ export default function Settings(props: Props) {
|
||||
|
||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||
const session = await getSession(context);
|
||||
const locale = await extractLocaleInfo(context.req);
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
|
||||
if (!session?.user?.id) {
|
||||
return { redirect: { permanent: false, destination: "/auth/login" } };
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import React from "react";
|
||||
|
||||
import { getSession } from "@lib/auth";
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import { useLocale } from "@lib/hooks/useLocale";
|
||||
import prisma from "@lib/prisma";
|
||||
|
||||
import SettingsShell from "@components/SettingsShell";
|
||||
@@ -8,12 +11,14 @@ import Shell from "@components/Shell";
|
||||
import ChangePasswordSection from "@components/security/ChangePasswordSection";
|
||||
import TwoFactorAuthSection from "@components/security/TwoFactorAuthSection";
|
||||
|
||||
export default function Security({ user }) {
|
||||
export default function Security({ user, localeProp }) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { locale, t } = useLocale({ localeProp });
|
||||
return (
|
||||
<Shell heading="Security" subtitle="Manage your account's security.">
|
||||
<Shell heading={t("security")} subtitle={t("manage_account_security")}>
|
||||
<SettingsShell>
|
||||
<ChangePasswordSection />
|
||||
<TwoFactorAuthSection twoFactorEnabled={user.twoFactorEnabled} />
|
||||
<ChangePasswordSection localeProp={locale} />
|
||||
<TwoFactorAuthSection localeProp={locale} twoFactorEnabled={user.twoFactorEnabled} />
|
||||
</SettingsShell>
|
||||
</Shell>
|
||||
);
|
||||
@@ -21,6 +26,8 @@ export default function Security({ user }) {
|
||||
|
||||
export async function getServerSideProps(context) {
|
||||
const session = await getSession(context);
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
|
||||
if (!session?.user?.id) {
|
||||
return { redirect: { permanent: false, destination: "/auth/login" } };
|
||||
}
|
||||
@@ -38,6 +45,11 @@ export async function getServerSideProps(context) {
|
||||
});
|
||||
|
||||
return {
|
||||
props: { session, user },
|
||||
props: {
|
||||
localeProp: locale,
|
||||
session,
|
||||
user,
|
||||
...(await serverSideTranslations(locale, ["common"])),
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -3,9 +3,12 @@ import { PlusIcon } from "@heroicons/react/solid";
|
||||
import { GetServerSideProps } from "next";
|
||||
import type { Session } from "next-auth";
|
||||
import { useSession } from "next-auth/client";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { getSession } from "@lib/auth";
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import { useLocale } from "@lib/hooks/useLocale";
|
||||
import { Member } from "@lib/member";
|
||||
import { Team } from "@lib/team";
|
||||
|
||||
@@ -17,7 +20,7 @@ import TeamList from "@components/team/TeamList";
|
||||
import TeamListItem from "@components/team/TeamListItem";
|
||||
import Button from "@components/ui/Button";
|
||||
|
||||
export default function Teams() {
|
||||
export default function Teams(props: { localeProp: string }) {
|
||||
const noop = () => undefined;
|
||||
const [, loading] = useSession();
|
||||
const [teams, setTeams] = useState([]);
|
||||
@@ -26,6 +29,7 @@ export default function Teams() {
|
||||
const [editTeamEnabled, setEditTeamEnabled] = useState(false);
|
||||
const [teamToEdit, setTeamToEdit] = useState<Team | null>();
|
||||
const nameRef = useRef<HTMLInputElement>() as React.MutableRefObject<HTMLInputElement>;
|
||||
const { locale } = useLocale({ localeProp: props.localeProp });
|
||||
|
||||
const handleErrors = async (resp: Response) => {
|
||||
if (!resp.ok) {
|
||||
@@ -110,7 +114,11 @@ export default function Teams() {
|
||||
</div>
|
||||
<div>
|
||||
{!!teams.length && (
|
||||
<TeamList teams={teams} onChange={loadData} onEditTeam={editTeam}></TeamList>
|
||||
<TeamList
|
||||
localeProp={locale}
|
||||
teams={teams}
|
||||
onChange={loadData}
|
||||
onEditTeam={editTeam}></TeamList>
|
||||
)}
|
||||
|
||||
{!!invites.length && (
|
||||
@@ -119,6 +127,7 @@ export default function Teams() {
|
||||
<ul className="px-4 mt-4 mb-2 bg-white border divide-y divide-gray-200 rounded">
|
||||
{invites.map((team: Team) => (
|
||||
<TeamListItem
|
||||
localeProp={locale}
|
||||
onChange={loadData}
|
||||
key={team.id}
|
||||
team={team}
|
||||
@@ -131,7 +140,7 @@ export default function Teams() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{!!editTeamEnabled && <EditTeam team={teamToEdit} onCloseEdit={onCloseEdit} />}
|
||||
{!!editTeamEnabled && <EditTeam localeProp={locale} team={teamToEdit} onCloseEdit={onCloseEdit} />}
|
||||
{showCreateTeamModal && (
|
||||
<div
|
||||
className="fixed inset-0 z-50 overflow-y-auto"
|
||||
@@ -200,11 +209,16 @@ export default function Teams() {
|
||||
// Export the `session` prop to use sessions with Server Side Rendering
|
||||
export const getServerSideProps: GetServerSideProps<{ session: Session | null }> = async (context) => {
|
||||
const session = await getSession(context);
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
if (!session) {
|
||||
return { redirect: { permanent: false, destination: "/auth/login" } };
|
||||
}
|
||||
|
||||
return {
|
||||
props: { session },
|
||||
props: {
|
||||
session,
|
||||
localeProp: locale,
|
||||
...(await serverSideTranslations(locale, ["common"])),
|
||||
},
|
||||
};
|
||||
};
|
||||
+12
-5
@@ -1,9 +1,12 @@
|
||||
import { ArrowRightIcon } from "@heroicons/react/solid";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { GetServerSidePropsContext } from "next";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import Link from "next/link";
|
||||
import React from "react";
|
||||
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import { useLocale } from "@lib/hooks/useLocale";
|
||||
import useTheme from "@lib/hooks/useTheme";
|
||||
import { useToggleQuery } from "@lib/hooks/useToggleQuery";
|
||||
import prisma from "@lib/prisma";
|
||||
@@ -18,9 +21,10 @@ import AvatarGroup from "@components/ui/AvatarGroup";
|
||||
import Button from "@components/ui/Button";
|
||||
import Text from "@components/ui/Text";
|
||||
|
||||
function TeamPage({ team }: inferSSRProps<typeof getServerSideProps>) {
|
||||
function TeamPage({ team, localeProp }: inferSSRProps<typeof getServerSideProps>) {
|
||||
const { isReady } = useTheme();
|
||||
const showMembers = useToggleQuery("members");
|
||||
const { t, locale } = useLocale({ localeProp: localeProp });
|
||||
|
||||
const eventTypes = (
|
||||
<ul className="space-y-3">
|
||||
@@ -33,7 +37,7 @@ function TeamPage({ team }: inferSSRProps<typeof getServerSideProps>) {
|
||||
<a className="px-6 py-4 flex justify-between">
|
||||
<div className="flex-shrink">
|
||||
<h2 className="font-cal font-semibold text-neutral-900 dark:text-white">{type.title}</h2>
|
||||
<EventTypeDescription className="text-sm" eventType={type} />
|
||||
<EventTypeDescription localeProp={locale} className="text-sm" eventType={type} />
|
||||
</div>
|
||||
<div className="mt-1">
|
||||
<AvatarGroup
|
||||
@@ -64,7 +68,7 @@ function TeamPage({ team }: inferSSRProps<typeof getServerSideProps>) {
|
||||
<Avatar alt={teamName} imageSrc={team.logo} className="mx-auto w-20 h-20 rounded-full mb-4" />
|
||||
<Text variant="headline">{teamName}</Text>
|
||||
</div>
|
||||
{(showMembers.isOn || !team.eventTypes.length) && <Team team={team} />}
|
||||
{(showMembers.isOn || !team.eventTypes.length) && <Team localeProp={locale} team={team} />}
|
||||
{!showMembers.isOn && team.eventTypes.length > 0 && (
|
||||
<div className="mx-auto max-w-3xl">
|
||||
{eventTypes}
|
||||
@@ -75,7 +79,7 @@ function TeamPage({ team }: inferSSRProps<typeof getServerSideProps>) {
|
||||
</div>
|
||||
<div className="relative flex justify-center">
|
||||
<span className="px-2 bg-gray-100 text-sm text-gray-500 dark:bg-black dark:text-gray-500">
|
||||
OR
|
||||
{t("or")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -86,7 +90,7 @@ function TeamPage({ team }: inferSSRProps<typeof getServerSideProps>) {
|
||||
EndIcon={ArrowRightIcon}
|
||||
href={`/team/${team.slug}?members=1`}
|
||||
shallow={true}>
|
||||
Book a team member instead
|
||||
{t("book_a_team_member")}
|
||||
</Button>
|
||||
</aside>
|
||||
</div>
|
||||
@@ -98,6 +102,7 @@ function TeamPage({ team }: inferSSRProps<typeof getServerSideProps>) {
|
||||
}
|
||||
|
||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
const slug = Array.isArray(context.query?.slug) ? context.query.slug.pop() : context.query.slug;
|
||||
|
||||
const userSelect = Prisma.validator<Prisma.UserSelect>()({
|
||||
@@ -160,7 +165,9 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
|
||||
return {
|
||||
props: {
|
||||
localeProp: locale,
|
||||
team,
|
||||
...(await serverSideTranslations(locale, ["common"])),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import { GetServerSidePropsContext } from "next";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
|
||||
import { asStringOrNull } from "@lib/asStringOrNull";
|
||||
import { extractLocaleInfo } from "@lib/core/i18n/i18n.utils";
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import prisma from "@lib/prisma";
|
||||
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
@@ -15,7 +15,7 @@ export default function TeamType(props: AvailabilityTeamPageProps) {
|
||||
}
|
||||
|
||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||
const locale = await extractLocaleInfo(context.req);
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
const slugParam = asStringOrNull(context.query.slug);
|
||||
const typeParam = asStringOrNull(context.query.type);
|
||||
const dateParam = asStringOrNull(context.query.date);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { GetServerSidePropsContext } from "next";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import "react-phone-number-input/style.css";
|
||||
|
||||
import { asStringOrThrow } from "@lib/asStringOrNull";
|
||||
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
|
||||
import prisma from "@lib/prisma";
|
||||
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
@@ -14,6 +16,7 @@ export default function TeamBookingPage(props: TeamBookingPageProps) {
|
||||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
const locale = await getOrSetUserLocaleFromHeaders(context.req);
|
||||
const eventTypeId = parseInt(asStringOrThrow(context.query.type));
|
||||
if (typeof eventTypeId !== "number" || eventTypeId % 1 !== 0) {
|
||||
return {
|
||||
@@ -86,6 +89,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
|
||||
return {
|
||||
props: {
|
||||
localeProp: locale,
|
||||
profile: {
|
||||
...eventTypeObject.team,
|
||||
slug: "team/" + eventTypeObject.slug,
|
||||
@@ -94,6 +98,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
},
|
||||
eventType: eventTypeObject,
|
||||
booking,
|
||||
...(await serverSideTranslations(locale, ["common"])),
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user