Skip to content

Commit 32d4908

Browse files
committed
feat: améliorer la gestion des identités en typant les données et en corrigeant les références nulles
1 parent 28e0a58 commit 32d4908

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

apps/web/src/pages/identities/outdated.vue

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ q-page.container
3939
<script lang="ts">
4040
import { get } from 'radash'
4141
import updateInitModale from '~/components/pages/identities/modals/update-init.vue'
42+
import type { components } from '#build/types/service-api'
43+
44+
type Identities = components['schemas']['IdentitiesDto']
4245
4346
export default defineNuxtComponent({
4447
name: 'IdentitiesOutdatedPage',
4548
data() {
4649
return {
47-
selected: [] as Array<string>,
50+
selected: [] as Array<Identities>,
4851
columns: [] as Array<any>,
4952
visibleColumns: [] as Array<string>,
5053
}
@@ -55,7 +58,7 @@ export default defineNuxtComponent({
5558
pending,
5659
error,
5760
refresh,
58-
} = await useHttp('/management/passwd/ioutdated', {
61+
} = await useHttp<{ total: number; data: Identities[] }>('/management/passwd/ioutdated', {
5962
method: 'GET',
6063
})
6164
@@ -74,16 +77,15 @@ export default defineNuxtComponent({
7477
componentProps: {
7578
selectedIdentities: this.selected,
7679
identityTypesName: name,
77-
allIdentitiesCount: this.outdateds.total,
80+
allIdentitiesCount: this.outdateds?.total || 0,
7881
},
7982
})
8083
.onOk(async (data) => {
81-
// console.log('initIdentities', data)
8284
data.initAllIdentities ? await this.sendInitToAllIdentities() : await this.sendInitToIdentity(this.selected)
8385
})
8486
},
85-
async sendInitToIdentity(identities) {
86-
const ids = identities.map((identity) => identity._id)
87+
async sendInitToIdentity(identities: Identities[]) {
88+
const ids = identities.map((identity) => (identity as any)._id)
8789
const { data, error } = await useHttp(`/management/passwd/initmany`, {
8890
method: 'post',
8991
body: {
@@ -108,7 +110,7 @@ export default defineNuxtComponent({
108110
},
109111
110112
async sendInitToAllIdentities() {
111-
const { data: identities } = await useHttp('/management/passwd/ioutdated', {
113+
const { data: identities } = await useHttp<{ total: number; data: Identities[] }>('/management/passwd/ioutdated', {
112114
method: 'get',
113115
})
114116
@@ -119,7 +121,7 @@ export default defineNuxtComponent({
119121
})
120122
return
121123
}
122-
this.sendInitToIdentity(identities.data)
124+
this.sendInitToIdentity(identities.value?.data || [])
123125
},
124126
},
125127
async mounted() {
@@ -128,10 +130,6 @@ export default defineNuxtComponent({
128130
method: 'GET',
129131
})
130132
131-
// Réinitialiser les colonnes pour éviter la boucle
132-
// this.visibleColumns.splice(0, this.visibleColumns.length)
133-
// this.columns.splice(0, this.columns.length)
134-
135133
for (const scheme in res._data.data) {
136134
const enr = res._data.data[scheme]
137135
const base = enr.name === 'inetOrgPerson' ? 'inetOrgPerson' : `additionalFields.attributes.${enr.name}`
@@ -149,11 +147,8 @@ export default defineNuxtComponent({
149147
150148
if (enr.name === 'inetOrgPerson') {
151149
this.columns.push(...fields)
152-
// console.log('fields inetOrgPerson', JSON.stringify(fields))
153150
}
154151
}
155-
156-
console.log('columns', this.columns)
157152
} catch (error) {
158153
console.error('There was an error!', error)
159154
}

0 commit comments

Comments
 (0)