hcs-t4sg / questable

questable.vercel.app
2 stars 0 forks source link

Teacher Inventory #74

Closed IsoPhoenix closed 1 year ago

IsoPhoenix commented 1 year ago

Teacher Inventory

Overview

Add an inventory page for teachers, where teacher has access to every item and can equip as they please

Details

The easiest + best way to do this is refactoring existing code from inventory.

  1. Refactor Inventory.tsx into a subcomponent InventoryDisplay that accepts player, classroom, and inventoryObjects props where inventoryObjects is the same as in the current implementation. It will keep the value state variable, but everything from line 48 (inventoryItems state variable) to the beginning of the return statement will be factored out into a separate component.
  2. Create a new component called InventoryStudent that contains all the code factored out from Inventory. Like in the original Inventory, this will handle the fetching of student inventory and constructing the inventoryObjects list. This component should return InventoryDisplay with inventoryObjects passed in.
    • You will have to update routing in StudentView.tsx to this line: <Route path='inventory' element={<InventoryStudent player={player} classroom={classroom} />} />
  3. Create a new component called InventoryTeacher. This will generate the inventoryObjects list using various get___Items() functions (see implementation in Shop.tsx) to get all possible items, then pass this into InventoryDisplay to be returned.
    • You will want to add a new route to TeacherView: <Route path='inventory' element={<InventoryTeacher player={player} classroom={classroom} />} />
    • Also update listItems.tsx with a new navbar item that links to the inventory route.