@@ -3,11 +3,11 @@ module.exports = router => {
33 router . get ( '/regions' , ( req , res ) => {
44 const data = req . session . data
55
6- const currentRegion = res . locals . currentOrganisation
6+ const currentOrganisation = res . locals . currentOrganisation
77
8- const organisations = data . organisations . filter ( ( organisation ) => ( organisation . region === currentRegion . id ) && ( [ "Active" , "Invited" , "Deactivated" ] . includes ( organisation . status ) ) )
8+ const organisations = data . organisations . filter ( ( organisation ) => ( organisation . region === currentOrganisation . id ) && ( [ "Active" , "Invited" , "Deactivated" ] . includes ( organisation . status ) ) )
99
10- const closedOrganisationsCount = data . organisations . filter ( ( organisation ) => ( organisation . region === currentRegion . id && organisation . status == "Closed" ) ) . length
10+ const closedOrganisationsCount = data . organisations . filter ( ( organisation ) => ( organisation . region === currentOrganisation . id && organisation . status == "Closed" ) ) . length
1111
1212 res . render ( 'regions/index' , {
1313 organisations,
@@ -16,10 +16,10 @@ module.exports = router => {
1616 } )
1717
1818 router . get ( '/regions/organisations/closed' , ( req , res ) => {
19- const currentRegion = res . locals . currentOrganisation
19+ const currentOrganisation = res . locals . currentOrganisation
2020
2121 const data = req . session . data
22- const organisations = data . organisations . filter ( ( organisation ) => ( organisation . region === currentRegion . id && organisation . status == "Closed" ) )
22+ const organisations = data . organisations . filter ( ( organisation ) => ( organisation . region === currentOrganisation . id && organisation . status == "Closed" ) )
2323
2424 res . render ( 'regions/closed-organisations' , {
2525 organisations
@@ -47,7 +47,7 @@ module.exports = router => {
4747 // Inviting an organisation
4848 router . post ( '/regions/add' , ( req , res ) => {
4949 const data = req . session . data
50- const currentRegion = res . locals . currentOrganisation
50+ const currentOrganisation = res . locals . currentOrganisation
5151
5252 const organisationId = data . organisationId
5353 const organisation = data . allOrganisations . find ( ( org ) => org . id === organisationId )
@@ -61,7 +61,7 @@ module.exports = router => {
6161 address : organisation . address ,
6262 type : organisation . type ,
6363 status : 'Invited' ,
64- region : currentRegion . id
64+ region : currentOrganisation . id
6565 } )
6666
6767 req . session . data . users . push ( {
@@ -163,7 +163,7 @@ module.exports = router => {
163163 const vaccines = organisation . vaccines || [ ]
164164 const vaccinesEnabled = vaccines . filter ( ( vaccine ) => vaccine . status === "enabled" )
165165
166- const messages = res . locals . currentOrganisation . inbox . filter ( ( message ) => message . fromOrganisationId === id )
166+ const messages = ( res . locals . currentOrganisation . inbox || [ ] ) . filter ( ( message ) => message . fromOrganisationId === id )
167167
168168 res . render ( 'regions/organisation' , {
169169 organisation,
0 commit comments