-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nevo David
committed
Sep 20, 2024
1 parent
6de19e4
commit 3a785e1
Showing
20 changed files
with
801 additions
and
177 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
40 changes: 40 additions & 0 deletions
40
apps/frontend/src/app/(site)/integrations/social/[provider]/continue/page.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,40 @@ | ||
import { HttpStatusCode } from 'axios'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
import { internalFetch } from '@gitroom/helpers/utils/internal.fetch'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default async function Page({ | ||
params: { provider }, | ||
searchParams, | ||
}: { | ||
params: { provider: string }; | ||
searchParams: any; | ||
}) { | ||
if (provider === 'x') { | ||
searchParams = { | ||
...searchParams, | ||
state: searchParams.oauth_token || '', | ||
code: searchParams.oauth_verifier || '', | ||
refresh: searchParams.refresh || '', | ||
}; | ||
} | ||
|
||
const data = await internalFetch(`/integrations/social/${provider}/connect`, { | ||
method: 'POST', | ||
body: JSON.stringify(searchParams), | ||
}); | ||
|
||
if (data.status === HttpStatusCode.NotAcceptable) { | ||
return redirect(`/launches?scope=missing`); | ||
} | ||
|
||
const { inBetweenSteps, id } = await data.json(); | ||
|
||
if (inBetweenSteps && !searchParams.refresh) { | ||
return redirect(`/launches?added=${provider}&continue=${id}`); | ||
} | ||
|
||
return redirect(`/launches?added=${provider}`); | ||
} |
31 changes: 2 additions & 29 deletions
31
apps/frontend/src/app/(site)/integrations/social/[provider]/page.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 |
---|---|---|
@@ -1,40 +1,13 @@ | ||
import { HttpStatusCode } from 'axios'; | ||
import { IntegrationRedirectComponent } from '@gitroom/frontend/components/launches/integration.redirect.component'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
import { internalFetch } from '@gitroom/helpers/utils/internal.fetch'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default async function Page({ | ||
params: { provider }, | ||
searchParams, | ||
}: { | ||
params: { provider: string }; | ||
searchParams: any; | ||
}) { | ||
if (provider === 'x') { | ||
searchParams = { | ||
...searchParams, | ||
state: searchParams.oauth_token || '', | ||
code: searchParams.oauth_verifier || '', | ||
refresh: searchParams.refresh || '', | ||
}; | ||
} | ||
|
||
const data = await internalFetch(`/integrations/social/${provider}/connect`, { | ||
method: 'POST', | ||
body: JSON.stringify(searchParams), | ||
}); | ||
|
||
if (data.status === HttpStatusCode.NotAcceptable) { | ||
return redirect(`/launches?scope=missing`); | ||
} | ||
|
||
const { inBetweenSteps, id } = await data.json(); | ||
|
||
if (inBetweenSteps && !searchParams.refresh) { | ||
return redirect(`/launches?added=${provider}&continue=${id}`); | ||
} | ||
|
||
return redirect(`/launches?added=${provider}`); | ||
return <IntegrationRedirectComponent />; | ||
} |
13 changes: 13 additions & 0 deletions
13
apps/frontend/src/app/(site)/integrations/social/layout.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,13 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
export default async function IntegrationLayout({ | ||
children, | ||
}: { | ||
children: ReactNode; | ||
}) { | ||
return ( | ||
<div className="text-6xl text-center mt-[50px]"> | ||
Adding channel, Redirecting You{children} | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.