shared-ritm 1.3.122 → 1.3.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/shared-ritm.es.js +26 -14
  3. package/dist/shared-ritm.umd.js +3 -3
  4. package/dist/types/api/services/MetricsService.d.ts +2 -0
  5. package/dist/types/api/services/TasksService.d.ts +3 -2
  6. package/package.json +70 -70
  7. package/src/App.vue +2461 -2461
  8. package/src/api/services/AuthService.ts +67 -67
  9. package/src/api/services/ControlsService.ts +100 -100
  10. package/src/api/services/EquipmentService.ts +68 -68
  11. package/src/api/services/GanttService.ts +58 -58
  12. package/src/api/services/InstrumentsService.ts +76 -76
  13. package/src/api/services/MetricsService.ts +7 -0
  14. package/src/api/services/RepairsService.ts +111 -111
  15. package/src/api/services/TasksService.ts +165 -158
  16. package/src/api/services/UserIssueService.ts +32 -32
  17. package/src/api/services/UserService.ts +129 -129
  18. package/src/api/services/VideoService.ts +118 -118
  19. package/src/api/settings/ApiService.ts +185 -185
  20. package/src/api/types/Api_Auth.ts +121 -121
  21. package/src/api/types/Api_Controls.ts +112 -112
  22. package/src/api/types/Api_Equipment.ts +54 -54
  23. package/src/api/types/Api_Instruments.ts +182 -182
  24. package/src/api/types/Api_Metrics.ts +89 -89
  25. package/src/api/types/Api_Repairs.ts +200 -200
  26. package/src/api/types/Api_Search.ts +81 -81
  27. package/src/api/types/Api_Tasks.ts +378 -378
  28. package/src/api/types/Api_User.ts +161 -161
  29. package/src/api/types/Api_User_Issue.ts +36 -36
  30. package/src/api/types/Api_Video.ts +244 -244
  31. package/src/common/app-button/Button.stories.ts +369 -369
  32. package/src/common/app-checkbox/AppCheckbox.vue +31 -31
  33. package/src/common/app-checkbox/Checkbox.stories.ts +252 -252
  34. package/src/common/app-date-picker/DatePicker.stories.ts +66 -66
  35. package/src/common/app-datepicker/Datepicker.stories.ts +145 -145
  36. package/src/common/app-dialogs/AppConfirmDialog.vue +109 -109
  37. package/src/common/app-dialogs/Confirm.stories.ts +93 -93
  38. package/src/common/app-dropdown/Dropdown.stories.ts +94 -94
  39. package/src/common/app-file/File.stories.ts +104 -104
  40. package/src/common/app-icon/AppIcon.vue +110 -110
  41. package/src/common/app-icon/Icon.stories.ts +91 -91
  42. package/src/common/app-input/AppInput.vue +150 -150
  43. package/src/common/app-input/Input.stories.ts +160 -160
  44. package/src/common/app-input-new/AppInputNew.vue +181 -181
  45. package/src/common/app-input-new/InputNew.stories.ts +240 -240
  46. package/src/common/app-input-search/InputSearch.stories.ts +149 -149
  47. package/src/common/app-layout/components/AppLayoutHeader.vue +289 -289
  48. package/src/common/app-loader/Loader.stories.ts +114 -114
  49. package/src/common/app-modal/index.vue +101 -101
  50. package/src/common/app-select/AppSelect.vue +159 -159
  51. package/src/common/app-select/Select.stories.ts +155 -155
  52. package/src/common/app-sheet-new/AppSheetNew.vue +254 -254
  53. package/src/common/app-sidebar/AppSidebar.vue +177 -177
  54. package/src/common/app-table/AppTable.vue +313 -313
  55. package/src/common/app-table/components/ModalSelect.stories.ts +323 -323
  56. package/src/common/app-table/components/ModalSelect.vue +302 -302
  57. package/src/common/app-table/components/TableModal.vue +369 -369
  58. package/src/common/app-table/controllers/useColumnSelector.ts +45 -45
  59. package/src/common/app-table/controllers/useTableModel.ts +98 -98
  60. package/src/common/app-toggle/AppToggle.vue +12 -12
  61. package/src/common/app-toggle/Toggle.stories.ts +245 -245
  62. package/src/common/app-wrapper/AppWrapper.vue +31 -31
  63. package/src/configs/storybook.ts +14 -14
  64. package/src/icons/sidebar/user-requests-icon.vue +23 -23
  65. package/src/index.ts +134 -134
  66. package/src/shared/styles/general.css +140 -140
  67. package/src/styles/variables.sass +12 -12
  68. package/src/utils/files.ts +38 -38
  69. package/src/utils/helpers.ts +59 -59
  70. package/dist/types/api/services/PhotoService.d.ts +0 -40
  71. package/dist/types/stories/Button.stories.d.ts +0 -13
  72. package/dist/types/stories/Checkbox.stories.d.ts +0 -7
  73. package/dist/types/stories/Confirm.stories.d.ts +0 -8
  74. package/dist/types/stories/DatePicker.stories.d.ts +0 -8
  75. package/dist/types/stories/Dropdown.stories.d.ts +0 -8
  76. package/dist/types/stories/File.stories.d.ts +0 -8
  77. package/dist/types/stories/Icon.stories.d.ts +0 -7
  78. package/dist/types/stories/Input.stories.d.ts +0 -11
  79. package/dist/types/stories/InputNew.stories.d.ts +0 -12
  80. package/dist/types/stories/InputSearch.stories.d.ts +0 -10
  81. package/dist/types/stories/Loader.stories.d.ts +0 -8
  82. package/dist/types/stories/Select.stories.d.ts +0 -7
  83. package/dist/types/stories/Toggle.stories.d.ts +0 -8
