untitled-8939App.tsx7 matches
7import AchievementNotification from "./AchievementNotification.tsx";
89const API_BASE_URL = "/api";
1011const App: React.FC = () => {
46try {
47setLoading(true);
48const response = await fetch(`${API_BASE_URL}/users/${userId}`);
49
50if (!response.ok) {
66try {
67setLoading(true);
68const response = await fetch(`${API_BASE_URL}/users`, {
69method: "POST",
70headers: {
92
93try {
94const response = await fetch(`${API_BASE_URL}/users/${user.id}/envelopes`, {
95method: "POST",
96headers: {
115
116try {
117const response = await fetch(`${API_BASE_URL}/users/${user.id}/envelopes/${envelopeId}/allocate`, {
118method: "PUT",
119headers: {
139try {
140setLoading(true);
141const response = await fetch(`${API_BASE_URL}/users/${user.id}/transactions/import`, {
142method: "POST",
143headers: {
165
166try {
167const response = await fetch(`${API_BASE_URL}/users/${user.id}/transactions/${transactionId}/assign`, {
168method: "PUT",
169headers: {
untitled-8939index.html2 matches
10
11<!-- Fonts -->
12<link rel="preconnect" href="https://fonts.googleapis.com">
13<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
14<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
15
16<!-- Error catching -->
untitled-8939README.md1 match
27│ ├── database/ # SQLite database setup and queries
28│ ├── parsers/ # CSV parsing logic
29│ └── index.ts # Main API entry point
30├── frontend/
31│ ├── components/ # React components
untitled-2833index.ts5 matches
388}
389
390// In a real application, you would call an API here to generate the script
391// For now, we'll just simulate script generation
392
393alert('Đang tạo kịch bản, vui lòng đợi...');
394
395// Simulate API delay
396setTimeout(() => {
397// Switch to the "Tạo Audio" tab
508const speed = document.getElementById('audio-speed').value;
509
510// In a real application, you would call an API here
511// For now, we'll just simulate audio generation
512
513alert('Đang tạo audio, vui lòng đợi...');
514
515// Simulate API delay
516setTimeout(() => {
517// Show audio player
612// Set up script flow
613document.getElementById('generate-script').addEventListener('click', function() {
614// In a real app, this would be the generated script from an API
615const mockGeneratedScript = "Đây là nội dung kịch bản được tạo tự động dựa trên chủ đề, số từ và ngữ cảnh bạn đã chọn. Trong một ứng dụng thực tế, nội dung này sẽ được tạo bởi AI hoặc một dịch vụ tạo văn bản.";
616
reactHonoStarterindex.ts2 matches
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
1314// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
1617// Unwrap and rethrow Hono errors as the original error
pushupappindex.html2 matches
5<meta name="viewport" content="width=device-width, initial-scale=1.0">
6<title>Push-Up Counter</title>
7<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
8<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
9<link rel="stylesheet" href="/styles.css">
10</head>
44// Load the face landmarks detection model
45model = await faceLandmarksDetection.load(
46faceLandmarksDetection.SupportedPackages.mediapipeFacemesh,
47{ maxFaces: 1 }
48);
stockAppScanBillView.tsx10 matches
3import {useState, useEffect} from "https://esm.sh/preact@10.19.6/hooks"
4import {User, SupplierBill, Product, Category, CreateProductPayload, SupplierBillItem as SharedSupplierBillItem, BillScanResponse} from "../../shared/types.ts"
5// import * as apiClient from "../apiClient.ts"; // Will be removed
67interface ScanBillViewProps {
19}
2021// Moved from apiClient.ts
22interface ConfirmBillFrontendPayload {
23reviewedItems: Array<{
33}>
34}
35const API_BASE_URL = "/api"
3637const ScanBillView: FunctionComponent<ScanBillViewProps> = ({currentUser}) => {
50if (step === "review" && currentUser) {
51// Fetch products
52fetch(`${API_BASE_URL}/products`, {
53headers: {"Accept": "application/json", "X-User-Id": currentUser.id}
54})
6768// Fetch categories
69fetch(`${API_BASE_URL}/categories`, {
70headers: {"Accept": "application/json", "X-User-Id": currentUser.id} // X-User-Id might not be strictly needed by backend for GET categories
71})
108109// Direct fetch for uploadBill
110let response = await fetch(`${API_BASE_URL}/bills/upload`, {
111method: "POST",
112headers: {
125126// Direct fetch for processBillAI
127response = await fetch(`${API_BASE_URL}/bills/process/${uploadResult.billId}`, {
128method: "POST",
129headers: {
139// The backend returns SupplierBill, but the AI service returns BillScanResponse.
140// The billService.processBillWithAI returns SupplierBill.
141// The apiClient.processBillAI was typed to return SupplierBill.
142// Let's assume the backend /api/bills/process/:billId returns SupplierBill
143const billData: SupplierBill = await response.json()
144219220// Direct fetch for confirmBill
221const response = await fetch(`${API_BASE_URL}/bills/${uploadedBillId}/confirm`, {
222method: "POST",
223headers: {
32backend.use("*", cors()) // Allow all origins for demo purposes
33backend.use("*", secureHeaders())
34// CSRF protection can be added if using cookie-based sessions, might be overkill for this API demo if using token auth
35// app.use("*", csrf());
3654// Error handler - Unwrap Hono errors to see original error details
55backend.onError((err, c) => {
56console.error("API Error:", err)
57// Check if it's an HTTPError from Hono, otherwise it's an internal error
58if (err && typeof err === 'object' && 'getResponse' in err && typeof err.getResponse === 'function') {
477// The payload for updateSupplierBillWithAIData expects a full BillScanResponse structure.
478// This might need a dedicated service method if the payload is different.
479console.warn(`PUT /api/bills/:billId - Manual bill update logic might need a dedicated service method. Reusing updateSupplierBillWithAIData for now if payload matches.`)
480const updatedBill = await db.updateSupplierBillWithAIData(billId, payload as BillScanResponse, userId) // Casting payload, ensure it's compatible
481
stockAppinventoryApp.http.tsx2 matches
5// import {serveStatic} from "https://esm.sh/hono@4.4.6/deno" // Unused and causing error
6import {readFile, parseProject} from "https://esm.town/v/std/utils@85-main/index.ts" // Val Town utils
7import backendRoutes from "./backend/api.ts"
8const app = new Hono()
9949596app.route("/api", backendRoutes)
9798