Title: Replace Hardcoded Branch ID in UseBranchService with Dynamic Data from Manager
Description:
The UseBranchService currently uses a hardcoded branchID value of 3. To improve flexibility and maintainability, we need to replace this hardcoded value with dynamic data fetched from the manager's details.
File:
src/path/to/UseBranchService.ts
Current Code:
import { useState } from 'react';
import useAxiosInstance from '../../login/services/useAxiosInstance';
import { IBranchData } from '../interfaces/IBranchData';
import { useUserContext } from '../../../context/UserContext';
import { toast } from 'react-toastify';
const UseBranchService = () => {
const http = useAxiosInstance();
const [branchData, setBranchData] = useState<IBranchData>();
const { user } = useUserContext(); //dont remove this from code because this is for the branch id
const branchID = 3; //replace this with actual id
const [loading, setLoading] = useState<boolean>(false);
const fetchBranchData = async () => {
try {
setLoading(true);
const res = await http.get(`/branch-summary/sales-summary/${branchID}`);
console.log(res);
const { data } = res;
setBranchData(data.data);
} catch (error) {
toast.error('Unable to fetch details');
console.log(error);
} finally {
setLoading(false);
}
};
return {
fetchBranchData,
branchData,
};
};
export default UseBranchService;
Proposed Change:
- Fetch the branch ID dynamically from the manager's data and use it in the API call.
Steps:
- Retrieve the branch ID from the manager's details available in the
useUserContext.
- Replace the hardcoded
branchID with the dynamically fetched value.
Expected Behavior:
The UseBranchService should use the branch ID associated with the logged-in manager, making the service more flexible and aligned with actual data.
Additional Context:
If there are any changes required in the context or other parts of the application to support this dynamic fetching, please include them in this issue.
Labels:
- enhancement
- backend
- frontend
Title: Replace Hardcoded Branch ID in
UseBranchServicewith Dynamic Data from ManagerDescription:
The
UseBranchServicecurrently uses a hardcodedbranchIDvalue of3. To improve flexibility and maintainability, we need to replace this hardcoded value with dynamic data fetched from the manager's details.File:
src/path/to/UseBranchService.tsCurrent Code:
Proposed Change:
Steps:
useUserContext.branchIDwith the dynamically fetched value.Expected Behavior:
The
UseBranchServiceshould use the branch ID associated with the logged-in manager, making the service more flexible and aligned with actual data.Additional Context:
If there are any changes required in the context or other parts of the application to support this dynamic fetching, please include them in this issue.
Labels: