Skip to content

Commit

Permalink
Remoe mock in resource file
Browse files Browse the repository at this point in the history
  • Loading branch information
ODORA0 committed Oct 25, 2024
1 parent 29dc0d7 commit a0d4f9c
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions src/billable-services/billable-service.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,6 @@ type ResponseObject = {
export const useBillableServices = () => {
const url = `${apiBasePath}billableService?v=custom:(uuid,name,shortName,serviceStatus,serviceType:(display),servicePrices:(uuid,name,price))`;

// Instead of generating with Faker.js, manually create some mock data for testing
const generateMockBillableServices = (count: number): BillableService[] => {
const mockBillableServices: BillableService[] = Array.from({ length: count }, (_, i) => ({
uuid: `uuid-${i}`,
name: `Service ${i}`,
shortName: `Short Name ${i}`,
serviceStatus: i % 2 === 0 ? 'Active' : 'Inactive',
serviceType: { display: `Type ${i % 5}` },
servicePrices: [
{
name: `Price Type ${i}`,
price: (i + 1) * 10,
},
],
}));

// Log the mock data to the console
// console.log('Mock Billable Services:', mockBillableServices);

return mockBillableServices;
};

const useMockData = true; // Set this to true for testing

// If testing, generate mock data instead of using the real API
if (useMockData) {
const mockBillableServices = generateMockBillableServices(100); // Generate 100 mock services
return {
billableServices: mockBillableServices,
isLoading: false,
isValidating: false,
error: null,
mutate: () => {},
};
}

// Fetch real data when not in testing mode
const { data, isLoading, isValidating, error, mutate } = useOpenmrsFetchAll<BillableService[]>(url);

return {
Expand Down

0 comments on commit a0d4f9c

Please sign in to comment.