Only show Google Meet dependency when GCal is not set as destination calendar (#7442)

* Query for destination calendar

* Only display Meet warning when destination calendar is not GCal

* Add conditional

---------

Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
Joe Au-YeungandAlex van Andel authored and GitHub committed 2023-03-06 12:37:18 +00:00
1 parent 3d41c64d81
commit 5f9f6ef025
3 files changed
+22 -5

No files matched your search

@@ -46,11 +46,14 @@ const getDefaultLocationValue = (options: EventTypeSetupProps["locationOptions"]
};
export const EventSetupTab = (
props: Pick<EventTypeSetupProps, "eventType" | "locationOptions" | "team" | "teamMembers">
props: Pick<
EventTypeSetupProps,
"eventType" | "locationOptions" | "team" | "teamMembers" | "destinationCalendar"
>
) => {
const { t } = useLocale();
const formMethods = useFormContext<FormValues>();
const { eventType, locationOptions, team } = props;
const { eventType, locationOptions, team, destinationCalendar } = props;
const [showLocationModal, setShowLocationModal] = useState(false);
const [editingLocationType, setEditingLocationType] = useState<string>("");
const [selectedLocation, setSelectedLocation] = useState<LocationOption | undefined>(undefined);
@@ -231,7 +234,10 @@ export const EventSetupTab = (
</li>
);
})}
{validLocations.some((location) => location.type === MeetLocationType) && (
{validLocations.some(
(location) =>
location.type === MeetLocationType && destinationCalendar?.integration !== "google_calendar"
) && (
<div className="flex text-sm text-gray-600">
<FiCheck className="mt-0.5 mr-1.5 h-2 w-2.5" />
<Trans i18nKey="event_type_requres_google_cal">
@@ -243,7 +249,6 @@ export const EventSetupTab = (
className="underline">
here.
</Link>{" "}
We will fall back to Cal video if you do not change it.
</p>
</Trans>
</div>
+2 -1
View File
@@ -123,7 +123,7 @@ const EventTypePage = (props: EventTypeSetupProps) => {
extendsFeature: "EventType",
});
const { eventType, locationOptions, team, teamMembers, currentUserMembership } = props;
const { eventType, locationOptions, team, teamMembers, currentUserMembership, destinationCalendar } = props;
const [animationParentRef] = useAutoAnimate<HTMLDivElement>();
const updateMutation = trpc.viewer.eventTypes.update.useMutation({
@@ -261,6 +261,7 @@ const EventTypePage = (props: EventTypeSetupProps) => {
locationOptions={locationOptions}
team={team}
teamMembers={teamMembers}
destinationCalendar={destinationCalendar}
/>
),
availability: <AvailabilityTab isTeamEvent={!!team} />,
+11
View File
@@ -282,9 +282,20 @@ export default async function getEventTypeById({
// Sets to null if no membership is found - this must mean we are in a none team event type
const currentUserMembership = eventTypeObject.team?.members.find((el) => el.user.id === userId) ?? null;
let destinationCalendar = eventTypeObject.destinationCalendar;
if (!destinationCalendar) {
destinationCalendar = await prisma.destinationCalendar.findFirst({
where: {
userId: userId,
eventTypeId: null,
},
});
}
const finalObj = {
eventType: eventTypeObject,
locationOptions,
destinationCalendar,
team: eventTypeObject.team || null,
teamMembers,
currentUserMembership,