const fs = require('fs');
const child_process = require('child_process');
try {
  const original = child_process.execSync('git show HEAD:src/services/fiestaQueries.ts', { encoding: 'utf-8' });
  let newContent = original.replace(
    'export function useFiestaStockRequests(opts: {',
    `export function useFiestaStockRequests(opts: {
  tenantid: number;
  locationid?: number;
  status?: string;
  date?: string;
  pageno?: number;
  pagesize?: number;
}) {
  return useQuery({
    queryKey: fiestaKeys.stockRequests(opts),
    queryFn: () => getStockRequests(opts),
    enabled: Boolean(opts.tenantid),
  });
}

// @ts-ignore
export function old_useFiestaStockRequests(opts: {`
  );
  fs.writeFileSync('src/services/fiestaQueries.ts', newContent);
  console.log('Restored and patched');
} catch (e) {
  console.error(e);
}
