Revize a6999074
Přidáno uživatelem Fantič před více než 1 rok
src/stores/actions/planThunks.ts | ||
---|---|---|
2 | 2 |
import { SortOptions } from "../../types/general"; |
3 | 3 |
import { Note } from "../../types/note"; |
4 | 4 |
import { getPlanAllRequest, getPlanItemsRequest } from "../../api/planservice"; |
5 |
import { Floor, InventoryTab, Room } from "../../types/plan";
|
|
5 |
import { Floor, Room } from "../../types/plan"; |
|
6 | 6 |
import { ItemPreviewType } from "../../types/listViewTypes"; |
7 | 7 |
import { StringLiteralType } from "typescript"; |
8 |
import { Inventory } from "../../types/searchFormTypes"; |
|
8 | 9 |
|
9 | 10 |
export const getFloorList = createAsyncThunk( |
10 | 11 |
"plan/getFloorList", |
... | ... | |
60 | 61 |
async (params: { room: number, place?: number }) => { |
61 | 62 |
try { |
62 | 63 |
try { |
63 |
const response = await getPlanItemsRequest({ activeTab: 0, page: 1, room: params.room, items: 1, place: params.place })
|
|
64 |
const response = await getPlanItemsRequest({ cursor: 0, room: params.room, items: 1, place: params.place })
|
|
64 | 65 |
if (response.status === 200) { |
65 | 66 |
|
66 |
let inventories: InventoryTab[] = [] |
|
67 |
console.log("response") |
|
68 |
console.log(response.data.pagination.inventories) |
|
67 | 69 |
|
68 |
for(let i = 0; i < response.data.pagination.inventories; i++){ |
|
69 |
let inventory = response.data.pagination.inventories[i] |
|
70 |
|
|
71 |
inventories.push({ |
|
72 |
tab: i, |
|
73 |
label: inventory.label, |
|
74 |
key: inventory.name |
|
75 |
}) |
|
76 |
} |
|
77 |
|
|
78 |
let allInventoriesRecords = response.data.pagination.records |
|
79 |
|
|
80 |
console.log(inventories) |
|
81 |
console.log(allInventoriesRecords) |
|
70 |
const inventories: Inventory[] = response.data.pagination.inventories |
|
71 |
const allInventoriesRecords = response.data.pagination.records |
|
82 | 72 |
|
83 | 73 |
return { |
84 | 74 |
inventories: inventories, |
85 |
allInventoriesRecords : allInventoriesRecords
|
|
75 |
allInventoriesRecords: allInventoriesRecords |
|
86 | 76 |
} |
87 | 77 |
} else { |
88 | 78 |
return Promise.reject(response.data ? response.data : "Get plan items request failed") |
... | ... | |
99 | 89 |
|
100 | 90 |
export const getPlanItems = createAsyncThunk( |
101 | 91 |
"plan/getPlanItems", |
102 |
async (params: { activeTab: number, page: number, room: number, items: number, place?: number, inventory?: string }) => {
|
|
92 |
async (params: { cursor: number, room: number, place?: number, inventory: string }) => {
|
|
103 | 93 |
try { |
104 | 94 |
try { |
105 |
const response = await getPlanItemsRequest({ activeTab: params.activeTab, page: params.page, room: params.room, items: params.items, place: params.place, inventory: params.inventory })
|
|
95 |
const response = await getPlanItemsRequest({ cursor: params.cursor, room: params.room, place: params.place, inventory: params.inventory })
|
|
106 | 96 |
if (response.status === 200) { |
107 | 97 |
|
108 |
let items: ItemPreviewType[] = response.data.data |
|
109 |
let totalItemsCountByInventory: number = response.data.pagination.records |
|
98 |
const items: ItemPreviewType[] = response.data.data |
|
99 |
const inventoryPagination = { |
|
100 |
cursor: response.data.pagination.cursor, |
|
101 |
items: response.data.pagination.items, |
|
102 |
records: response.data.pagination.records |
|
103 |
} |
|
110 | 104 |
|
111 | 105 |
return { |
112 | 106 |
items: items, |
113 |
totalItemsCount: totalItemsCountByInventory,
|
|
107 |
inventoryPagination: inventoryPagination,
|
|
114 | 108 |
} |
115 | 109 |
} else { |
116 | 110 |
return Promise.reject(response.data ? response.data : "Get plan items request failed") |
Také k dispozici: Unified diff
re #10871: PlanViewPage: ListView integration