shared-ritm 1.3.125 → 1.3.126

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 (82) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/shared-ritm.es.js +502 -484
  3. package/dist/shared-ritm.umd.js +3 -3
  4. package/dist/types/api/services/MetricsService.d.ts +0 -1
  5. package/dist/types/api/services/PhotoService.d.ts +40 -0
  6. package/dist/types/stories/Button.stories.d.ts +13 -0
  7. package/dist/types/stories/Checkbox.stories.d.ts +7 -0
  8. package/dist/types/stories/Confirm.stories.d.ts +8 -0
  9. package/dist/types/stories/DatePicker.stories.d.ts +8 -0
  10. package/dist/types/stories/Dropdown.stories.d.ts +8 -0
  11. package/dist/types/stories/File.stories.d.ts +8 -0
  12. package/dist/types/stories/Icon.stories.d.ts +7 -0
  13. package/dist/types/stories/Input.stories.d.ts +11 -0
  14. package/dist/types/stories/InputNew.stories.d.ts +12 -0
  15. package/dist/types/stories/InputSearch.stories.d.ts +10 -0
  16. package/dist/types/stories/Loader.stories.d.ts +8 -0
  17. package/dist/types/stories/Select.stories.d.ts +7 -0
  18. package/dist/types/stories/Toggle.stories.d.ts +8 -0
  19. package/package.json +70 -70
  20. package/src/App.vue +2461 -2461
  21. package/src/api/services/AuthService.ts +67 -67
  22. package/src/api/services/ControlsService.ts +100 -100
  23. package/src/api/services/EquipmentService.ts +68 -68
  24. package/src/api/services/GanttService.ts +58 -58
  25. package/src/api/services/InstrumentsService.ts +76 -76
  26. package/src/api/services/MetricsService.ts +0 -3
  27. package/src/api/services/RepairsService.ts +111 -111
  28. package/src/api/services/TasksService.ts +165 -165
  29. package/src/api/services/UserIssueService.ts +32 -32
  30. package/src/api/services/UserService.ts +129 -129
  31. package/src/api/services/VideoService.ts +118 -118
  32. package/src/api/settings/ApiService.ts +185 -185
  33. package/src/api/types/Api_Auth.ts +121 -121
  34. package/src/api/types/Api_Controls.ts +112 -112
  35. package/src/api/types/Api_Equipment.ts +54 -54
  36. package/src/api/types/Api_Instruments.ts +182 -182
  37. package/src/api/types/Api_Metrics.ts +89 -89
  38. package/src/api/types/Api_Repairs.ts +200 -200
  39. package/src/api/types/Api_Search.ts +81 -81
  40. package/src/api/types/Api_Tasks.ts +378 -378
  41. package/src/api/types/Api_User.ts +161 -161
  42. package/src/api/types/Api_User_Issue.ts +36 -36
  43. package/src/api/types/Api_Video.ts +244 -244
  44. package/src/common/app-button/Button.stories.ts +369 -369
  45. package/src/common/app-checkbox/AppCheckbox.vue +33 -31
  46. package/src/common/app-checkbox/Checkbox.stories.ts +252 -252
  47. package/src/common/app-date-picker/DatePicker.stories.ts +66 -66
  48. package/src/common/app-datepicker/Datepicker.stories.ts +145 -145
  49. package/src/common/app-dialogs/AppConfirmDialog.vue +109 -109
  50. package/src/common/app-dialogs/Confirm.stories.ts +93 -93
  51. package/src/common/app-dropdown/Dropdown.stories.ts +94 -94
  52. package/src/common/app-file/File.stories.ts +104 -104
  53. package/src/common/app-icon/AppIcon.vue +110 -110
  54. package/src/common/app-icon/Icon.stories.ts +91 -91
  55. package/src/common/app-input/AppInput.vue +150 -150
  56. package/src/common/app-input/Input.stories.ts +160 -160
  57. package/src/common/app-input-new/AppInputNew.vue +181 -181
  58. package/src/common/app-input-new/InputNew.stories.ts +240 -240
  59. package/src/common/app-input-search/InputSearch.stories.ts +149 -149
  60. package/src/common/app-layout/components/AppLayoutHeader.vue +289 -289
  61. package/src/common/app-loader/Loader.stories.ts +114 -114
  62. package/src/common/app-modal/index.vue +101 -101
  63. package/src/common/app-select/AppSelect.vue +159 -159
  64. package/src/common/app-select/Select.stories.ts +155 -155
  65. package/src/common/app-sheet-new/AppSheetNew.vue +254 -254
  66. package/src/common/app-sidebar/AppSidebar.vue +177 -177
  67. package/src/common/app-table/AppTable.vue +313 -313
  68. package/src/common/app-table/components/ModalSelect.stories.ts +323 -323
  69. package/src/common/app-table/components/ModalSelect.vue +311 -302
  70. package/src/common/app-table/components/TableModal.vue +369 -369
  71. package/src/common/app-table/controllers/useColumnSelector.ts +45 -45
  72. package/src/common/app-table/controllers/useTableModel.ts +98 -98
  73. package/src/common/app-toggle/AppToggle.vue +12 -12
  74. package/src/common/app-toggle/Toggle.stories.ts +245 -245
  75. package/src/common/app-wrapper/AppWrapper.vue +31 -31
  76. package/src/configs/storybook.ts +14 -14
  77. package/src/icons/sidebar/user-requests-icon.vue +23 -23
  78. package/src/index.ts +134 -134
  79. package/src/shared/styles/general.css +140 -140
  80. package/src/styles/variables.sass +12 -12
  81. package/src/utils/files.ts +38 -38
  82. package/src/utils/helpers.ts +59 -59
@@ -1,165 +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
- '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
+ 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
+ }