Skip to content
Open
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
115 changes: 50 additions & 65 deletions apps/frontend/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,17 @@ import AdminDonation from '@containers/adminDonation';
import { pantryIdLoader } from '@loaders/pantryIdLoader';
import Homepage from '@containers/homepage';
import AdminOrderManagement from '@containers/adminOrderManagement';
import '@aws-amplify/ui-react/styles.css';
import { Authenticator } from '@aws-amplify/ui-react';
Comment on lines -24 to -25
Copy link
Member

Choose a reason for hiding this comment

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

there are still some routes that use authenticator, and that's causing an error for me without this

import { Amplify } from 'aws-amplify';
import CognitoAuthConfig from './aws-exports';
import LoginPage from '@containers/loginPage';
import SignupPage from '@containers/signupPage';
import ForgotPasswordPage from '@containers/forgotPasswordPage';
import ProtectedRoute from '@components/protectedRoute';
import { Button } from '@chakra-ui/react';
import Unauthorized from '@containers/unauthorized';

Amplify.configure(CognitoAuthConfig);

const components = {
Copy link
Member

Choose a reason for hiding this comment

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

same with this for the routes that still use authenticator

SignUp: {
Footer() {
return (
<>
<Button as="a" href="/pantry-application">
{' '}
Sign up to be pantry partner{' '}
</Button>
<Button> Log donation for one-time donors </Button>
</>
);
},
},

SignIn: {
Footer() {
return (
<>
<Button as="a" href="/pantry-application">
{' '}
Sign up to be pantry partner{' '}
</Button>
<Button> Log donation for one-time donors </Button>
</>
);
},
},
};

const router = createBrowserRouter([
{
path: '/',
Expand All @@ -75,6 +47,18 @@ const router = createBrowserRouter([
path: '/landing-page',
element: <LandingPage />,
},
{
path: '/login',
element: <LoginPage />,
},
{
path: '/signup',
element: <SignupPage />,
},
{
path: '/forgot-password',
element: <ForgotPasswordPage />,
},
{
path: '/pantry-application',
element: <PantryApplication />,
Expand All @@ -92,17 +76,17 @@ const router = createBrowserRouter([
{
path: '/pantry-overview',
element: (
<Authenticator components={components}>
<ProtectedRoute>
<PantryOverview />
</Authenticator>
</ProtectedRoute>
),
},
{
path: '/pantry-dashboard/:pantryId',
element: (
<Authenticator components={components}>
<ProtectedRoute>

Choose a reason for hiding this comment

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

Note for later: The pantry id loader I think makes u navigate to a 404 error instead (while still navigating to request-form/1). I think my role based auth backend may have fixed this, but once this get's merged in we should check to see if it still works. If not, we may need to adjust how the ProtectedRoute and loader interact with each other.

Copy link
Author

Choose a reason for hiding this comment

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

Ok sounds good!

<PantryDashboard />
</Authenticator>
</ProtectedRoute>
),
},
{
Expand Down Expand Up @@ -141,82 +125,82 @@ const router = createBrowserRouter([
{
path: '/pantry-past-orders',
element: (
<Authenticator components={components}>
<ProtectedRoute>
<PantryPastOrders />
</Authenticator>
</ProtectedRoute>
),
},
{
path: '/pantries',
element: (
<Authenticator components={components}>
<ProtectedRoute>
<Pantries />
</Authenticator>
</ProtectedRoute>
),
},
{
path: '/food-manufacturer-order-dashboard',
element: (
<Authenticator components={components}>
<ProtectedRoute>
<FoodManufacturerOrderDashboard />
</Authenticator>
</ProtectedRoute>
),
},
{
path: '/orders',
element: (
<Authenticator components={components}>
<ProtectedRoute>
<Orders />
</Authenticator>
</ProtectedRoute>
),
},
{
path: '/request-form/:pantryId',
element: (
<Authenticator components={components}>
<ProtectedRoute>
<FormRequests />
</Authenticator>
</ProtectedRoute>
),
loader: pantryIdLoader,
},
{
path: '/approve-pantries',
path: '/donation-mangement',
element: (
<Authenticator components={components}>
<ApprovePantries />
</Authenticator>
<ProtectedRoute>
<DonationManagement />
</ProtectedRoute>
),
},
{
path: '/donation-management',
path: '/approve-pantries',
element: (
<Authenticator components={components}>
<DonationManagement />
</Authenticator>
<ProtectedRoute>
<ApprovePantries />
</ProtectedRoute>
),
},
{
path: '/admin-donation',
element: (
<Authenticator components={components}>
<ProtectedRoute>
<AdminDonation />
</Authenticator>
</ProtectedRoute>
),
},
{
path: '/volunteer-management',
element: (
<Authenticator components={components}>
<ProtectedRoute>
<VolunteerManagement />
</Authenticator>
</ProtectedRoute>
),
},
{
path: '/admin-order-management',
element: (
<Authenticator components={components}>
<ProtectedRoute>
<AdminOrderManagement />
</Authenticator>
</ProtectedRoute>
),
},
// Actions
Expand All @@ -233,11 +217,12 @@ const router = createBrowserRouter([
]);

export const App: React.FC = () => {
return (
<Authenticator.Provider>
<RouterProvider router={router} />
</Authenticator.Provider>
);
useEffect(() => {
document.title = 'SSF';
apiClient.getHello().then((res) => console.log(res));
}, []);

return <RouterProvider router={router} />;
};

export default App;
Binary file added apps/frontend/src/assets/login_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading