new changes in api base url

This commit is contained in:
2026-07-09 15:49:45 +05:30
parent 7cd0ae85ef
commit 4ef9cd9085
29 changed files with 2714 additions and 1191 deletions

View File

@@ -192,10 +192,10 @@ export default function InventoryView({
const reqsMap: Record<number, any> = {};
stockRequestsQ.data.forEach((req: any) => {
if (!reqsMap[req.locationid]) {
const loc = locations.find(l => l.locationid === req.locationid);
const loc = locations.find(l => String(l.locationid) === String(req.locationid));
reqsMap[req.locationid] = {
locationid: req.locationid,
locationname: loc ? loc.locationname : `Outlet #${req.locationid}`,
locationname: req.locationname || (loc ? loc.locationname : `Outlet #${req.locationid}`),
picks: {}
};
}
@@ -215,6 +215,12 @@ export default function InventoryView({
}
}, [activeTab, locations, stockRequestsQ.data]);
useEffect(() => {
if (activeTab === 'requests') {
stockRequestsQ.refetch();
}
}, [activeTab, stockRequestsQ]);
const updateStockRequestMutation = useFiestaUpdateStockRequest();
const updateProductRequestStatus = (locationid: number, productid: string, status: 'Approved' | 'Rejected' | 'Pending') => {
@@ -386,40 +392,38 @@ export default function InventoryView({
}
};
const flattenedRequests = useMemo(() => {
const list: any[] = [];
storeRequests.forEach(req => {
Object.entries(req.picks).forEach(([productid, pickData]) => {
let product = products.find(p => String(p.id) === String(productid));
if (!product) {
const liveMatch = liveMasterCatalog.find((r: any) => String(r.productid) === String(productid));
if (liveMatch) {
product = {
id: String(liveMatch.productid),
name: String(liveMatch.productname || 'Unknown'),
sku: String(liveMatch.sku || `SKU-${liveMatch.productid}`),
image: String(liveMatch.productimage || 'https://images.unsplash.com/photo-1542838132-92c53300491e?auto=format&fit=crop&q=80&w=200'),
category: String(liveMatch.categoryname || 'Uncategorized'),
} as any;
} else {
product = MOCK_GLOBAL_CATALOG.find(p => String(p.id) === String(productid)) as any;
}
}
list.push({
locationid: req.locationid,
locationname: req.locationname,
productid,
product,
pickData
});
});
});
// Sort by requestedAt desc
let sortedList = list.sort((a, b) => new Date(b.pickData.requestedAt).getTime() - new Date(a.pickData.requestedAt).getTime());
if (requestStoreFilter !== 'All Stores') {
sortedList = sortedList.filter(req => req.locationname === requestStoreFilter);
}
return sortedList;
}, [storeRequests, products, requestStoreFilter]);
return storeRequests
.filter(r => requestStoreFilter === 'All Stores' || r.locationname === requestStoreFilter)
.flatMap(store => {
return Object.entries(store.picks)
.filter(([_, pick]) => String(pick.status).toLowerCase() === 'pending')
.map(([productId, pick]) => {
let product = products.find(p => String(p.id) === String(productId));
if (!product) {
const liveMatch = liveMasterCatalog.find((r: any) => String(r.productid) === String(productId));
if (liveMatch) {
product = {
id: String(liveMatch.productid),
name: String(liveMatch.productname || 'Unknown'),
sku: String(liveMatch.sku || `SKU-${liveMatch.productid}`),
image: String(liveMatch.productimage || 'https://images.unsplash.com/photo-1542838132-92c53300491e?auto=format&fit=crop&q=80&w=200'),
category: String(liveMatch.categoryname || 'Uncategorized'),
} as any;
} else {
product = MOCK_GLOBAL_CATALOG.find(p => String(p.id) === String(productId)) as any;
}
}
return {
locationid: store.locationid,
locationname: store.locationname,
productid: productId,
product,
pickData: pick
};
});
})
.sort((a, b) => new Date(b.pickData.requestedAt).getTime() - new Date(a.pickData.requestedAt).getTime());
}, [storeRequests, products, requestStoreFilter, liveMasterCatalog]);
const requestingStores = useMemo(() => {
return Array.from(new Set(locations.map(l => l.locationname))).sort();