Skip to content

Commit

Permalink
removing comment and updating endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
maayarosama committed Feb 8, 2024
1 parent 9c6c885 commit 62ef620
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 56 deletions.
5 changes: 0 additions & 5 deletions client/src/clients/api/office.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export class OfficeApi extends ApiClientBase {
transform: (d) => d.results
})
}

async listSupervisor(id: number, query?: Api.Inputs.List) {
ApiClientBase.assertUser()
return this.unwrap(() => this.$http.get<Api.Returns.List<Api.User>>(this.getUrl(`/${id}/supervisor`, query)))
}
async update(id: number) {}

async delete(id: number) {}
Expand Down
11 changes: 11 additions & 0 deletions client/src/clients/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class UsersApi extends ApiClientBase {
readonly set_inactive: UsersSetInActiveApi
readonly skills: UsersSkillsApi
readonly team: UsersTeamApi
readonly supervisors: UsersSupervisorsApi

constructor(options: Api.ClientOptions) {
super(options)
Expand All @@ -20,6 +21,7 @@ export class UsersApi extends ApiClientBase {
this.set_inactive = new UsersSetInActiveApi(options, this.path)
this.skills = new UsersSkillsApi(options, this.path)
this.team = new UsersTeamApi(options, this.path)
this.supervisors = new UsersSupervisorsApi(options, this.path)
}

list(query?: any) {
Expand Down Expand Up @@ -115,6 +117,15 @@ class UsersSkillsApi extends ApiClientBase {
}
}

class UsersSupervisorsApi extends ApiClientBase {
protected readonly path = '/supervisors'

async list( query?: Api.Inputs.List) {
ApiClientBase.assertUser()
return this.unwrap(() => this.$http.get<Api.Returns.List<Api.User>>(this.getUrl("", query)))
}
}

class UsersTeamApi extends ApiClientBase {
protected readonly path = '/team'

Expand Down
37 changes: 1 addition & 36 deletions client/src/components/AddUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
</VContainer>
</template>
</v-select>

<!-- <v-select v-model="selectedSupervisor" :items="supervisors" item-title="full_name" item-value="id"
label="Team Lead" return-object density="comfortable"></v-select> -->

</v-col>
<v-col cols="12">
<v-file-input v-model="imageInput" label="Image" variant="filled" accept="image/*" :show-size="1024"
Expand Down Expand Up @@ -136,8 +132,6 @@ export default {
const imageUrl = ref()
const supervisorPage = ref(1)
const supervisorCount = ref(0)
const loggedUser = ApiClientBase.user
const officeId = ref()
const user = computed(() => ({
first_name: first_name.value,
last_name: last_name.value,
Expand All @@ -160,15 +154,11 @@ export default {
async function listSupervisors() {
const res = await $api.users.admin.list({ page: supervisorPage.value })
// const res = await $api.office.listSupervisor(officeId.value,{ page: supervisorPage.value })
const res = await $api.users.supervisors.list({ page: supervisorPage.value })
if (res.count) {
supervisorCount.value = Math.ceil(res.count / 10)
res.results.forEach((user: any) => {
// if( user.user_type === 'Supervisor'){
supervisors.value.push(user)
// }
})
} else {
supervisorCount.value = 0
Expand All @@ -193,32 +183,7 @@ export default {
}))
location.value = offices.value[0]
officeId.value = loggedUser.value?.fullUser.location.id
await listSupervisors()
// const res = await $api.users.admin.list({ page: supervisorPage.value })
// if (res.count > 10) {
// supervisorCount.value = Math.ceil(res.count / 10)
// for (let i = 1; i <= supervisorCount.value - 1; i++) {
// const res = await $api.users.admin.list({ page: supervisorPage.value++ })
// if (res.results) {
// let supervisorsArr: []
// supervisorsArr = (res.results as any).filter(
// (supervisor: any) => supervisor.user_type === 'Supervisor'
// )
// for (let supervisor of supervisorsArr) {
// supervisors.value.push(supervisor)
// }
// }
// }
// } else {
// supervisors.value = (res.results as any).filter(
// (supervisor: any) => supervisor.user_type === 'Supervisor'
// )
// }
selectedSupervisor.value = supervisors.value[0]
} catch (error) {
console.error(error);
Expand Down
17 changes: 2 additions & 15 deletions client/src/components/UpdateUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
</VContainer>
</template>
</v-select>


<v-select v-model="reporting_to" :items="supervisors" item-title="full_name" item-value="id" label="Team Lead"
return-object density="comfortable" :rules="requiredRules">

Expand Down Expand Up @@ -141,9 +139,6 @@ export default {
const offices = ref([])
const supervisors = ref<any[]>([])
const image = ref()
const user = ApiClientBase.user
const officeId = ref()
const imageUrl = ref()
const selectedUser = ref()
const reporting_to = ref()
Expand Down Expand Up @@ -185,15 +180,11 @@ export default {
}
async function listSupervisors() {
const res = await $api.users.admin.list({ page: supervisorPage.value })
// const res = await $api.office.listSupervisor(officeId.value,{ page: supervisorPage.value })
const res = await $api.users.supervisors.list({ page: supervisorPage.value })
if (res.count) {
supervisorCount.value = Math.ceil(res.count / 10)
res.results.forEach((user: any) => {
// if( user.user_type === 'Supervisor'){
supervisors.value.push(user)
// }
})
} else {
supervisorCount.value = 0
Expand All @@ -208,13 +199,10 @@ export default {
id: office.id,
name: office.name
}))
officeId.value = user.value?.fullUser.location.id
await listUsers()
selectedUser.value = officeUsers.value[0]
reporting_to.value = selectedUser.value.reporting_to[0]
await listSupervisors()
reporting_to.value = selectedUser.value?.reporting_to[0]
} catch (error) {
console.error(error)
Expand Down Expand Up @@ -254,7 +242,6 @@ export default {
await $api.users.set_active.update({ user_id: selectedUser.value.id })
}
isLoading.value = false
},
null,
{ immediate: false }
Expand Down

0 comments on commit 62ef620

Please sign in to comment.