Skip to content
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
4 changes: 2 additions & 2 deletions apps/ui-admin/src/app.container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const AppContainer: FC = () => {
});

if (!auth.isAuthenticated) {
return <App isAuthenticated={false} />;
return <App />;
}

const user = data?.currentAdminUser;
Expand All @@ -26,7 +26,7 @@ export const AppContainer: FC = () => {
error={error}
hasDataComponent={
<UserIdProvider userId={userId}>
<App isAuthenticated={auth.isAuthenticated} />
<App />
</UserIdProvider>
}
/>
Expand Down
17 changes: 10 additions & 7 deletions apps/ui-admin/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@ import { RequireAuth } from '@sthrift/ui-admin-route-shared';
import { UserOperationsRoutes } from '@sthrift/ui-admin-route-user-operations';
import type React from 'react';

const appSection = (
<RequireAuth redirectPath="/login">
<AppRoutes />
</RequireAuth>
);

const listingOperationsSection = (
<RequireAuth redirectPath="/">
<RequireAuth redirectPath="/login">
<ListingOperationsRoutes />
</RequireAuth>
);

const userOperationsSection = (
<RequireAuth redirectPath="/">
<RequireAuth redirectPath="/login">
<UserOperationsRoutes />
</RequireAuth>
);

interface AppProps {
isAuthenticated: boolean;
}
export const App: React.FC<AppProps> = () => {
export const App: React.FC = () => {
return (
<Routes>
<Route path="/*" element={<AppRoutes />} />
<Route path="/*" element={appSection} />
<Route path="/login" element={<AdminLogin />} />
<Route path="/auth-redirect" element={<AuthRedirect />} />
<Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export const SectionLayout: React.FC = () => {
return () => window.removeEventListener('resize', handleResize);
}, [auth.isAuthenticated]);

const handleOnLogin = () => {
navigate('/login');
};

const handleLogOut = () => {
HandleLogout(auth, apolloClient, window.location.origin);
};
Expand Down Expand Up @@ -93,7 +89,6 @@ export const SectionLayout: React.FC = () => {
>
<AdminHeader
isAuthenticated={auth.isAuthenticated}
onLogin={handleOnLogin}
onLogout={handleLogOut}
/>
<div
Expand Down
11 changes: 2 additions & 9 deletions packages/sthrift/ui-admin-route-root/src/admin-login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const AdminLogin: React.FC = () => {
const [submitting, setSubmitting] = useState(false);
const navigate = useNavigate();
const auth = useAuth();
const handleBack = () => undefined;

const handleLogin = (_values: LoginFormData) => {
setSubmitting(true);
Expand All @@ -23,25 +24,17 @@ export const AdminLogin: React.FC = () => {
}
};

const handleBack = () => {
navigate('/');
};

const handleOnLogin = () => {
globalThis.location.href = '/auth-redirect';
};

return (
<LoginForm
title="Admin Log In"
emailPlaceholder="admin@sharethrift.com"
onSubmit={handleLogin}
submitting={submitting}
onBack={handleBack}
showBack={false}
headerSlot={
<AdminHeader
isAuthenticated={auth.isAuthenticated}
onLogin={handleOnLogin}
onLogout={() => navigate('/')}
/>
}
Expand Down
10 changes: 1 addition & 9 deletions packages/sthrift/ui-admin-route-root/src/app-routes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Route, Routes } from 'react-router-dom';
import { RequireAuth } from '@sthrift/ui-admin-route-shared';
import { SectionLayout } from './section-layout.tsx';
import { Listings } from './components/pages/home/pages/all-listings-page.tsx';
import { ViewListing } from './components/pages/view-listing/pages/view-listing-page.tsx';
Expand All @@ -11,14 +10,7 @@ export const AppRoutes: React.FC = () => {
<Route path="" element={<SectionLayout />}>
<Route path="" element={<Listings />} />
<Route path="listing/:listingId" element={<ViewListing />} />
<Route
path="messages/*"
element={
<RequireAuth redirectPath="/">
<MessagesRoutes />
</RequireAuth>
}
/>
<Route path="messages/*" element={<MessagesRoutes />} />
</Route>
</Routes>
);
Expand Down
5 changes: 0 additions & 5 deletions packages/sthrift/ui-admin-route-root/src/section-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export const SectionLayout: React.FC = () => {
return () => window.removeEventListener('resize', handleResize);
}, [auth.isAuthenticated]);

const handleOnLogin = () => {
navigate('/login');
};

const handleLogOut = () => {
HandleLogout(auth, apolloClient, window.location.origin);
};
Expand Down Expand Up @@ -93,7 +89,6 @@ export const SectionLayout: React.FC = () => {
>
<AdminHeader
isAuthenticated={auth.isAuthenticated}
onLogin={handleOnLogin}
onLogout={handleLogOut}
/>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@

.brandName {
font-family: var(--Urbanist);
font-size: 1.1rem;
font-size: 24px;
font-weight: 700;
line-height: 32px;
letter-spacing: 0.02em;
color: var(--color-message-text);
color: var(--color-primary);
text-transform: lowercase;
}

Expand Down Expand Up @@ -87,7 +88,7 @@
}

.brandName {
font-size: 1rem;
font-size: 20px;
}

.portalPill {
Expand Down
12 changes: 1 addition & 11 deletions packages/sthrift/ui-admin-route-shared/src/admin-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import styles from './admin-header.module.css';

interface AdminHeaderProps {
isAuthenticated: boolean;
onLogin?: () => void;
onLogout?: () => void;
}

const { Header: AntHeader } = Layout;

export const AdminHeader: React.FC<AdminHeaderProps> = ({
isAuthenticated,
onLogin,
onLogout,
}) => {
return (
Expand All @@ -35,15 +33,7 @@ export const AdminHeader: React.FC<AdminHeaderProps> = ({
>
Log Out
</Button>
) : (
<Button
type="link"
className={styles['authButton']}
onClick={onLogin}
>
Log In
</Button>
)}
) : null}
</nav>
</AntHeader>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export const SectionLayout: React.FC = () => {
return () => window.removeEventListener('resize', handleResize);
}, [auth.isAuthenticated]);

const handleOnLogin = () => {
navigate('/login');
};

const handleLogOut = () => {
HandleLogout(auth, apolloClient, window.location.origin);
};
Expand Down Expand Up @@ -93,7 +89,6 @@ export const SectionLayout: React.FC = () => {
>
<AdminHeader
isAuthenticated={auth.isAuthenticated}
onLogin={handleOnLogin}
onLogout={handleLogOut}
/>
<div
Expand Down
25 changes: 17 additions & 8 deletions packages/sthrift/ui-shared/src/organisms/login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface LoginFormProps {
onBack: () => void;
headerSlot: React.ReactNode;
footerSlot?: React.ReactNode;
showBack?: boolean;
showForgotPassword?: boolean;
onForgotPassword?: () => void;
}
Expand All @@ -30,6 +31,7 @@ export const LoginForm: React.FC<LoginFormProps> = ({
onBack,
headerSlot,
footerSlot,
showBack = true,
showForgotPassword,
onForgotPassword,
}) => {
Expand Down Expand Up @@ -166,17 +168,24 @@ export const LoginForm: React.FC<LoginFormProps> = ({
<div
style={{
display: 'flex',
justifyContent: showForgotPassword ? 'space-between' : 'flex-start',
justifyContent:
showBack && showForgotPassword
? 'space-between'
: showBack
? 'flex-start'
: 'flex-end',
marginTop: '1rem',
}}
>
<Button
type="link"
onClick={onBack}
style={{ padding: 0 }}
>
← Back to Home
</Button>
{showBack && (
<Button
type="link"
onClick={onBack}
style={{ padding: 0 }}
>
← Back to Home
</Button>
)}
{showForgotPassword && onForgotPassword && (
<Button
type="link"
Expand Down
Loading