faq_chatbotmain.tsx2 matches
15setIsLoading(true);
16try {
17const response = await fetch(`/search?q=${encodeURIComponent(searchTerm)}`);
18const data = await response.json();
19setResults(data);
3940try {
41const response = await fetch('/chat', {
42method: 'POST',
43headers: {
2627useEffect(() => {
28const fetchProjects = async () => {
29try {
30setLoading(true);
34setProjects(projects || []);
35} catch (err) {
36console.error("Error fetching projects:", err);
37setError("Failed to load projects. Please try again later.");
38} finally {
41};
4243fetchProjects();
44}, []);
4564}
65} catch (err) {
66console.error("Error fetching project details:", err);
67setError("Failed to load project details. Please try again later.");
68}
22const username = userInfo.username;
2324// Now fetch all public projects
25const projects = await valtown.getUserProjects(username, { privacy: "public" });
2627return c.json(projects);
28} catch (error) {
29console.error("Error fetching projects:", error);
30return c.json({ error: "Failed to fetch projects" }, 500);
31}
32});
40return c.json(filesData);
41} catch (error) {
42console.error("Error fetching project files:", error);
43return c.json({ error: "Failed to fetch project files" }, 500);
44}
45});
58return c.json(fileData);
59} catch (error) {
60console.error("Error fetching file content:", error);
61return c.json({ error: "Failed to fetch file content" }, 500);
62}
63});
117});
118119export default app.fetch;
101102try {
103const response = await fetch("/analyze", {
104method: "POST",
105body: formData,
4748try {
49const response = await fetch("/support", {
50method: "POST",
51body: JSON.stringify({ query: input })
10const handleSubmit = async (e) => {
11e.preventDefault();
12const response = await fetch("/job", {
13method: "POST",
14headers: { "Content-Type": "application/json" },
7273useEffect(() => {
74fetchMessages();
75const interval = setInterval(fetchMessages, 5000);
76return () => clearInterval(interval);
77}, []);
7879const fetchMessages = async () => {
80const response = await fetch("/messages");
81if (response.ok) {
82const data = await response.json();
87const sendMessage = async (e) => {
88e.preventDefault();
89const response = await fetch("/messages", {
90method: "POST",
91headers: { "Content-Type": "application/json" },
94if (response.ok) {
95setNewMessage("");
96fetchMessages();
97}
98};
125const [jobs, setJobs] = useState([]);
126127const fetchJobs = async () => {
128const response = await fetch("/job");
129if (response.ok) {
130const data = await response.json();
134135useEffect(() => {
136fetchJobs();
137}, []);
138142<div className="app-container">
143<div className="left-panel">
144<JobPostingForm onSubmit={fetchJobs} />
145<JobBoard jobs={jobs} />
146</div>
8182try {
83const response = await fetch('/submit-order', {
84method: 'POST',
85headers: { 'Content-Type': 'application/json' },
1011async function refreshGmailAccessToken(refreshToken: string) {
12const response = await fetch("https://oauth2.googleapis.com/token", {
13method: "POST",
14headers: { "Content-Type": "application/x-www-form-urlencoded" },
2526async function getUnreadEmails(accessToken: string) {
27const response = await fetch(
28"https://gmail.googleapis.com/gmail/v1/users/me/messages?q=is:unread",
29{
3940async function getEmailDetails(messageId: string, accessToken: string) {
41const response = await fetch(
42`https://gmail.googleapis.com/gmail/v1/users/me/messages/${messageId}`,
43{
5354async function sendWhatsAppMessage(body: string) {
55const response = await fetch("https://api.twilio.com/2010-04-01/Accounts/" + TWILIO_ACCOUNT_SID + "/Messages.json", {
56method: "POST",
57headers: {
dreamyOliveNewtmain.tsx13 matches
23const { latitude, longitude } = position.coords;
24setLocation({ latitude, longitude });
25fetchWeather(latitude, longitude);
26},
27(err) => {
28// Fallback to Johannesburg if geolocation fails
29setError(`Geolocation error: ${err.message}`);
30fetchWeather(-26.2041, 28.0473);
31},
32{
38} else {
39// Fallback to Johannesburg if geolocation not supported
40fetchWeather(-26.2041, 28.0473);
41}
42}, []);
4344async function fetchCoordinates(cityName) {
45try {
46const geoResponse = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(cityName)}&count=1&language=en&format=json`);
47const geoData = await geoResponse.json();
48
59}
6061async function fetchWeather(lat, lon) {
62try {
63setLoading(true);
64const response = await fetch(
65`https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}¤t_weather=true&hourly=temperature_2m,temperature_fahrenheit,weathercode,apparent_temperature,precipitation_probability,windspeed_10m,uv_index,relativehumidity_2m&daily=weathercode,temperature_2m_max,temperature_2m_min,sunrise,sunset,uv_index_max&timezone=Africa/Johannesburg`
66);
78setError(null);
79} catch (err) {
80setError(`Weather fetch error: ${err.message}`);
81setLoading(false);
82}
93async (position) => {
94const { latitude, longitude } = position.coords;
95await fetchWeather(latitude, longitude);
96},
97(err) => {
98// Fallback to Johannesburg coordinates
99const defaultCoords = { latitude: -26.2041, longitude: 28.0473 };
100fetchWeather(defaultCoords.latitude, defaultCoords.longitude);
101setError(`Geolocation error: ${err.message}`);
102},
117118try {
119const coords = await fetchCoordinates(cityInput);
120if (coords) {
121await fetchWeather(coords.latitude, coords.longitude);
122}
123} catch (err) {
130const newUnit = temperatureUnit === 'celsius' ? 'fahrenheit' : 'celsius';
131setTemperatureUnit(newUnit);
132fetchWeather(location.latitude, location.longitude);
133};
134
1920try {
21const response = await fetch("/send-email", {
22method: "POST",
23headers: {