-
Couldn't load subscription status.
- Fork 0
Pantry dashboard #24
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
Pantry dashboard #24
Conversation
| constructor(private pantriesService: PantriesService) {} | ||
|
|
||
| @Get('/:pantryId/ssf-contact') | ||
| async getUser( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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> {....
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> | ||
| ; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
apps/frontend/src/types/types.ts
Outdated
| @@ -0,0 +1,27 @@ | |||
| export interface User { | |||
| id: number; | |||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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.
apps/frontend/src/app.tsx
Outdated
| element: <PantryOverview />, | ||
| }, | ||
| { | ||
| path: '/pantry-dashboard', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed

ℹ️ 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:
✔️ 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.
🏕️ (Optional) Future Work / Notes