Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add close button #204

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/web-shared/components/Auth/AuthConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import AuthLayout from './AuthLayout';
import authSteps from './authSteps';
import { useAnalytics } from '../../providers/AnalyticsProvider';

const AuthConfirm = () => {
const AuthConfirm = (props) => {
const [status, setStatus] = useState('IDLE');
const [error, setError] = useState(null);
const [state, dispatch] = useAuth();
Expand Down Expand Up @@ -63,7 +63,7 @@ const AuthConfirm = () => {
email: user?.email,
phone: user?.phone,
numberOfSharedProfiles: sharedProfiles.length,
});
});
dispatch(
updateAuth({
token,
Expand All @@ -77,7 +77,7 @@ const AuthConfirm = () => {
userId: user?.id,
email: user?.email,
phone: user?.phone,
});
});
if (needsOnboarding) {
dispatch(
updateAuth({
Expand Down Expand Up @@ -130,6 +130,7 @@ const AuthConfirm = () => {

return (
<AuthLayout
{...props}
heading="We sent you a code..."
subHeading={`Verify the code we sent to your ${state.type === 'email' ? 'email' : 'phone'}.`}
>
Expand Down
10 changes: 3 additions & 7 deletions packages/web-shared/components/Auth/AuthDetails.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import React, { useState, useEffect } from 'react';

import {
useForm,
useUpdateProfileFields,
useCurrentUser,
useCompleteRegister,
} from '../../hooks';
import { useForm, useUpdateProfileFields, useCurrentUser, useCompleteRegister } from '../../hooks';
import { update as updateAuth, useAuth } from '../../providers/AuthProvider';
import { Box, Button, Input, Select } from '../../ui-kit';
import authSteps from '../Auth/authSteps';
Expand All @@ -16,7 +11,7 @@ function upperFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function AuthDetails() {
function AuthDetails(props) {
const [status, setStatus] = useState('IDLE');
const [error, setError] = useState(null);
const [user, setUser] = useState(null);
Expand Down Expand Up @@ -61,6 +56,7 @@ function AuthDetails() {

return (
<AuthLayout
{...props}
heading="Complete your profile"
subHeading="Help us learn a little more about you so we can connect you with the
best ministries and events."
Expand Down
11 changes: 4 additions & 7 deletions packages/web-shared/components/Auth/AuthIdentity.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Button, Input, SmallSystemText, Box } from '../../ui-kit';
import { validateEmail, validatePhoneNumber } from '../../utils';
import AuthLayout from './AuthLayout';

const AuthIdentity = () => {
const AuthIdentity = (props) => {
const [status, setStatus] = useState('IDLE');
const [error, setError] = useState(null);
const [state, dispatch] = useAuth();
Expand Down Expand Up @@ -72,9 +72,7 @@ const AuthIdentity = () => {
setStatus('LOADING');
requestLogin({
variables: {
identity: validEmail
? { email: values.identity }
: { phone: values.identity },
identity: validEmail ? { email: values.identity } : { phone: values.identity },
},
});
} else {
Expand All @@ -87,9 +85,8 @@ const AuthIdentity = () => {

return (
<AuthLayout
heading={
state.type === 'login' ? 'Welcome back!' : 'We’re glad you’re here.'
}
{...props}
heading={state.type === 'login' ? 'Welcome back!' : 'We’re glad you’re here.'}
subHeading={
state.type === 'login'
? 'Use the same phone number or email that you used when logging into the app before.'
Expand Down
16 changes: 14 additions & 2 deletions packages/web-shared/components/Auth/AuthLayout/AuthLayout.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { CaretLeft } from '@phosphor-icons/react';
import { CaretLeft, X } from '@phosphor-icons/react';

import { Box, Card, Button } from '../../../ui-kit';
import customizations from './customizations';
Expand Down Expand Up @@ -47,7 +47,19 @@ function AuthLayout(props = {}) {
flexDirection="row-reverse"
icon={<CaretLeft />}
/>
) : null}
) : (
<Button
variant="link"
title="Close"
onClick={props.onClose}
alignSelf="flex-end"
color="text.action"
alignItems="center"
display="flex"
flexDirection="row-reverse"
icon={<X />}
/>
)}
Comment on lines +50 to +62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<Heading>{props.heading || customizations.defaulthHeading}</Heading>
<SubHeading>{props.subHeading || customizations.defaultSubHeading}</SubHeading>
{props.children}
Expand Down
12 changes: 6 additions & 6 deletions packages/web-shared/components/Auth/AuthManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ function AuthManager(props = {}) {
const render = () => {
switch (step) {
case authSteps.Welcome: {
return <Welcome />;
return <Welcome {...props} />;
}
case authSteps.Identity: {
return <Identity />;
return <Identity {...props} />;
}
case authSteps.Details: {
return <Details />;
return <Details {...props} />;
}
case authSteps.Merge: {
return <Merge />;
return <Merge {...props} />;
}
case authSteps.Confirm: {
return <Confirm />;
return <Confirm {...props} />;
}
case authSteps.Success: {
return null;
}
default: {
return <Welcome />;
return <Welcome {...props} />;
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions packages/web-shared/components/Auth/AuthWelcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { Box, Button } from '../../ui-kit';
import AuthLayout from './AuthLayout';
import steps from './authSteps';

const AuthWelcome = () => {
const AuthWelcome = (props) => {
const [state, dispatch] = useAuth();

const handleSubmit = async ({ step, type }) => {
dispatch(updateAuth({ step, type }));
};

return (
<AuthLayout>
<AuthLayout {...props}>
<Box flexDirection="row">
<Button
mr="base"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-shared/components/Profile/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ const Profile = ({ theme, handleCloseProfile, ...rest }) => {
) : null}
</Styled.ProfileCard>
</Styled.Profile>
{showAuth && state.step !== authSteps.Success ? <AuthManager /> : null}
{showAuth && state.step !== authSteps.Success ? (
<AuthManager onClose={() => setShowAuth(false)} />
) : null}
</>
);
};
Expand Down