Build a greeter app
Building a Greeter app
yarn app-store createLast updated
Was this helpful?
yarn app-store createLast updated
Was this helpful?
Was this helpful?
/**
* GreeterButton.tsx
* It creates a button that can be added anywhere. The button is visible only if the app is installed.
*/
import useApp from "@calcom/lib/hooks/useApp";
import showToast from "@calcom/lib/notification";
import { Button } from "@calcom/ui";
import useMeQuery from "@lib/hooks/useMeQuery";
export default function GreeterButton() {
const { data: user } = useMeQuery();
const { data: greeterApp } = useApp("greeter");
// Make sure that greeterApp is installed. We shouldn't show the button when app is not installed
if (!user || !greeterApp) {
return null;
}
return (
<Button
onClick={() => {
showToast("Hello, " + user.name, "success");
}}>
Greet Me!
</Button>
);
}/**
* Shell.tsx
*/
....
import GreeterButton from "@calcom/app-store/greeter/components/GreeterButton"
.....
<GreeterButton />