Skip to content

Commit

Permalink
fix: handle amplify secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozwiaczek committed Nov 9, 2020
1 parent 3336091 commit 53864b5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { IntentbaseProvider } from '../src';

export const decorators = [
(Story) => (
<IntentbaseProvider>
<IntentbaseProvider
region={process.env.AWS_DEFAULT_REGION}
userPoolId={process.env.COGNITO_USER_POOL_ID}
userPoolWebClientId={process.env.COGNITO_USER_POOL_CLIENT_ID}
>
<Story />
</IntentbaseProvider>
),
Expand Down
13 changes: 11 additions & 2 deletions src/containers/IntentbaseProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ import { SnackbarContextProvider } from '../components/SnackbarProvider';

interface IntentbaseProps {
theme?: Partial<Theme> | ((outerTheme: Theme) => Theme);
region: string;
userPoolId: string;
userPoolWebClientId: string;
}

export const IntentbaseProvider: FC<IntentbaseProps> = ({ children, theme = defaultTheme }) => {
configureAmplify();
export const IntentbaseProvider: FC<IntentbaseProps> = ({
children,
region = 'eu-central-1',
userPoolId,
userPoolWebClientId,
theme = defaultTheme,
}) => {
configureAmplify(region, userPoolId, userPoolWebClientId);
return (
<StylesProvider injectFirst>
<MuiThemeProvider theme={theme}>
Expand Down
12 changes: 8 additions & 4 deletions src/utils/configureAmplify.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import Amplify from 'aws-amplify';

export const configureAmplify = (): void => {
export const configureAmplify = (
region: string,
userPoolId: string,
userPoolWebClientId: string,
): void => {
Amplify.configure({
Auth: {
region: process.env.AWS_DEFAULT_REGION,
userPoolId: process.env.COGNITO_USER_POOL_ID,
userPoolWebClientId: process.env.COGNITO_USER_POOL_CLIENT_ID,
region,
userPoolId,
userPoolWebClientId,
},
});
};

0 comments on commit 53864b5

Please sign in to comment.