untitled-2689main.tsx13 matches
604const triggerTelegramInteraction = async (chatId) => {
605try {
606const response = await fetch("/handle-telegram-interaction", {
607method: "POST",
608headers: { "Content-Type": "application/json" },
621};
622623const fetchUserBalance = async () => {
624let userId = null;
625let isTelegramEnv = false;
674if (userId) {
675try {
676const response = await fetch(`/get-balance?uid=${userId}`);
677if (!response.ok) {
678try {
699}
700} catch (error) {
701console.error("Failed to fetch or process balance:", error.toString());
702setBalance("Error");
703}
704} else {
705console.error("User ID could not be determined for balance fetching.");
706setBalance("--.--");
707}
731window.Telegram.WebApp.ready();
732}
733fetchUserBalance();
734} else if (isTelegramWebAppPresent) {
735console.log(
736"Telegram script present, but user data not immediately available or ready() pending. Setting timeout for balance fetch.",
737);
738if (window.Telegram.WebApp.ready) {
739window.Telegram.WebApp.ready();
740}
741scriptLoadTimeoutId = setTimeout(fetchUserBalance, 300);
742} else {
743console.log("Not in Telegram environment. Proceeding as web user for balance fetch.");
744fetchUserBalance();
745}
746}
882setShowSpinner(true);
883884const response = await fetch("/save-credentials", {
885method: "POST",
886headers: { "Content-Type": "application/json" },
1884const sendActualTelegramAPIMessage = async (botToken, chatId, text, parseMode = "Markdown") => {
1885try {
1886const response = await fetch(`https://api.telegram.org/bot${botToken}/sendMessage`, {
1887method: "POST",
1888headers: { "Content-Type": "application/json" },
2194if (confirm('Are you sure you want to unban this user?')) {
2195try {
2196const response = await fetch('/unban-telegram-user', {
2197method: 'POST',
2198headers: { 'Content-Type': 'application/json' },
personalShopperindex.ts7 matches
304async function logout(): Promise<void> {
305try {
306await fetch("/auth/logout", { method: "POST" });
307window.location.reload();
308} catch (error) {
318319try {
320const response = await fetch("/api/user/location", {
321method: "PUT",
322headers: { "Content-Type": "application/json" },
349350try {
351const response = await fetch(
352`/api/locations/search?zipCode=${
353encodeURIComponent(
428): Promise<void> {
429try {
430const response = await fetch("/api/user/location", {
431method: "PUT",
432headers: { "Content-Type": "application/json" },
482if (userData && userData.preferredLocationId) {
483try {
484const response = await fetch(
485`/api/locations/${userData.preferredLocationId}`,
486);
502async function loadGuidanceCount(): Promise<void> {
503try {
504const response = await fetch("/api/guidance");
505const guidance = await response.json();
506document.getElementById("guidance-count")!.textContent = guidance.length.toString();
512async function loadSelectionsCount(): Promise<void> {
513try {
514const response = await fetch("/api/selections");
515const selections = await response.json();
516document.getElementById("selections-count")!.textContent = selections.length.toString();
73});
7475export default app.fetch;
76
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
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}