Skip to content

Commit 87191ae

Browse files
committed
Type refactoring
1 parent 662aaf8 commit 87191ae

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

react-static-web-apps-auth/src/Login.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ import React from "react";
22
import { StaticWebAppsClassName } from "./constants";
33
import { AuthProviders } from "./types";
44

5+
export type LoginProps = {
6+
name: string;
7+
id: AuthProviders;
8+
postLoginRedirect?: string;
9+
label?: (name: string) => string;
10+
};
11+
512
const Login = ({
613
name,
714
id,
815
postLoginRedirect,
916
label = (name) => `Sign in using ${name}`,
10-
}: {
11-
name: string;
12-
id: AuthProviders;
13-
postLoginRedirect?: string;
14-
label?: (name: string) => string;
15-
}) => {
17+
}: LoginProps) => {
1618
return (
1719
<a
1820
href={`/.auth/login/${id}${

react-static-web-apps-auth/src/StaticWebAuthLogins.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import Login from "./Login";
2+
import Login, { LoginProps } from "./Login";
33

44
export type CustomProvider = {
55
id: string;
@@ -18,12 +18,9 @@ export type LoginProviderProps = {
1818
label?: (name: string) => string;
1919
};
2020

21-
type LoginProps = {
22-
postLoginRedirect?: string;
23-
label?: (name: string) => string;
24-
};
21+
type LoginWrapperProps = Pick<LoginProps, "postLoginRedirect" | "label">;
2522

26-
const AzureADLogin = ({ postLoginRedirect, label }: LoginProps) => (
23+
const AzureADLogin = ({ postLoginRedirect, label }: LoginWrapperProps) => (
2724
<Login
2825
name="Azure AD"
2926
id="aad"
@@ -32,7 +29,7 @@ const AzureADLogin = ({ postLoginRedirect, label }: LoginProps) => (
3229
key="aad"
3330
/>
3431
);
35-
const FacebookLogin = ({ postLoginRedirect, label }: LoginProps) => (
32+
const FacebookLogin = ({ postLoginRedirect, label }: LoginWrapperProps) => (
3633
<Login
3734
name="Facebook"
3835
id="facebook"
@@ -41,7 +38,7 @@ const FacebookLogin = ({ postLoginRedirect, label }: LoginProps) => (
4138
key="facebook"
4239
/>
4340
);
44-
const TwitterLogin = ({ postLoginRedirect, label }: LoginProps) => (
41+
const TwitterLogin = ({ postLoginRedirect, label }: LoginWrapperProps) => (
4542
<Login
4643
name="Twitter"
4744
id="twitter"
@@ -50,7 +47,7 @@ const TwitterLogin = ({ postLoginRedirect, label }: LoginProps) => (
5047
key="twitter"
5148
/>
5249
);
53-
const GitHubLogin = ({ postLoginRedirect, label }: LoginProps) => (
50+
const GitHubLogin = ({ postLoginRedirect, label }: LoginWrapperProps) => (
5451
<Login
5552
name="GitHub"
5653
id="github"
@@ -59,7 +56,7 @@ const GitHubLogin = ({ postLoginRedirect, label }: LoginProps) => (
5956
key="github"
6057
/>
6158
);
62-
const GoogleLogin = ({ postLoginRedirect, label }: LoginProps) => (
59+
const GoogleLogin = ({ postLoginRedirect, label }: LoginWrapperProps) => (
6360
<Login
6461
name="Google"
6562
id="google"
@@ -68,7 +65,7 @@ const GoogleLogin = ({ postLoginRedirect, label }: LoginProps) => (
6865
key="google"
6966
/>
7067
);
71-
const AppleLogin = ({ postLoginRedirect, label }: LoginProps) => (
68+
const AppleLogin = ({ postLoginRedirect, label }: LoginWrapperProps) => (
7269
<Login
7370
name="Apple"
7471
id="apple"
@@ -83,7 +80,7 @@ const CustomProviderLogin = ({
8380
id,
8481
name,
8582
label,
86-
}: LoginProps & CustomProvider) => (
83+
}: LoginWrapperProps & CustomProvider) => (
8784
<Login
8885
name={name || id}
8986
id={id}

0 commit comments

Comments
 (0)