191. The user fills out the form with their professional information
202. They select what type of content they want to generate
213. The form data is sent to the backend API
224. The generated content is displayed in the result container
235. The user can copy the content or regenerate it if needed
202
203 try {
204 // Send request to API
205 const response = await fetch('/api/generate', {
206 method: 'POST',
207 headers: {
3import { useState, useEffect } from "https://esm.sh/preact@10.19.6/hooks";
4import { User, Product, InventoryBatch } from "../../shared/types.ts";
5// import * as apiClient from "../apiClient.ts"; // Will be removed
6
7const API_BASE_URL = "/api";
8
9interface ViewInventoryViewProps {
28 if (searchTerm) queryParams.append("search", searchTerm);
29 const queryString = queryParams.toString();
30 let response = await fetch(`${API_BASE_URL}/products${queryString ? `?${queryString}` : ""}`, {
31 headers: { "Accept": "application/json", "X-User-Id": currentUser.id } // X-User-Id might not be strictly needed by backend for GET products
32 });
42 try {
43 // Direct fetch for total product quantity
44 const qtyResponse = await fetch(`${API_BASE_URL}/inventory/products/${p.id}/total`, {
45 headers: { "Accept": "application/json", "X-User-Id": currentUser.id } // X-User-Id might not be strictly needed
46 });
82 try {
83 // Direct fetch for inventory batches by product
84 const response = await fetch(`${API_BASE_URL}/inventory/batches?productId=${product.id}`, {
85 headers: { "Accept": "application/json", "X-User-Id": currentUser.id } // X-User-Id might not be strictly needed
86 });
3import { useState, useEffect } from "https://esm.sh/preact@10.19.6/hooks";
4import { User, InventoryBatch } from "../../shared/types.ts";
5// import * as apiClient from "../apiClient.ts"; // Will be removed
6
7const API_BASE_URL = "/api";
8
9interface ExpiringItemsViewProps {
30 if (filterDays !== undefined) queryParams.append("days", String(filterDays));
31 const queryString = queryParams.toString();
32 const response = await fetch(`${API_BASE_URL}/inventory/expiring${queryString ? `?${queryString}` : ""}`, {
33 headers: { "Accept": "application/json", "X-User-Id": currentUser.id } // X-User-Id might not be strictly needed
34 });
1import { useState, useEffect } from "react";
2
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
20 SUM(num_images) as total_images
21 FROM ${USAGE_TABLE}
22 WHERE our_api_token = 1
23 GROUP BY user_id, username
24 ORDER BY total_price DESC
1import { useState, useEffect } from "react";
2
3const PROJECT_ENDPOINT = "/api/project";
4const FILES_ENDPOINT = "/api/project-files";
5
6export function useProject(projectId: string, branchId?: string) {
1import { useState, useEffect } from "react";
2
3const ENDPOINT = "/api/projects-loader";
4
5export function useProjects() {
1import { useState, useEffect } from "react";
2
3const ENDPOINT = "/api/create-project";
4
5export function useCreateProject() {
1import { useState, useEffect } from "react";
2
3const ENDPOINT = "/api/create-branch";
4
5export function useCreateBranch(projectId: string) {