Skip to content

Commit a2df137

Browse files
authored
Merge branch 'main' into stripe_metadat_restriction
2 parents 4a12107 + 489d56d commit a2df137

3 files changed

Lines changed: 79 additions & 24 deletions

File tree

apps/web/app/_utils.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,48 @@ export const _generateMetadata = async (
8080
};
8181
};
8282

83+
export const _generateMetadataForStaticPage = (
84+
title: string,
85+
description: string,
86+
hideBranding?: boolean,
87+
origin?: string,
88+
pathname?: string
89+
) => {
90+
const _pathname = pathname ?? "";
91+
const canonical = buildCanonical({ path: _pathname, origin: origin ?? CAL_URL });
92+
const titleSuffix = `| ${APP_NAME}`;
93+
const displayedTitle = title.includes(titleSuffix) || hideBranding ? title : `${title} ${titleSuffix}`;
94+
const metadataBase = new URL(IS_CALCOM ? getCalcomUrl() : WEBAPP_URL);
95+
96+
const metadata = {
97+
title: title.length === 0 ? APP_NAME : displayedTitle,
98+
description,
99+
alternates: { canonical },
100+
openGraph: {
101+
description: truncateOnWord(description, 158),
102+
url: canonical,
103+
type: "website",
104+
siteName: APP_NAME,
105+
title: displayedTitle,
106+
},
107+
metadataBase,
108+
};
109+
const image =
110+
SEO_IMG_OGIMG +
111+
constructGenericImage({
112+
title: metadata.title,
113+
description: metadata.description,
114+
});
115+
116+
return {
117+
...metadata,
118+
openGraph: {
119+
...metadata.openGraph,
120+
images: [image],
121+
},
122+
};
123+
};
124+
83125
export const generateMeetingMetadata = async (
84126
meeting: MeetingImageProps,
85127
getTitle: (t: TFunction<string, undefined>) => string,

apps/web/app/icons/page.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { _generateMetadata, getTranslate } from "app/_utils";
1+
import { _generateMetadataForStaticPage } from "app/_utils";
2+
import type { Metadata } from "next";
23
import { Inter } from "next/font/google";
34
import localFont from "next/font/local";
45

@@ -8,6 +9,15 @@ import type { IconName } from "@calcom/ui/components/icon";
89
import { lucideIconList } from "../../../../packages/ui/components/icon/icon-list.mjs";
910
import { IconGrid } from "./IconGrid";
1011

12+
export const dynamic = "force-static";
13+
export const metadata: Metadata = _generateMetadataForStaticPage(
14+
"Icons Showcase",
15+
"",
16+
undefined,
17+
undefined,
18+
"/icons"
19+
);
20+
1121
const interFont = Inter({ subsets: ["latin"], variable: "--font-inter", preload: true, display: "swap" });
1222
const calFont = localFont({
1323
src: "../../fonts/CalSans-SemiBold.woff2",
@@ -16,25 +26,16 @@ const calFont = localFont({
1626
display: "swap",
1727
weight: "600",
1828
});
19-
export const generateMetadata = async () => {
20-
return await _generateMetadata(
21-
(t) => t("icon_showcase"),
22-
() => "",
23-
undefined,
24-
undefined,
25-
"/icons"
26-
);
27-
};
28-
export default async function IconsPage() {
29+
30+
export default function IconsPage() {
2931
const icons = Array.from(lucideIconList).sort() as IconName[];
30-
const t = await getTranslate();
3132

3233
return (
3334
<div className={`${interFont.variable} ${calFont.variable}`}>
3435
<div className="bg-subtle flex h-screen">
3536
<IconSprites />
3637
<div className="bg-default m-auto min-w-full rounded-md p-10 text-right ltr:text-left">
37-
<h1 className="text-emphasis font-cal text-2xl font-medium">{t("icons_showcase")}</h1>
38+
<h1 className="text-emphasis font-cal text-2xl font-medium">Icons Showcase</h1>
3839
<IconGrid title="Regular Icons" icons={icons} />
3940
<IconGrid
4041
title="Filled Icons"

packages/features/form-builder/FormBuilder.tsx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,30 @@ type RhfFormFields = RhfForm["fields"];
4242

4343
type RhfFormField = RhfFormFields[number];
4444

45+
type DataStore = {
46+
options: Record<
47+
string,
48+
{
49+
source: { label: string };
50+
value: { label: string; value: string; inputPlaceholder?: string }[];
51+
}
52+
>;
53+
};
54+
4555
function getCurrentFieldType(fieldForm: UseFormReturn<RhfFormField>) {
4656
return fieldTypesConfigMap[fieldForm.watch("type") || "text"];
4757
}
4858

59+
const getLocationFieldType = (field: RhfFormField) => {
60+
const baseFieldType = fieldTypesConfigMap[field.type];
61+
62+
if (field.name === "location") {
63+
return { ...baseFieldType, label: "Location" };
64+
}
65+
66+
return baseFieldType;
67+
};
68+
4969
/**
5070
* It works with a react-hook-form only.
5171
* `formProp` specifies the name of the property in the react-hook-form that has the fields. This is where fields would be updated.
@@ -71,15 +91,7 @@ export const FormBuilder = function FormBuilder({
7191
/**
7292
* A readonly dataStore that is used to lookup the options for the fields. It works in conjunction with the field.getOptionAt property which acts as the key in options
7393
*/
74-
dataStore: {
75-
options: Record<
76-
string,
77-
{
78-
source: { label: string };
79-
value: { label: string; value: string; inputPlaceholder?: string }[];
80-
}
81-
>;
82-
};
94+
dataStore: DataStore;
8395
/**
8496
* This is kind of a hack to allow certain fields to be just shown as required when they might not be required in a strict sense
8597
* e.g. Location field has a default value at backend so API can send no location but formBuilder in UI doesn't allow it.
@@ -226,7 +238,7 @@ export const FormBuilder = function FormBuilder({
226238
return null;
227239
}
228240

229-
const fieldType = fieldTypesConfigMap[field.type];
241+
const fieldType = getLocationFieldType(field);
230242
const isFieldEditableSystemButOptional = field.editable === "system-but-optional";
231243
const isFieldEditableSystemButHidden = field.editable === "system-but-hidden";
232244
const isFieldEditableSystem = field.editable === "system";
@@ -565,7 +577,7 @@ function FieldEditDialog({
565577
}
566578
fieldForm.setValue("type", value, { shouldDirty: true });
567579
}}
568-
value={fieldTypesConfigMap[formFieldType]}
580+
value={dialog.data ? getLocationFieldType(dialog.data) : fieldTypesConfigMap[formFieldType]}
569581
options={fieldTypes.filter((f) => !f.systemOnly)}
570582
label={t("input_type")}
571583
/>

0 commit comments

Comments
 (0)