@@ -2,9 +2,21 @@ module.exports = router => {
22
33 router . get ( '/regions/v1' , ( req , res ) => {
44 const data = req . session . data
5- const organisations = data . organisations . filter ( ( organisation ) => organisation . region === "Y61" )
5+ const organisations = data . organisations . filter ( ( organisation ) => ( organisation . region === "Y61" ) && ( organisation . status != "Closed" ) )
6+
7+ const closedOrganisationsCount = data . organisations . filter ( ( organisation ) => ( organisation . region === "Y61" && organisation . status == "Closed" ) ) . length
68
79 res . render ( 'regions/v1/index' , {
10+ organisations,
11+ closedOrganisationsCount
12+ } )
13+ } )
14+
15+ router . get ( '/regions/v1/organisations/closed' , ( req , res ) => {
16+ const data = req . session . data
17+ const organisations = data . organisations . filter ( ( organisation ) => ( organisation . region === "Y61" && organisation . status == "Closed" ) )
18+
19+ res . render ( 'regions/v1/closed-organisations' , {
820 organisations
921 } )
1022 } )
@@ -257,6 +269,49 @@ module.exports = router => {
257269 } )
258270 } )
259271
272+ // Deactivate an organisation
273+ router . get ( '/regions/v1/organisations/:id/deactivate' , ( req , res ) => {
274+ const data = req . session . data
275+ const organisation = data . organisations . find ( ( org ) => org . id === req . params . id )
276+ if ( ! organisation ) { res . redirect ( '/regions/v1/' ) ; return }
277+
278+ res . render ( 'regions/v1/deactivate' , {
279+ organisation
280+ } )
281+ } )
282+
283+ // Deactivating an organisation
284+ router . post ( '/regions/v1/organisations/:id/deactivated' , ( req , res ) => {
285+ const organisation = req . session . data . organisations . find ( ( org ) => org . id === req . params . id )
286+ if ( ! organisation ) { res . redirect ( '/regions/v1/' ) ; return }
287+
288+ organisation . status = "Deactivated"
289+
290+ res . redirect ( '/regions/v1/organisations/' + organisation . id )
291+ } )
292+
293+ // Reactivate an organisation
294+ router . get ( '/regions/v1/organisations/:id/reactivate' , ( req , res ) => {
295+ const data = req . session . data
296+ const organisation = data . organisations . find ( ( org ) => org . id === req . params . id )
297+ if ( ! organisation ) { res . redirect ( '/regions/v1/' ) ; return }
298+
299+ res . render ( 'regions/v1/reactivate' , {
300+ organisation
301+ } )
302+ } )
303+
304+ // Reactivating an organisation
305+ router . post ( '/regions/v1/organisations/:id/reactivated' , ( req , res ) => {
306+ const organisation = req . session . data . organisations . find ( ( org ) => org . id === req . params . id )
307+ if ( ! organisation ) { res . redirect ( '/regions/v1/' ) ; return }
308+
309+ organisation . status = "Active"
310+
311+ res . redirect ( '/regions/v1/organisations/' + organisation . id )
312+ } )
313+
314+
260315 // Check a second lead user for an organisation
261316 router . get ( '/regions/v1/organisations/:id/add-email-check' , ( req , res ) => {
262317 const data = req . session . data
0 commit comments