Add CTA to Meta component & button to add calendar on /settings/calendars (#5099)
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
1 parent
7bb3397503
commit
e53abd921e
4 files changed
+28
-11
No files matched your search
@@ -1,18 +1,18 @@
|
||||
import Head from "next/head";
|
||||
import React, { createContext, useContext, useState, useEffect } from "react";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
type MetaType = {
|
||||
title: string;
|
||||
description: string;
|
||||
backButton?: boolean;
|
||||
CTA?: React.ReactNode;
|
||||
};
|
||||
|
||||
const initialMeta = {
|
||||
const initialMeta: MetaType = {
|
||||
title: "",
|
||||
description: "",
|
||||
backButton: false,
|
||||
CTA: null,
|
||||
};
|
||||
|
||||
const MetaContext = createContext({
|
||||
@@ -41,16 +41,16 @@ export function MetaProvider({ children }: { children: React.ReactNode }) {
|
||||
* elsewhere (ie. on a Heading, Title, Subtitle, etc.)
|
||||
* @example <Meta title="Password" description="Manage settings for your account passwords" />
|
||||
*/
|
||||
export default function Meta({ title, description, backButton }: MetaType) {
|
||||
export default function Meta({ title, description, backButton, CTA }: MetaType) {
|
||||
const { setMeta, meta } = useMeta();
|
||||
|
||||
/* @TODO: maybe find a way to have this data on first render to prevent flicker */
|
||||
useEffect(() => {
|
||||
if (meta.title !== title || meta.description !== description) {
|
||||
setMeta({ title, description, backButton });
|
||||
setMeta({ title, description, backButton, CTA });
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [title, description, backButton]);
|
||||
}, [title, description, backButton, CTA]);
|
||||
|
||||
return (
|
||||
<Head>
|
||||
|
||||
@@ -377,6 +377,7 @@ function ShellHeader() {
|
||||
<div className="mb-1 h-6 w-32 animate-pulse rounded-md bg-gray-200" />
|
||||
)}
|
||||
</div>
|
||||
<div className="ml-auto">{meta.CTA}</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user