Skip to content

Commit

Permalink
Login app
Browse files Browse the repository at this point in the history
  • Loading branch information
vietredweb committed Apr 5, 2024
1 parent e4a2d51 commit 1649769
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/AnalyticsNext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ interface AnalyticsNext {
router: NextRouter;
attributes: any;
customLayout?: boolean;
loginApp?: any;
children?: ReactNode;
}

const AnalyticsNext = ({ router, attributes, customLayout = false, children }: AnalyticsNext) => {
const AnalyticsNext = ({
router,
attributes,
customLayout = false,
loginApp,
children,
}: AnalyticsNext) => {
return (
<>
<AnalyticsContextProvider>
Expand All @@ -28,12 +35,14 @@ const AnalyticsNext = ({ router, attributes, customLayout = false, children }: A
endpoint={process.env.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL}
networkEnv={process.env.NEXT_PUBLIC_CONCORDIUM_NETWORK}
aesirXEndpoint={process.env.NEXT_PUBLIC_ENDPOINT_URL ?? 'https://api.aesirx.io'}
loginApp={loginApp}
/>
) : (
<ConsentComponent
endpoint={process.env.NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL}
networkEnv={process.env.NEXT_PUBLIC_CONCORDIUM_NETWORK}
aesirXEndpoint={process.env.NEXT_PUBLIC_ENDPOINT_URL ?? 'https://api.aesirx.io'}
loginApp={loginApp}
/>
)}
</>
Expand Down
13 changes: 11 additions & 2 deletions src/Components/Consent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@ interface WalletConnectionPropsExtends extends WalletConnectionProps {
endpoint: string;
aesirXEndpoint: string;
networkEnv?: string;
loginApp?: any;
}
const ConsentComponent = ({ endpoint, aesirXEndpoint, networkEnv }: any) => {
const ConsentComponent = ({ endpoint, aesirXEndpoint, networkEnv, loginApp }: any) => {
return (
<WithWalletConnector network={networkEnv === 'testnet' ? TESTNET : MAINNET}>
{(props) => (
<div className="aesirxconsent">
<SSOEthereumProvider>
<ConsentComponentApp {...props} endpoint={endpoint} aesirXEndpoint={aesirXEndpoint} />
<ConsentComponentApp
{...props}
endpoint={endpoint}
aesirXEndpoint={aesirXEndpoint}
loginApp={loginApp}
/>
</SSOEthereumProvider>
</div>
)}
Expand All @@ -66,6 +72,7 @@ const ConsentComponentApp = (props: WalletConnectionPropsExtends) => {
const {
endpoint,
aesirXEndpoint,
loginApp,
activeConnectorType,
activeConnector,
activeConnectorError,
Expand Down Expand Up @@ -227,6 +234,7 @@ const ConsentComponentApp = (props: WalletConnectionPropsExtends) => {
);
sessionStorage.setItem('aesirx-analytics-jwt', data?.jwt);
jwt = data?.jwt;
loginApp && loginApp(data);
setLoadingCheckAccount(false);
}
} else {
Expand Down Expand Up @@ -398,6 +406,7 @@ const ConsentComponentApp = (props: WalletConnectionPropsExtends) => {
setLoading('done');
}
}
loginApp && loginApp(response);
} catch (error) {
console.log(error);
setShow(false);
Expand Down
7 changes: 6 additions & 1 deletion src/Components/ConsentCustom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ interface WalletConnectionPropsExtends extends WalletConnectionProps {
endpoint: string;
aesirXEndpoint: string;
networkEnv?: string;
loginApp?: any;
}
const ConsentComponentCustom = ({ endpoint, aesirXEndpoint, networkEnv }: any) => {
const ConsentComponentCustom = ({ endpoint, aesirXEndpoint, networkEnv, loginApp }: any) => {
return (
<WithWalletConnector network={networkEnv === 'testnet' ? TESTNET : MAINNET}>
{(props) => (
Expand All @@ -61,6 +62,7 @@ const ConsentComponentCustom = ({ endpoint, aesirXEndpoint, networkEnv }: any) =
{...props}
endpoint={endpoint}
aesirXEndpoint={aesirXEndpoint}
loginApp={loginApp}
/>
</SSOEthereumProvider>
</div>
Expand All @@ -72,6 +74,7 @@ const ConsentComponentCustomApp = (props: WalletConnectionPropsExtends) => {
const {
endpoint,
aesirXEndpoint,
loginApp,
activeConnectorType,
activeConnector,
activeConnectorError,
Expand Down Expand Up @@ -236,6 +239,7 @@ const ConsentComponentCustomApp = (props: WalletConnectionPropsExtends) => {
);
sessionStorage.setItem('aesirx-analytics-jwt', data?.jwt);
jwt = data?.jwt;
loginApp && loginApp(data);
setLoadingCheckAccount(false);
}
} else {
Expand Down Expand Up @@ -407,6 +411,7 @@ const ConsentComponentCustomApp = (props: WalletConnectionPropsExtends) => {
setLoading('done');
}
}
loginApp && loginApp(response);
} catch (error) {
console.log(error);
setShow(false);
Expand Down

0 comments on commit 1649769

Please sign in to comment.