Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Apoorva64 committed Sep 28, 2024
2 parents 43f7819 + e056ba3 commit d0239de
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
10 changes: 3 additions & 7 deletions libs/services/common/src/lib/group/groupServiceWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,14 @@ export class GroupServiceWorkflow implements GroupService {
}
@logger
async removeAllGroups(): Promise<boolean> {
const groupIds = Object.keys(this.group);
const groupIds = Object.keys(this.group);
if (groupIds.length > 0) {
for (const id of groupIds) {
delete this.group[id];
delete this.group[id];
console.debug('Group removed:', id);
}
console.debug('All groups have been removed.');
return true;

} else {
throw new NoGroupsFoundException(`No group found.`);
}
return true;
}

}
37 changes: 33 additions & 4 deletions libs/ui/common/src/lib/offers/offers.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Box, Button, Typography } from '@mui/material';
import { useOffers } from './stores/offers';
import { useNavigate } from 'react-router-dom';
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQuery } from '@tanstack/react-query';
import {
GroupCreateDto,
GroupService,
OfferService,
TYPES,
} from '@spos/services/common';
import { useCurrentSelectedGroup } from '../tables/stores/currentSelectedGroup';
import { ContainerContext } from "../containerHook/containerContext";
import { useContext } from "react";

export function Offers() {
const offers = useOffers((state) => state.offers);
const selectedTables = useCurrentSelectedGroup((state) => state.tables);
const navigate = useNavigate();
const resetCurrentSelectedGroup = useCurrentSelectedGroup(
(state) => state.resetTables
);
Expand All @@ -26,7 +26,36 @@ export function Offers() {
navigate('/');
},
});
const navigate = useNavigate();

const {
data: offers,
isLoading,
isError,
error,
} = useQuery({
queryKey: ['offers'],
queryFn: async () => {
const offerService: OfferService = container.get<OfferService>(TYPES.OfferService);
return offerService.getOffers();
},
refetchOnWindowFocus: 'always',
});

if (isLoading) {
return (
<Typography variant="h6" component="h2" fontWeight="bold">
Loading...
</Typography>
);
}
if (!offers || isError) {
console.error(error);
return (
<Typography variant="h6" component="h2" fontWeight="bold">
Error
</Typography>
);
}

function onClick(offer) {
return () => {
Expand Down
19 changes: 0 additions & 19 deletions libs/ui/common/src/lib/offers/stores/offers.ts

This file was deleted.

0 comments on commit d0239de

Please sign in to comment.