stravachatApp.tsx17 matches
82const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
8384// Fetch images from backend instead of blob storage directly
85useEffect(() => {
86// Set default background color in case image doesn't load
89}
9091// Fetch avatar image
92fetch("/api/images/stevens.jpg")
93.then((response) => {
94if (response.ok) return response.blob();
103});
104105// Fetch wood background
106fetch("/api/images/wood.jpg")
107.then((response) => {
108if (response.ok) return response.blob();
129}, []);
130131const fetchMemories = useCallback(async () => {
132setLoading(true);
133setError(null);
134try {
135const response = await fetch(API_BASE);
136if (!response.ok) {
137throw new Error(`HTTP error! status: ${response.status}`);
154}
155} catch (e) {
156console.error("Failed to fetch memories:", e);
157setError(e.message || "Failed to fetch memories.");
158} finally {
159setLoading(false);
162163useEffect(() => {
164fetchMemories();
165}, [fetchMemories]);
166167const handleAddMemory = async (e: React.FormEvent) => {
176177try {
178const response = await fetch(API_BASE, {
179method: "POST",
180headers: { "Content-Type": "application/json" },
188setNewMemoryTags("");
189setShowAddForm(false);
190await fetchMemories();
191} catch (e) {
192console.error("Failed to add memory:", e);
199200try {
201const response = await fetch(`${API_BASE}/${id}`, {
202method: "DELETE",
203});
205throw new Error(`HTTP error! status: ${response.status}`);
206}
207await fetchMemories();
208} catch (e) {
209console.error("Failed to delete memory:", e);
231232try {
233const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234method: "PUT",
235headers: { "Content-Type": "application/json" },
240}
241setEditingMemory(null);
242await fetchMemories();
243} catch (e) {
244console.error("Failed to update memory:", e);
ChatEnhancedCommandPalette.tsx5 matches
170171try {
172// Fetch prompts and tools using the client pool
173const [promptsResult, toolsResult] = await Promise.all([
174clientPool.fetchPrompts(),
175clientPool.fetchTools(),
176]);
177210// Log any errors
211if (!promptsResult.success) {
212console.warn("[CMD] Failed to fetch prompts:", promptsResult.error);
213}
214if (!toolsResult.success) {
215console.warn("[CMD] Failed to fetch tools:", toolsResult.error);
216}
217} catch (error) {
TownieuseUser.tsx4 matches
8const [error, setError] = useState(null);
910const fetchData = async () => {
11try {
12const userEndpoint = new URL(USER_ENDPOINT, window.location.origin);
1314const res = await fetch(userEndpoint);
15const data = await res.json();
16if (!res.ok) {
3334useEffect(() => {
35fetchData();
36}, []);
3738return { data, loading, error, refetch: fetchData };
39}
40
TownieuseProject.tsx5 matches
9const [error, setError] = useState(null);
1011const fetchData = async () => {
12try {
13const projectEndpoint = new URL(PROJECT_ENDPOINT, window.location.origin);
17if (branchId) filesEndpoint.searchParams.append("branchId", branchId);
1819const { project } = await fetch(projectEndpoint).then((res) =>
20res.json()
21);
22const { files } = await fetch(filesEndpoint).then((res) => res.json());
2324setData({ project, files });
34useEffect(() => {
35if (!projectId) return;
36fetchData();
37}, [projectId, branchId]);
3839return { data, loading, error, refetch: fetchData };
40}
41
TownieuseProjects.tsx4 matches
8const [error, setError] = useState(null);
910const fetchData = async () => {
11try {
12const res = await fetch(ENDPOINT);
13const data = await res.json();
14if (!res.ok) {
3233useEffect(() => {
34fetchData();
35}, []);
3637return { data, loading, error, refetch: fetchData };
38}
39
TownieuseCreditBalance.tsx6 matches
6const [loading, setLoading] = useState(true);
78const fetchBalance = async () => {
9try {
10const response = await fetch("/api/credit-balance");
11if (response.ok) {
12const data = await response.json();
13setBalance(data.balance);
14} else {
15console.error("Failed to fetch balance");
16}
17} catch (err) {
18console.error("Error fetching balance:", err);
19} finally {
20setLoading(false);
2324useEffect(() => {
25fetchBalance();
26}, []);
2728return { balance, loading, refetch: fetchBalance };
29}
TownieuseCreateProject.tsx1 match
19setError(null);
20try {
21const res = await fetch(ENDPOINT, {
22method: "POST",
23headers: {
TownieuseCreateBranch.tsx1 match
12setData(null);
13setError(null);
14const res = await fetch(ENDPOINT, {
15method: "POST",
16body: JSON.stringify({
TownieuseBranches.tsx4 matches
7const [loading, setLoading] = useState(true);
89const fetchData = async () => {
10const endpoint = new URL(ENDPOINT, window.location.origin);
11endpoint.searchParams.append("projectId", projectId);
1213const res = await fetch(endpoint)
14.then(res => res.json());
15setData(res.branches);
19useEffect(() => {
20if (!projectId) return;
21fetchData();
22}, [projectId]);
2324return { data, loading, refetch: fetchData };
25}