-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: outlook 365 connect atom (#15318)
* custom for office 365 connect atom * office 365 connect atom * add office 365 atom to package exports * fixup * fixup * fixup fixup * refactors * chore: refactor connect atoms * fixup * chore: refactor connect, enable custom redir * fixup! Merge branch 'outlook-365-calendar-frontend' of github.com:calcom/cal.com into outlook-365-calendar-frontend * fixup! fixup! Merge branch 'outlook-365-calendar-frontend' of github.com:calcom/cal.com into outlook-365-calendar-frontend --------- Co-authored-by: Rajiv Sahal <rajivsahal@Rajivs-MacBook-Pro.local> Co-authored-by: Morgan Vernay <morgan@cal.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
- Loading branch information
1 parent
50eeb71
commit 7d4e8e2
Showing
17 changed files
with
285 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import type { FC } from "react"; | ||
|
||
import type { CALENDARS } from "@calcom/platform-constants"; | ||
import { Button } from "@calcom/ui"; | ||
|
||
import type { OnCheckErrorType } from "../hooks/connect/useCheck"; | ||
import { useCheck } from "../hooks/connect/useCheck"; | ||
import { useConnect } from "../hooks/connect/useConnect"; | ||
import { useAtomsContext } from "../hooks/useAtomsContext"; | ||
import { AtomsWrapper } from "../src/components/atoms-wrapper"; | ||
import { cn } from "../src/lib/utils"; | ||
|
||
export type OAuthConnectProps = { | ||
className?: string; | ||
label: string; | ||
alreadyConnectedLabel: string; | ||
loadingLabel: string; | ||
onCheckError?: OnCheckErrorType; | ||
redir?: string; | ||
}; | ||
|
||
export const OAuthConnect: FC<OAuthConnectProps & { calendar: (typeof CALENDARS)[number] }> = ({ | ||
label, | ||
alreadyConnectedLabel, | ||
loadingLabel, | ||
className, | ||
onCheckError, | ||
calendar, | ||
redir, | ||
}) => { | ||
const { isAuth } = useAtomsContext(); | ||
const { connect } = useConnect(calendar, redir); | ||
|
||
const { allowConnect, checked } = useCheck({ | ||
isAuth, | ||
onCheckError, | ||
calendar: calendar, | ||
}); | ||
|
||
const isChecking = !isAuth || !checked; | ||
const isDisabled = isChecking || !allowConnect; | ||
|
||
let displayedLabel = label; | ||
|
||
if (isChecking) { | ||
displayedLabel = loadingLabel; | ||
} else if (!allowConnect) { | ||
displayedLabel = alreadyConnectedLabel; | ||
} | ||
|
||
return ( | ||
<AtomsWrapper> | ||
<Button | ||
StartIcon="calendar-days" | ||
color="primary" | ||
disabled={isDisabled} | ||
className={cn( | ||
"", | ||
className, | ||
isChecking && "animate-pulse", | ||
isDisabled && "cursor-not-allowed", | ||
!isDisabled && "cursor-pointer" | ||
)} | ||
onClick={() => connect()}> | ||
{displayedLabel} | ||
</Button> | ||
</AtomsWrapper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { FC } from "react"; | ||
|
||
import { GOOGLE_CALENDAR } from "@calcom/platform-constants"; | ||
|
||
import type { OAuthConnectProps } from "../OAuthConnect"; | ||
import { OAuthConnect } from "../OAuthConnect"; | ||
|
||
export const GcalConnect: FC<Partial<OAuthConnectProps>> = ({ | ||
label = "Connect Google Calendar", | ||
alreadyConnectedLabel = "Connected Google Calendar", | ||
loadingLabel = "Checking Google Calendar", | ||
className, | ||
onCheckError, | ||
redir, | ||
}) => { | ||
return ( | ||
<OAuthConnect | ||
label={label} | ||
alreadyConnectedLabel={alreadyConnectedLabel} | ||
loadingLabel={loadingLabel} | ||
calendar={GOOGLE_CALENDAR} | ||
className={className} | ||
onCheckError={onCheckError} | ||
redir={redir} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { GcalConnect as GoogleCalendar } from "./google/GcalConnect"; | ||
export { OutlookConnect as OutlookCalendar } from "./outlook/OutlookConnect"; |
27 changes: 27 additions & 0 deletions
27
packages/platform/atoms/connect/outlook/OutlookConnect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { FC } from "react"; | ||
|
||
import { OFFICE_365_CALENDAR } from "@calcom/platform-constants"; | ||
|
||
import type { OAuthConnectProps } from "../OAuthConnect"; | ||
import { OAuthConnect } from "../OAuthConnect"; | ||
|
||
export const OutlookConnect: FC<Partial<OAuthConnectProps>> = ({ | ||
label = "Connect Outlook Calendar", | ||
alreadyConnectedLabel = "Connected Outlook Calendar", | ||
loadingLabel = "Checking Outlook Calendar", | ||
className, | ||
onCheckError, | ||
redir, | ||
}) => { | ||
return ( | ||
<OAuthConnect | ||
label={label} | ||
alreadyConnectedLabel={alreadyConnectedLabel} | ||
loadingLabel={loadingLabel} | ||
calendar={OFFICE_365_CALENDAR} | ||
className={className} | ||
onCheckError={onCheckError} | ||
redir={redir} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.