Skip to content

Conversation

@Juwang110
Copy link

ℹ️ Issue

Closes: Pantry Dashboard View, Get SSF contact name for pantry

📝 Description

Write a short summary of what you added. Why is it important? Any member of C4C should be able to read this and understand your contribution -- not just your team members.

I added a page for the pantry dashboard which includes a get request to display a welcome message to the current pantry based on the pantry's id. This dashboard includes a menu dropdown to navigate to profile (no functionality), sign out (no functionality), or navigate to request form page. The page also includes a need help? message and displays the pantry's associated SSF representative's contact details via a get request. A button is also present to navigate to request form page. This is important for pantries to have a hub when they enter the website.

I also added backend support for pantries (module, entity, controller, service) and the appropriate controller routes and services.

Finally, I abstracted out defined interfaces of User and Pantry into a new types folder in the frontend/src folder to deduplicate code if these interfaces are needed elsewhere.

Briefly list the changes made to the code:

  1. Added pantry dashboard page
  2. Added backend support for pantries
  3. Added a types folder to deduplicate interface code

✔️ Verification

There weren't many steps to verify this particular ticket. I simply checked if the frontend looked good and all the routes in the menu/button worked as intended. To verify the get request I simply made a pantry and user that were linked to each other and observed the dashboard to see if the text matched the database data.

Screenshot 2025-01-30 120438
Screenshot 2025-01-30 120453

🏕️ (Optional) Future Work / Notes

  1. Set pantry ID to default value of 1 for both get request and navigation
  2. Sign out navigates to landing page as well as profile since there is no functionality for these options yet
  3. Added a types.ts and types folder to reduce duplicate code for data types from table like User, Pantry, etc.
  4. In the future: need to implement proper pantryID and replace default 1 value, also fix the routes to profile/sign out once those components are made.

constructor(private pantriesService: PantriesService) {}

@Get('/:pantryId/ssf-contact')
async getUser(

Choose a reason for hiding this comment

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

nit: maybe change the function name to getSSFRep here instead of getUser

Copy link
Author

Choose a reason for hiding this comment

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

fixed

referencedColumnName: 'user_id',
})
pantryRepresentative: User;
}

Choose a reason for hiding this comment

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

I think we added some new fields to pantries after (activities, questions, items_in_stock, and need_more_options) to correspond with questions 15-18 on pantry sign-up form; we might need to pull new code to see them

Screenshot 2025-02-05 at 11 02 25 PM

Copy link
Author

Choose a reason for hiding this comment

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

fixed

export class PantriesService {
constructor(@InjectRepository(Pantry) private repo: Repository<Pantry>) {}

findOne(pantryId: number) {

Choose a reason for hiding this comment

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

we can make findOne an async function too and add the type -->
async findOne(pantryId: number): Promise<Pantry | null> {....

Copy link
Author

Choose a reason for hiding this comment

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

fixed

return null;
}

return this.repo.findOneBy({ pantryId });

Choose a reason for hiding this comment

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

we can add await here when we change findOne to async

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Request new shipment or check shipment status
</Button>
</VStack>
;

Choose a reason for hiding this comment

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

nit: we can remove the stray ; in line 178

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@@ -0,0 +1,27 @@
export interface User {
id: number;

Choose a reason for hiding this comment

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

nit: userId instead of id

Copy link
Author

Choose a reason for hiding this comment

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

fixed

restrictions: string[];
ssfRepresentativeId: number;
pantryRepresentativeId: number;
}

Choose a reason for hiding this comment

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

we can add

activities: string;
questions: string;
itemsInStock: string;
needMoreOptions: string;

to the interface as well

Copy link
Author

Choose a reason for hiding this comment

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

fixed

const [ssfRep, setSsfRep] = useState<User | null>(null);
const [pantry, setPantry] = useState<Pantry | null>(null);

const getSSFRep = async (pantryId: number): Promise<User | null> => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we move the functionality for getSSFRep and getPantry into apps/frontend/src/api/apiClient.ts to separate out the API call logic from the component? We might be able to use some of the existing functions in that file too to simplify the logic.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Copy link

@fanzzz368 fanzzz368 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

@dburkhart07 dburkhart07 left a comment

Choose a reason for hiding this comment

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

Aside from those 2 changes everything looks good

})
phone: string;

get id(): number {

Choose a reason for hiding this comment

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

Sorry if this is wrong (and if so it can be ignored), but is this 'get' necessary when we have the one in the controller? That one has authentication but I have just been disabling it for now. While not completely necessary, could consider doing that instead.

element: <PantryOverview />,
},
{
path: '/pantry-dashboard',

Choose a reason for hiding this comment

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

Consider using the id here to make it more modular now rather than having the id assigned in the component. We could have it just be coded to '/pantry-dashboard/:pantryId', and then pass it in as a parameter so, when we get more pantries, it is easy to refactor.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@Juwang110 Juwang110 merged commit 9bb10a2 into main Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants