feat: added banner for orgs (#13644)

Use this banner to test https://pbs.twimg.com/profile_banners/1063089191565905920/1685635865/1500x500

- [x] add backend
- [x] add file upload (require 1500x500px) in Organization/Appearance
- [x] for now, apply this to all Org event types. later we could think about sub-team overwrites, but for now org is enough


1) Upload Banner Screen

<img width="1512" alt="Screenshot 2024-02-15 at 10 26 36 PM" src="https://github.com/calcom/cal.com/assets/53316345/3c7417ee-7ef7-4138-b5f8-38f255a407fa">

2) 

<img width="1512" alt="Screenshot 2024-02-15 at 10 27 02 PM" src="https://github.com/calcom/cal.com/assets/53316345/a74dffbf-3727-4b2f-82d5-fefd55c12901">


3) Go to Org Team Event Types

<img width="1512" alt="Screenshot 2024-02-15 at 10 27 21 PM" src="https://github.com/calcom/cal.com/assets/53316345/5f188bd7-8a66-4da7-be73-1b5e178b5b3b">


__________________________________________________

DESIGNS


![CleanShot 2024-02-12 at 15 02 37@2x](https://github.com/calcom/cal.com/assets/8019099/85602120-1ced-4627-ae7c-375d33ccf1e9)


__


![CleanShot 2024-02-12 at 14 55 23@2x](https://github.com/calcom/cal.com/assets/8019099/e8a9e9c3-4e01-4a07-a2e0-7259027feb36)


![CleanShot 2024-02-12 at 14 55 34@2x](https://github.com/calcom/cal.com/assets/8019099/56500809-6c6e-49a6-9229-43190dd711b7)

mobile:
![CleanShot 2024-02-12 at 14 56 00@2x](https://github.com/calcom/cal.com/assets/8019099/f90b58b2-3104-4c00-bc18-a2a54ac8e7e7)
This commit is contained in:
Peer Richelsen authored and GitHub committed 2024-03-06 16:18:56 -07:00
1 parent 0972307998
commit dfd683ffc4
16 files changed
+435 -88

No files matched your search

@@ -66,6 +66,7 @@ const BookerComponent = ({
bookerLayout,
schedule,
verifyCode,
orgBannerUrl,
}: BookerProps & WrappedBookerProps) => {
const [bookerState, setBookerState] = useBookerStore((state) => [state.state, state.setState], shallow);
const selectedDate = useBookerStore((state) => state.selectedDate);
@@ -338,6 +339,15 @@ const BookerComponent = ({
<BookerSection
area="meta"
className="max-w-screen flex w-full flex-col md:w-[var(--booker-meta-width)]">
{orgBannerUrl && (
<img
loading="eager"
className="-mb-9 h-40 max-h-40 rounded-tl-md sm:max-h-24"
alt="org banner"
src={orgBannerUrl}
/>
)}
<EventMeta event={event.data} isPending={event.isPending} />
{layout !== BookerLayouts.MONTH_VIEW &&
!(layout === "mobile" && bookerState === "booking") && (
@@ -16,6 +16,7 @@ import type { GetBookingType } from "../lib/get-booking";
export interface BookerProps {
eventSlug: string;
username: string;
orgBannerUrl?: string | null;
/**
* Whether is a team or org, we gather basic info from both
@@ -22,6 +22,7 @@ import {
Button,
Form,
ImageUploader,
BannerUploader,
Label,
Meta,
showToast,
@@ -40,12 +41,14 @@ import { useOrgBranding } from "../../../organizations/context/provider";
const orgProfileFormSchema = z.object({
name: z.string(),
logo: z.string().nullable(),
banner: z.string().nullable(),
bio: z.string(),
});
type FormValues = {
name: string;
logo: string | null;
banner: string | null;
bio: string;
slug: string;
};
@@ -110,6 +113,7 @@ const OrgProfileView = () => {
const defaultValues: FormValues = {
name: currentOrganisation?.name || "",
logo: currentOrganisation?.logo || "",
banner: currentOrganisation?.bannerUrl || "",
bio: currentOrganisation?.bio || "",
slug:
currentOrganisation?.slug ||
@@ -178,6 +182,7 @@ const OrgProfileForm = ({ defaultValues }: { defaultValues: FormValues }) => {
name: (res.data?.name || "") as string,
bio: (res.data?.bio || "") as string,
slug: defaultValues["slug"],
banner: (res.data?.bannerUrl || "") as string,
});
await utils.viewer.teams.get.invalidate();
await utils.viewer.organizations.listCurrent.invalidate();
@@ -201,6 +206,7 @@ const OrgProfileForm = ({ defaultValues }: { defaultValues: FormValues }) => {
name: values.name,
slug: values.slug,
bio: values.bio,
banner: values.banner,
};
mutation.mutate(variables);
@@ -250,6 +256,53 @@ const OrgProfileForm = ({ defaultValues }: { defaultValues: FormValues }) => {
/>
</div>
<div className="mt-2 flex items-center">
<Controller
control={form.control}
name="banner"
render={({ field: { value } }) => {
const showRemoveBannerButton = !!value;
return (
<>
<Avatar
data-testid="profile-upload-banner"
alt={`${defaultValues.name} Banner` || ""}
imageSrc={value}
size="lg"
/>
<div className="ms-4">
<div className="flex gap-2">
<BannerUploader
height={500}
width={1500}
target="banner"
uploadInstruction={t("org_banner_instructions", { height: 500, width: 1500 })}
id="banner-upload"
buttonMsg={t("upload_banner")}
handleAvatarChange={(newBanner) => {
form.setValue("banner", newBanner, { shouldDirty: true });
}}
imageSrc={value || undefined}
triggerButtonColor={showRemoveBannerButton ? "secondary" : "primary"}
/>
{showRemoveBannerButton && (
<Button
color="destructive"
onClick={() => {
form.setValue("banner", "", { shouldDirty: true });
}}>
{t("remove")}
</Button>
)}
</div>
</div>
</>
);
}}
/>
</div>
<Controller
control={form.control}
name="name"
@@ -81,6 +81,7 @@ const publicEventSelect = Prisma.validator<Prisma.EventTypeSelect>()({
select: {
slug: true,
name: true,
bannerUrl: true,
},
},
},