Last active
November 10, 2021 18:10
-
-
Save umutyerebakmaz/de46942b0a56efff9dd45194947e39f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sorumluluk Alanımdakiler | |
/** | |
* Daire Başkanı - county ve neighborhood filtrelemesi olmamalı | |
* Şube Müdürü - county ve neighborhood filtrelemesi olmamalı | |
* Şef - county ve neighborhood filtrelemesi olmamalı | |
* Mesul Müdür - county ve neighborhood filtrelemesi olmamalı | |
* | |
* Bölge Sorumlusu - county filtrelemesi olmalı | |
* | |
* Ekip Sorumlusu - neighborhood filtrelemesi olmalı | |
* Şoför, Uygulayıcı - neighborhood filtrelemesi olmalı | |
*/ | |
requestsByArea(): void { | |
console.log('requestsByArea'); | |
const noFilter = ['Daire Başkanı', 'Şube Müdürü', 'Şef', 'Mesul Müdür']; | |
const mustHaveCountyFilter = ['Bölge Sorumlusu', 'Admin']; | |
const mustHaveNeighborhoodFilter = ['Ekip Sorumlusu', 'Şoför', 'Uygulayıcı']; | |
// 1. Daire Başkanı, Şube Müdürü, Şef, Mesul Müdür ise county ve neighborhood filtresi yok | |
if(this.me.roles.map(role => role.title).some(role => noFilter.includes(role))) { | |
console.log(noFilter, this.me.roles); | |
} | |
if (this.me.roles.map(role => role.title).some(role => mustHaveCountyFilter.includes(role))) { | |
console.log(mustHaveCountyFilter, this.me.roles); | |
} | |
if (this.me.roles.map(role => role.title).some(role => mustHaveNeighborhoodFilter.includes(role))) { | |
console.log(mustHaveNeighborhoodFilter, this.me.roles); | |
} | |
// 2. Bölge Sorumlusu ise county filtresi olmalı | |
if (this.me.counties.length !== 0) { | |
this.requestFilterInput.countyList = this.me.counties.map(county => county.id); | |
delete this.requestFilterInput.userId; | |
} | |
// 3. Ekip Sorumlusu ise neighborhood filtresi olmalı | |
if (this.me.neighborhoods.length !== 0) { | |
this.requestFilterInput.neighborhoodList = this.me.neighborhoods.map(neighborhood => neighborhood.id); | |
delete this.requestFilterInput.userId; | |
} | |
this.requestFilter(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment