Skip to content

Commit 0ad3986

Browse files
committed
stub out api call from FE
1 parent b54eb2b commit 0ad3986

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

components/dashboard/src/login/SSOLoginForm.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77
import { useMutation } from "@tanstack/react-query";
88
import { FC, useCallback, useState } from "react";
9+
import Alert from "../components/Alert";
910
import { Button } from "../components/Button";
1011
import { TextInputField } from "../components/forms/TextInputField";
12+
import { getGitpodService } from "../service/service";
1113

1214
export const SSOLoginForm: FC = () => {
1315
const [orgSlug, setOrgSlug] = useState("");
16+
const [error, setError] = useState("");
17+
1418
// TODO: remove this
1519
const [loginUrl, setLoginUrl] = useState("");
1620

@@ -20,6 +24,7 @@ export const SSOLoginForm: FC = () => {
2024
// return provider id
2125
await new Promise((resolve) => setTimeout(resolve, 2000));
2226

27+
// return await getGitpodService().server.getSSOLoginID(slug);
2328
return { id: "sample-id" };
2429
},
2530
});
@@ -29,10 +34,16 @@ export const SSOLoginForm: FC = () => {
2934
e.preventDefault();
3035

3136
// make api call to get provider id by slug
32-
const { id } = await exchangeSlug.mutateAsync({ slug: orgSlug });
37+
const resp = await exchangeSlug.mutateAsync({ slug: orgSlug });
38+
const loginId = resp?.id;
39+
40+
// No SSO configured for provided slug
41+
if (!loginId) {
42+
setError("It looks like SSO has not been configured for that organization.");
43+
}
3344

3445
// create sso login url with provider id
35-
const loginUrl = `/oidc/start/?id=${id}`;
46+
const loginUrl = `/oidc/start/?id=${loginId}`;
3647
setLoginUrl(loginUrl);
3748

3849
// openAuthorize window for sso w/ login url
@@ -49,6 +60,7 @@ export const SSOLoginForm: FC = () => {
4960
Continue with SSO
5061
</Button>
5162
{loginUrl && <p>{loginUrl}</p>}
63+
{error && <Alert type="info">{error}</Alert>}
5264
</div>
5365
</form>
5466
);

0 commit comments

Comments
 (0)