542
543 try {
544 const response = await fetch('/api/bookings', {
545 method: 'POST',
546 headers: {
12
13The routes are defined in `routes` and can include data loading and actions.
14The `/about` route includes a loader that fetches data from the `api.tsx` server, which returns a JSON response.
15The About page uses the `useLoaderData` hook to render the data from the loader in the page.
16
75
76async function catsLoader () {
77 const data = await fetch(API_URL)
78 .then(res => res.json());
79 return data;
437 try {
438 // Send message to API
439 const response = await fetch('/api/chat', {
440 method: 'POST',
441 headers: {
503 try {
504 // Send request to generate image
505 const response = await fetch('/api/generate-image', {
506 method: 'POST',
507 headers: {
2 const url = new URL(req.url);
3 url.host = `02c3dc47-4c6a-4818b-84ae-d22210c9d4cb.cloudflarepreviews.com`;
4 const ver = await fetch(
5 url,
6 {
1const script = `
2export default {
3 async fetch(request, env, ctx) {
4 const url = new URL(request.url);
5 url.host = "embed-hono.lime4042.workers.dev";
6 console.log(url)
7 const r = await fetch(url,request);
8 return new Response((r).body,r);
9 },
19 files.append("uuid", uuid);
20 files.append("token", key);
21 const upload = await fetch(
22 `https://temptemp-workers.web.val.run/pushCode?uuid=${uuid}&token=${key}`,
23 {
42
43 try {
44 const response = await fetch("/ask", {
45 method: "POST",
46 body: JSON.stringify({ question }),
23 const [paymentMethodFilter, setPaymentMethodFilter] = useState<PaymentMethodFilter>(null);
24
25 // Fetch sales and payment data
26 const fetchSalesData = async (startDate: Date, endDate: Date) => {
27 setIsLoading(true);
28 setError(null);
32 const dateTo = endDate.toISOString().split('T')[0];
33
34 // Fetch both data sets in parallel
35 const [salesResponse, paymentsResponse] = await Promise.all([
36 getSaleWaiters(dateFrom, dateTo),
39
40 if (salesResponse && paymentsResponse) {
41 console.log('Fetched sales data:', salesResponse.length, 'records');
42 console.log('Fetched payment data:', paymentsResponse.length, 'records');
43
44 setSalesData(salesResponse);
49 }
50 } catch (error) {
51 setError('Failed to fetch sales data. Please try again.');
52 console.error('Fetch error:', error);
53 } finally {
54 setIsLoading(false);
130 error,
131 paymentMethodFilter,
132 fetchSalesData,
133 filterByCashPayment,
134 filterByBankPayment,
144 error,
145 paymentMethodFilter,
146 fetchSalesData,
147 filterByCashPayment,
148 filterByBankPayment,
174 const startDate = new Date();
175 startDate.setDate(startDate.getDate() - 6);
176 fetchSalesData(startDate, endDate);
177 }, []);
178
197 <View className='mb-6'>
198 <DateRangeSelector
199 onDateRangeChange={fetchSalesData}
200 additionalButtons={paymentMethodButtons}
201 />
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
27
28// Export the app for HTTP val
29export default app.fetch;