Skip to content

Commit

Permalink
Merge pull request #269 from Build-Squad/Interactive-UI-fixes
Browse files Browse the repository at this point in the history
User Guide: Order request page
  • Loading branch information
Parikshit85 authored Mar 26, 2024
2 parents 3730905 + 5a6e73c commit 7295d26
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/ui/app/influencer/orders/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,29 @@ export default function Orders() {
}
};

const handleUserInteraction = async () => {
const { isSuccess, data, message } = await postService(
`orders/order-list/`,
{
page_number: pagination.current_page_number,
page_size: pagination.current_page_size,
}
);

if (isSuccess && data?.data?.status_counts) {
const { status_counts: orders } = data.data;
const totalOrders = Object.values(orders).reduce(
(acc: number, curr: any) => acc + curr,
0
);

if (totalOrders === 1 && orders.pending === 1) {
setStepIndex(0);
setRun(true);
}
}
};

const getOrders = async () => {
try {
setLoading(true);
Expand All @@ -180,11 +203,6 @@ export default function Orders() {
}
);
if (isSuccess) {
// Open the user guide if there's only 1 order request.
if (data?.pagination?.total_data_count == 1) {
setStepIndex(0);
setRun(true);
}
setOrders(data?.data?.orders);
setPagination({
...pagination,
Expand Down Expand Up @@ -365,6 +383,10 @@ export default function Orders() {
},
];

useEffect(() => {
handleUserInteraction();
}, []);

useEffect(() => {
const delayDebounceFn = setTimeout(() => {
getOrders();
Expand Down

0 comments on commit 7295d26

Please sign in to comment.