@@ -1,158 +1,165 @@
1
- import ApiService from '../settings/ApiService'
2
- import { ResponseApi } from '../types/Api_Service'
3
- import {
4
- Api_Task_Close_Reason,
5
- Api_Task_Instrument_Dto,
6
- Api_Task_Instrument_From_Warehouse,
7
- Api_Task_Module_Instrument_Condition,
8
- Api_Task_Dto,
9
- Api_Tasks_Task_Dto,
10
- Api_Task_ChangeStatusVerification_Dto,
11
- Api_QualityMetric_Request_Dto,
12
- Api_Tasks_Task_Edit_Request_Dto,
13
- Api_Tasks_ReplaceInstrument_Request_Dto,
14
- Api_Tasks_AllPersonalUser_Dto,
15
- Api_Tasks_InstrumentHistory_Item_Dto,
16
- Api_Task_Intersections_DTO,
17
- } from '../types/Api_Tasks'
18
- import { Api_Task_Video_Source, Api_Task_Video_Source_Stream } from '../types/Api_Repairs'
19
- import { Api_Equipment_Dto } from '@/api/types/Api_Equipment'
20
-
21
- export type EquipmentData = {
22
- id: string
23
- model: unknown
24
- name: string
25
- registration_number: string
26
- repair_frequency: unknown
27
- repair_range: number
28
- }
29
-
30
- class TasksService extends ApiService {
31
- public fetchTaskById(id: string): Promise<Api_Tasks_Task_Dto> {
32
- return this.get<Api_Tasks_Task_Dto>(`/tasks/${id}`)
33
- }
34
-
35
- public fetchTasksList(params: any): Promise<ResponseApi<Api_Task_Dto[]>> {
36
- return this.get<ResponseApi<Api_Task_Dto[]>>('/list/tasks/search', { params })
37
- }
38
-
39
- public fetchSubtasksList(id: string): Promise<Api_Task_Dto[]> {
40
- return this.get<Api_Task_Dto[]>(`/task/${id}/subtasks/list`)
41
- }
42
-
43
- public fetchIntersectionsList(id: string): Promise<Api_Task_Intersections_DTO[]> {
44
- return this.get<Api_Task_Intersections_DTO[]>(`/tasks/${id}/intersections`)
45
- }
46
-
47
- public fetchTaskBranch(id: string): Promise<ResponseApi<any>> {
48
- return this.get(`/get_list_task_branch?task_id=${id}`)
49
- }
50
-
51
- public fetchInstrumentsList(params: any): Promise<ResponseApi<any[]>> {
52
- return this.get('admin/instruments', { params })
53
- }
54
-
55
- public fetchInstrumentTypeListWithPreparedWarehouse(params: {
56
- page: number
57
- per_page: number
58
- 'filterList[taskId]'?: string | undefined
59
- search?: string
60
- }): Promise<ResponseApi<Api_Task_Instrument_From_Warehouse[]>> {
61
- return this.get('/instrument_type/get_instrument_type_list_with_prepared_warehouse', { params })
62
- }
63
-
64
- public fetchInstrumentsEquivalentList(params: any): Promise<ResponseApi<Api_Task_Instrument_Dto[]>> {
65
- return this.get<ResponseApi<Api_Task_Instrument_Dto[]>>('tasks/instrument/list', { params })
66
- }
67
-
68
- public fetchDiffInstruments(params: any): Promise<ResponseApi<Api_Task_Module_Instrument_Condition>> {
69
- return this.get<ResponseApi<Api_Task_Module_Instrument_Condition>>(`tasks/${params.taskId}/fill/module`, {
70
- params,
71
- })
72
- }
73
-
74
- public replaceInstruments(payload: Api_Tasks_ReplaceInstrument_Request_Dto[]): Promise<ResponseApi<any[]>> {
75
- return this.post<Api_Tasks_ReplaceInstrument_Request_Dto[], ResponseApi<any[]>>(
76
- `/instruments/equivalent/attach`,
77
- payload,
78
- )
79
- }
80
-
81
- public fetchTaskUsagePersonal(task_id: string): Promise<Api_Tasks_AllPersonalUser_Dto> {
82
- return this.get<Api_Tasks_AllPersonalUser_Dto>(`tasks/${task_id}/usage/users`)
83
- }
84
-
85
- public fetchTaskUsageInstrument(task_id: string): Promise<Api_Tasks_InstrumentHistory_Item_Dto[]> {
86
- return this.get<Api_Tasks_InstrumentHistory_Item_Dto[]>(`tasks/${task_id}/usage/instruments`)
87
- }
88
-
89
- public fetchEquipment(params: any): Promise<ResponseApi<Api_Equipment_Dto[]>> {
90
- return this.get<ResponseApi<Api_Equipment_Dto[]>>('repairs/equipment/list', { params })
91
- }
92
-
93
- public fetchTaskVideoSources(params: any): Promise<ResponseApi<Api_Task_Video_Source[]>> {
94
- return this.get<ResponseApi<Api_Task_Video_Source[]>>('work_zone/get_list_video_source', { params })
95
- }
96
-
97
- public fetchTaskVideoSourcesStream(params: any): Promise<ResponseApi<Api_Task_Video_Source_Stream[]>> {
98
- return this.get<ResponseApi<Api_Task_Video_Source_Stream[]>>('horizon/video-source', { params })
99
- }
100
-
101
- public createWorkZone(payload: any): Promise<unknown> {
102
- return this.post('admin/work-zones', payload)
103
- }
104
-
105
- public createTask(payload: any): Promise<ResponseApi<any>> {
106
- return this.post(`tasks`, payload)
107
- }
108
-
109
- public editTask(task_id: string, payload: Api_Tasks_Task_Edit_Request_Dto): Promise<Api_Tasks_Task_Dto> {
110
- return this.put<Api_Tasks_Task_Edit_Request_Dto, Api_Tasks_Task_Dto>(`tasks/${task_id}`, payload)
111
- }
112
-
113
- public mergeTask(payload: { name: string; tasks_id: string[]; defect?: string }): Promise<ResponseApi<any>> {
114
- return this.post(`tasks/merge`, payload)
115
- }
116
-
117
- public cloneTask(
118
- task_id: string,
119
- payload: { project_id: string; state_id?: string; with_subtask: boolean },
120
- ): Promise<any> {
121
- return this.post(`gantt/${task_id}/clone`, payload)
122
- }
123
-
124
- public deleteTask(id: string): Promise<any> {
125
- return this.delete(`tasks/${id}`)
126
- }
127
-
128
- public changeStatus(taskId: string, statusId: string): Promise<any> {
129
- return this.put<{ status_id: string }, any>(`task/${taskId}/change-status`, {
130
- status_id: statusId,
131
- })
132
- }
133
-
134
- public saveMetrics(payload: Api_QualityMetric_Request_Dto[]): Promise<EquipmentData[]> {
135
- return this.put<Api_QualityMetric_Request_Dto[], EquipmentData[]>('/update_quality_metrics', payload)
136
- }
137
-
138
- public checkReasonForStatus(task_id: string): Promise<Api_Task_Close_Reason> {
139
- return this.post<{ task_id: string }, Api_Task_Close_Reason>('/tasks/check_reason_for_task', { task_id })
140
- }
141
-
142
- public verifyTaskStatus(task_id: string, status_id: string): Promise<Api_Task_ChangeStatusVerification_Dto[]> {
143
- return this.get<Api_Task_ChangeStatusVerification_Dto[]>(`/task/${task_id}/change-status/verification`, {
144
- params: { status_id },
145
- })
146
- }
147
-
148
- public checkBranchBeforeCloseTask(task_id: string): Promise<ResponseApi<boolean>> {
149
- return this.post<{ task_id: string }, ResponseApi<boolean>>(`/check_branch_before_close_task`, { task_id })
150
- }
151
- }
152
-
153
- let api: TasksService
154
-
155
- export default function useTasksService() {
156
- if (!api) api = new TasksService()
157
- return api
158
- }
1
+ import ApiService from '../settings/ApiService'
2
+ import { ResponseApi } from '../types/Api_Service'
3
+ import {
4
+ Api_Task_Close_Reason,
5
+ Api_Task_Instrument_Dto,
6
+ Api_Task_Instrument_From_Warehouse,
7
+ Api_Task_Module_Instrument_Condition,
8
+ Api_Task_Dto,
9
+ Api_Tasks_Task_Dto,
10
+ Api_Task_ChangeStatusVerification_Dto,
11
+ Api_QualityMetric_Request_Dto,
12
+ Api_Tasks_Task_Edit_Request_Dto,
13
+ Api_Tasks_ReplaceInstrument_Request_Dto,
14
+ Api_Tasks_AllPersonalUser_Dto,
15
+ Api_Tasks_InstrumentHistory_Item_Dto,
16
+ Api_Task_Intersections_DTO,
17
+ } from '../types/Api_Tasks'
18
+ import { Api_Task_Video_Source, Api_Task_Video_Source_Stream } from '../types/Api_Repairs'
19
+ import { Api_Equipment_Dto } from '@/api/types/Api_Equipment'
20
+
21
+ export type EquipmentData = {
22
+ id: string
23
+ model: unknown
24
+ name: string
25
+ registration_number: string
26
+ repair_frequency: unknown
27
+ repair_range: number
28
+ }
29
+
30
+ class TasksService extends ApiService {
31
+ public fetchTaskById(id: string): Promise<Api_Tasks_Task_Dto> {
32
+ return this.get<Api_Tasks_Task_Dto>(`/tasks/${id}`)
33
+ }
34
+
35
+ public fetchTasksList(params: any): Promise<ResponseApi<Api_Task_Dto[]>> {
36
+ return this.get<ResponseApi<Api_Task_Dto[]>>('/list/tasks/search', { params })
37
+ }
38
+
39
+ public fetchSubtasksList(id: string): Promise<Api_Task_Dto[]> {
40
+ return this.get<Api_Task_Dto[]>(`/task/${id}/subtasks/list`)
41
+ }
42
+
43
+ public fetchIntersectionsList(id: string): Promise<Api_Task_Intersections_DTO[]> {
44
+ return this.get<Api_Task_Intersections_DTO[]>(`/tasks/${id}/intersections`)
45
+ }
46
+
47
+ public fetchTaskBranch(id: string): Promise<ResponseApi<any>> {
48
+ return this.get(`/get_list_task_branch?task_id=${id}`)
49
+ }
50
+
51
+ public fetchInstrumentsList(params: any): Promise<ResponseApi<any[]>> {
52
+ return this.get('admin/instruments', { params })
53
+ }
54
+
55
+ public fetchInstrumentTypeListWithPreparedWarehouse(params: {
56
+ page?: number
57
+ per_page: number
58
+ 'filter_list[task_Id]'?: string | undefined
59
+ search?: string
60
+ }): Promise<ResponseApi<Api_Task_Instrument_From_Warehouse[]>> {
61
+ return this.get('/instrument_type/get_instrument_type_list_with_prepared_warehouse', { params })
62
+ }
63
+
64
+ public downloadInstrumentTypeListWithPreparedWarehouse(params: any): Promise<Blob> {
65
+ return this.get('/instrument_type/get_instrument_type_list_with_prepared_warehouse', {
66
+ responseType: 'blob',
67
+ params,
68
+ })
69
+ }
70
+
71
+ public fetchInstrumentsEquivalentList(params: any): Promise<ResponseApi<Api_Task_Instrument_Dto[]>> {
72
+ return this.get<ResponseApi<Api_Task_Instrument_Dto[]>>('tasks/instrument/list', { params })
73
+ }
74
+
75
+ public fetchDiffInstruments(params: any): Promise<ResponseApi<Api_Task_Module_Instrument_Condition>> {
76
+ return this.get<ResponseApi<Api_Task_Module_Instrument_Condition>>(`tasks/${params.taskId}/fill/module`, {
77
+ params,
78
+ })
79
+ }
80
+
81
+ public replaceInstruments(payload: Api_Tasks_ReplaceInstrument_Request_Dto[]): Promise<ResponseApi<any[]>> {
82
+ return this.post<Api_Tasks_ReplaceInstrument_Request_Dto[], ResponseApi<any[]>>(
83
+ `/instruments/equivalent/attach`,
84
+ payload,
85
+ )
86
+ }
87
+
88
+ public fetchTaskUsagePersonal(task_id: string): Promise<Api_Tasks_AllPersonalUser_Dto> {
89
+ return this.get<Api_Tasks_AllPersonalUser_Dto>(`tasks/${task_id}/usage/users`)
90
+ }
91
+
92
+ public fetchTaskUsageInstrument(task_id: string): Promise<Api_Tasks_InstrumentHistory_Item_Dto[]> {
93
+ return this.get<Api_Tasks_InstrumentHistory_Item_Dto[]>(`tasks/${task_id}/usage/instruments`)
94
+ }
95
+
96
+ public fetchEquipment(params: any): Promise<ResponseApi<Api_Equipment_Dto[]>> {
97
+ return this.get<ResponseApi<Api_Equipment_Dto[]>>('repairs/equipment/list', { params })
98
+ }
99
+
100
+ public fetchTaskVideoSources(params: any): Promise<ResponseApi<Api_Task_Video_Source[]>> {
101
+ return this.get<ResponseApi<Api_Task_Video_Source[]>>('work_zone/get_list_video_source', { params })
102
+ }
103
+
104
+ public fetchTaskVideoSourcesStream(params: any): Promise<ResponseApi<Api_Task_Video_Source_Stream[]>> {
105
+ return this.get<ResponseApi<Api_Task_Video_Source_Stream[]>>('horizon/video-source', { params })
106
+ }
107
+
108
+ public createWorkZone(payload: any): Promise<unknown> {
109
+ return this.post('admin/work-zones', payload)
110
+ }
111
+
112
+ public createTask(payload: any): Promise<ResponseApi<any>> {
113
+ return this.post(`tasks`, payload)
114
+ }
115
+
116
+ public editTask(task_id: string, payload: Api_Tasks_Task_Edit_Request_Dto): Promise<Api_Tasks_Task_Dto> {
117
+ return this.put<Api_Tasks_Task_Edit_Request_Dto, Api_Tasks_Task_Dto>(`tasks/${task_id}`, payload)
118
+ }
119
+
120
+ public mergeTask(payload: { name: string; tasks_id: string[]; defect?: string }): Promise<ResponseApi<any>> {
121
+ return this.post(`tasks/merge`, payload)
122
+ }
123
+
124
+ public cloneTask(
125
+ task_id: string,
126
+ payload: { project_id: string; state_id?: string; with_subtask: boolean },
127
+ ): Promise<any> {
128
+ return this.post(`gantt/${task_id}/clone`, payload)
129
+ }
130
+
131
+ public deleteTask(id: string): Promise<any> {
132
+ return this.delete(`tasks/${id}`)
133
+ }
134
+
135
+ public changeStatus(taskId: string, statusId: string): Promise<any> {
136
+ return this.put<{ status_id: string }, any>(`task/${taskId}/change-status`, {
137
+ status_id: statusId,
138
+ })
139
+ }
140
+
141
+ public saveMetrics(payload: Api_QualityMetric_Request_Dto[]): Promise<EquipmentData[]> {
142
+ return this.put<Api_QualityMetric_Request_Dto[], EquipmentData[]>('/update_quality_metrics', payload)
143
+ }
144
+
145
+ public checkReasonForStatus(task_id: string): Promise<Api_Task_Close_Reason> {
146
+ return this.post<{ task_id: string }, Api_Task_Close_Reason>('/tasks/check_reason_for_task', { task_id })
147
+ }
148
+
149
+ public verifyTaskStatus(task_id: string, status_id: string): Promise<Api_Task_ChangeStatusVerification_Dto[]> {
150
+ return this.get<Api_Task_ChangeStatusVerification_Dto[]>(`/task/${task_id}/change-status/verification`, {
151
+ params: { status_id },
152
+ })
153
+ }
154
+
155
+ public checkBranchBeforeCloseTask(task_id: string): Promise<ResponseApi<boolean>> {
156
+ return this.post<{ task_id: string }, ResponseApi<boolean>>(`/check_branch_before_close_task`, { task_id })
157
+ }
158
+ }
159
+
160
+ let api: TasksService
161
+
162
+ export default function useTasksService() {
163
+ if (!api) api = new TasksService()
164
+ return api
165
+ }
@@ -1,32 +1,32 @@
1
- import ApiService from '../settings/ApiService'
2
- import { Api_User_Issue, Api_User_Issue_List_Item, Api_User_Issue_Properties } from '@/api/types/Api_User_Issue'
3
- import { ResponseApi } from '@/api/types/Api_Service'
4
-
5
- class UserIssueService extends ApiService {
6
- public createUserIssue(body: any): Promise<Api_User_Issue_List_Item> {
7
- return this.post('user_issue', body, { headers: { 'Content-Type': 'multipart/form-data' } })
8
- }
9
-
10
- public getUserIssue(id: string): Promise<Api_User_Issue> {
11
- return this.get(`user_issue/${id}`)
12
- }
13
-
14
- public getUserIssueList(params: any): Promise<ResponseApi<Api_User_Issue_List_Item>> {
15
- return this.get('user_issue/list', { params })
16
- }
17
-
18
- public getProperties(): Promise<Api_User_Issue_Properties> {
19
- return this.get('user_issue/properties')
20
- }
21
-
22
- public deleteUserIssue(id: string): Promise<{ data: boolean; status: number }> {
23
- return this.delete(`user_issue/${id}`)
24
- }
25
- }
26
-
27
- let api: UserIssueService
28
-
29
- export default function useUserIssueService() {
30
- if (!api) api = new UserIssueService()
31
- return api
32
- }
1
+ import ApiService from '../settings/ApiService'
2
+ import { Api_User_Issue, Api_User_Issue_List_Item, Api_User_Issue_Properties } from '@/api/types/Api_User_Issue'
3
+ import { ResponseApi } from '@/api/types/Api_Service'
4
+
5
+ class UserIssueService extends ApiService {
6
+ public createUserIssue(body: any): Promise<Api_User_Issue_List_Item> {
7
+ return this.post('user_issue', body, { headers: { 'Content-Type': 'multipart/form-data' } })
8
+ }
9
+
10
+ public getUserIssue(id: string): Promise<Api_User_Issue> {
11
+ return this.get(`user_issue/${id}`)
12
+ }
13
+
14
+ public getUserIssueList(params: any): Promise<ResponseApi<Api_User_Issue_List_Item>> {
15
+ return this.get('user_issue/list', { params })
16
+ }
17
+
18
+ public getProperties(): Promise<Api_User_Issue_Properties> {
19
+ return this.get('user_issue/properties')
20
+ }
21
+
22
+ public deleteUserIssue(id: string): Promise<{ data: boolean; status: number }> {
23
+ return this.delete(`user_issue/${id}`)
24
+ }
25
+ }
26
+
27
+ let api: UserIssueService
28
+
29
+ export default function useUserIssueService() {
30
+ if (!api) api = new UserIssueService()
31
+ return api
32
+ }
@@ -1,129 +1,129 @@
1
- import ApiService from '../settings/ApiService'
2
- import {
3
- Api_User,
4
- Api_User_Create,
5
- Api_User_Delete_Body,
6
- Api_User_Delete_Photos_Body,
7
- Api_User_Position,
8
- Api_User_Role,
9
- Api_User_Team,
10
- Api_User_Team_Search,
11
- Api_User_Warehouse,
12
- Api_User_Change_Password_Payload,
13
- } from '../types/Api_User'
14
-
15
- import { ResponseApi } from '../types/Api_Service'
16
-
17
- class UserService extends ApiService {
18
- public async editUser({ id, model }: { id: string; model: any }): Promise<Api_User> {
19
- return await this.put<Partial<Api_User>, Api_User>(`/admin/users/${id}`, model)
20
- }
21
-
22
- public async getUser(id: string): Promise<Api_User> {
23
- return await this.get<Api_User>(`/admin/users/${id}`)
24
- }
25
-
26
- public async changeUserPassword(payload: Api_User_Change_Password_Payload): Promise<Api_User> {
27
- return await this.patch<Api_User_Change_Password_Payload, Api_User>(`/v2/auth/users/password`, payload)
28
- }
29
-
30
- public async getUserWarehouses(params: {
31
- user_id: string
32
- page?: number
33
- }): Promise<ResponseApi<Api_User_Warehouse[]>> {
34
- return await this.get<ResponseApi<Api_User_Warehouse[]>>(`users/get_warehouse_list_by_user`, { params })
35
- }
36
-
37
- public async createUser(model: Api_User_Create): Promise<Api_User> {
38
- return await this.post<Api_User_Create, Api_User>('/admin/users', model)
39
- }
40
-
41
- public async deleteUser({
42
- user_id,
43
- archive_reason,
44
- }: Api_User_Delete_Body): Promise<{ data: boolean; status: number }> {
45
- return await this.post(`/users/archive_user`, { user_id, archive_reason })
46
- }
47
-
48
- public async deleteUserPhotos({
49
- user_id,
50
- photos,
51
- }: Api_User_Delete_Photos_Body): Promise<{ data: boolean; status: number }> {
52
- return await this.post(`/users/photos/delete`, { user_id, photos })
53
- }
54
-
55
- public async restoreUser(user_id: string): Promise<{ data: boolean; status: number }> {
56
- return await this.post(`/users/restore_user`, { user_id })
57
- }
58
-
59
- public async getRoles(params?: { per_page?: number }): Promise<ResponseApi<Api_User_Role[]>> {
60
- return await this.get<ResponseApi<Api_User_Role[]>>('/search/roles', { params })
61
- }
62
-
63
- public async getPositions(params?: { per_page?: number }): Promise<ResponseApi<Api_User_Position[]>> {
64
- return await this.get<ResponseApi<Api_User_Position[]>>('/search/positions', { params })
65
- }
66
-
67
- public async createPosition(body: Partial<Api_User_Position>): Promise<ResponseApi<Api_User_Position>> {
68
- return await this.post<Partial<Api_User_Position>, ResponseApi<Api_User_Position>>('/admin/positions', body)
69
- }
70
-
71
- public async editPosition(id: string, body: Partial<Api_User_Position>): Promise<ResponseApi<Api_User_Position>> {
72
- return await this.put<Partial<Api_User_Position>, ResponseApi<Api_User_Position>>(`/admin/positions/${id}`, body)
73
- }
74
-
75
- public async deletePosition(id: string): Promise<{ data: boolean; status: number }> {
76
- return await this.delete(`/admin/positions/${id}`)
77
- }
78
-
79
- public async getTeams(params?: { per_page?: number }): Promise<ResponseApi<Api_User_Team_Search[]>> {
80
- return await this.get<ResponseApi<Api_User_Team_Search[]>>('/search/teams', { params })
81
- }
82
-
83
- public async createTeam(body: Partial<Api_User_Team_Search>): Promise<ResponseApi<Api_User_Team>> {
84
- return await this.post<Partial<Api_User_Team_Search>, ResponseApi<Api_User_Team>>('/teams', body)
85
- }
86
-
87
- public async editTeam(id: string, body: Partial<Api_User_Team_Search>): Promise<{ data: boolean; status: number }> {
88
- return await this.patch<Partial<Api_User_Team_Search>, { data: boolean; status: number }>(`/teams/${id}`, body)
89
- }
90
-
91
- public async deleteTeam(id: string): Promise<{ data: boolean; status: number }> {
92
- return await this.delete(`/teams/${id}`)
93
- }
94
-
95
- public async checkUserVectors(id: string): Promise<{ count: number }> {
96
- return await this.get(`/user/get-vectors/${id}`)
97
- }
98
-
99
- public async checkArchiveUserVectors(id: string): Promise<{ count: number }> {
100
- return await this.get(`/users/get_vector_count_by_user?user_id=${id}`)
101
- }
102
-
103
- public async addUserVectors(formData: FormData): Promise<{ response: string }> {
104
- return await this.post(`/user/add-vector`, formData, {
105
- headers: { 'Content-Type': 'multipart/form-data' },
106
- })
107
- }
108
-
109
- public async removeUserVectors(id: string): Promise<unknown> {
110
- return await this.delete(`/user/delete-vectors/${id}`)
111
- }
112
-
113
- public async deleteUserPasses(body: {
114
- personnel_number: number
115
- }): Promise<{ delete_passes: boolean; user: Partial<Api_User> }> {
116
- return await this.post('admin/delete/passes', body)
117
- }
118
-
119
- public async checkUserBeforeArchive(body: { user_id: string }): Promise<any> {
120
- return await this.post('users/check_user_before_archive', body)
121
- }
122
- }
123
-
124
- let api: UserService
125
-
126
- export default function useUserService() {
127
- if (!api) api = new UserService()
128
- return api
129
- }
1
+ import ApiService from '../settings/ApiService'
2
+ import {
3
+ Api_User,
4
+ Api_User_Create,
5
+ Api_User_Delete_Body,
6
+ Api_User_Delete_Photos_Body,
7
+ Api_User_Position,
8
+ Api_User_Role,
9
+ Api_User_Team,
10
+ Api_User_Team_Search,
11
+ Api_User_Warehouse,
12
+ Api_User_Change_Password_Payload,
13
+ } from '../types/Api_User'
14
+
15
+ import { ResponseApi } from '../types/Api_Service'
16
+
17
+ class UserService extends ApiService {
18
+ public async editUser({ id, model }: { id: string; model: any }): Promise<Api_User> {
19
+ return await this.put<Partial<Api_User>, Api_User>(`/admin/users/${id}`, model)
20
+ }
21
+
22
+ public async getUser(id: string): Promise<Api_User> {
23
+ return await this.get<Api_User>(`/admin/users/${id}`)
24
+ }
25
+
26
+ public async changeUserPassword(payload: Api_User_Change_Password_Payload): Promise<Api_User> {
27
+ return await this.patch<Api_User_Change_Password_Payload, Api_User>(`/v2/auth/users/password`, payload)
28
+ }
29
+
30
+ public async getUserWarehouses(params: {
31
+ user_id: string
32
+ page?: number
33
+ }): Promise<ResponseApi<Api_User_Warehouse[]>> {
34
+ return await this.get<ResponseApi<Api_User_Warehouse[]>>(`users/get_warehouse_list_by_user`, { params })
35
+ }
36
+
37
+ public async createUser(model: Api_User_Create): Promise<Api_User> {
38
+ return await this.post<Api_User_Create, Api_User>('/admin/users', model)
39
+ }
40
+
41
+ public async deleteUser({
42
+ user_id,
43
+ archive_reason,
44
+ }: Api_User_Delete_Body): Promise<{ data: boolean; status: number }> {
45
+ return await this.post(`/users/archive_user`, { user_id, archive_reason })
46
+ }
47
+
48
+ public async deleteUserPhotos({
49
+ user_id,
50
+ photos,
51
+ }: Api_User_Delete_Photos_Body): Promise<{ data: boolean; status: number }> {
52
+ return await this.post(`/users/photos/delete`, { user_id, photos })
53
+ }
54
+
55
+ public async restoreUser(user_id: string): Promise<{ data: boolean; status: number }> {
56
+ return await this.post(`/users/restore_user`, { user_id })
57
+ }
58
+
59
+ public async getRoles(params?: { per_page?: number }): Promise<ResponseApi<Api_User_Role[]>> {
60
+ return await this.get<ResponseApi<Api_User_Role[]>>('/search/roles', { params })
61
+ }
62
+
63
+ public async getPositions(params?: { per_page?: number }): Promise<ResponseApi<Api_User_Position[]>> {
64
+ return await this.get<ResponseApi<Api_User_Position[]>>('/search/positions', { params })
65
+ }
66
+
67
+ public async createPosition(body: Partial<Api_User_Position>): Promise<ResponseApi<Api_User_Position>> {
68
+ return await this.post<Partial<Api_User_Position>, ResponseApi<Api_User_Position>>('/admin/positions', body)
69
+ }
70
+
71
+ public async editPosition(id: string, body: Partial<Api_User_Position>): Promise<ResponseApi<Api_User_Position>> {
72
+ return await this.put<Partial<Api_User_Position>, ResponseApi<Api_User_Position>>(`/admin/positions/${id}`, body)
73
+ }
74
+
75
+ public async deletePosition(id: string): Promise<{ data: boolean; status: number }> {
76
+ return await this.delete(`/admin/positions/${id}`)
77
+ }
78
+
79
+ public async getTeams(params?: { per_page?: number }): Promise<ResponseApi<Api_User_Team_Search[]>> {
80
+ return await this.get<ResponseApi<Api_User_Team_Search[]>>('/search/teams', { params })
81
+ }
82
+
83
+ public async createTeam(body: Partial<Api_User_Team_Search>): Promise<ResponseApi<Api_User_Team>> {
84
+ return await this.post<Partial<Api_User_Team_Search>, ResponseApi<Api_User_Team>>('/teams', body)
85
+ }
86
+
87
+ public async editTeam(id: string, body: Partial<Api_User_Team_Search>): Promise<{ data: boolean; status: number }> {
88
+ return await this.patch<Partial<Api_User_Team_Search>, { data: boolean; status: number }>(`/teams/${id}`, body)
89
+ }
90
+
91
+ public async deleteTeam(id: string): Promise<{ data: boolean; status: number }> {
92
+ return await this.delete(`/teams/${id}`)
93
+ }
94
+
95
+ public async checkUserVectors(id: string): Promise<{ count: number }> {
96
+ return await this.get(`/user/get-vectors/${id}`)
97
+ }
98
+
99
+ public async checkArchiveUserVectors(id: string): Promise<{ count: number }> {
100
+ return await this.get(`/users/get_vector_count_by_user?user_id=${id}`)
101
+ }
102
+
103
+ public async addUserVectors(formData: FormData): Promise<{ response: string }> {
104
+ return await this.post(`/user/add-vector`, formData, {
105
+ headers: { 'Content-Type': 'multipart/form-data' },
106
+ })
107
+ }
108
+
109
+ public async removeUserVectors(id: string): Promise<unknown> {
110
+ return await this.delete(`/user/delete-vectors/${id}`)
111
+ }
112
+
113
+ public async deleteUserPasses(body: {
114
+ personnel_number: number
115
+ }): Promise<{ delete_passes: boolean; user: Partial<Api_User> }> {
116
+ return await this.post('admin/delete/passes', body)
117
+ }
118
+
119
+ public async checkUserBeforeArchive(body: { user_id: string }): Promise<any> {
120
+ return await this.post('users/check_user_before_archive', body)
121
+ }
122
+ }
123
+
124
+ let api: UserService
125
+
126
+ export default function useUserService() {
127
+ if (!api) api = new UserService()
128
+ return api
129
+ }