Skip to content

Commit 2477a6f

Browse files
fix: unable to fetch due to incorrect initialData
1 parent 7d5edcb commit 2477a6f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/meteor/client/components/Omnichannel/hooks/useUnitsList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const DEFAULT_QUERY_LIMIT = 25;
1919

2020
export const useUnitsList = (options: UnitsListOptions) => {
2121
const { t } = useTranslation();
22-
const { haveNone = false, text, limit } = options;
22+
const { haveNone = false, text, limit = DEFAULT_QUERY_LIMIT } = options;
2323
const getUnits = useEndpoint('GET', '/v1/livechat/units');
2424

2525
const formatUnitItem = (u: Serialized<IOmnichannelBusinessUnit>): UnitOption => ({
@@ -34,7 +34,7 @@ export const useUnitsList = (options: UnitsListOptions) => {
3434
const { units, ...data } = await getUnits({
3535
...(text && { text }),
3636
offset,
37-
count: limit ?? DEFAULT_QUERY_LIMIT,
37+
count: limit,
3838
sort: `{ "name": 1 }`,
3939
});
4040

@@ -61,7 +61,7 @@ export const useUnitsList = (options: UnitsListOptions) => {
6161
return offset < lastPage.total ? offset : undefined;
6262
},
6363
initialData: () => ({
64-
pages: [{ units: [], total: 0, offset: 0, count: limit ?? DEFAULT_QUERY_LIMIT }],
64+
pages: [{ units: [], offset: 0, count: 0, total: Infinity }],
6565
pageParams: [0],
6666
}),
6767
});

0 commit comments

Comments
 (0)