diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d6038673..5fe68015 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -44,8 +44,8 @@ jobs: - name: Write .env.production working-directory: frontend run: | - echo "REACT_APP_GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }}" >> .env.production - echo "REACT_APP_BACKEND_URL=${{ secrets.BACKEND_URL }}" >> .env.production + echo "VITE_APP_GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }}" >> .env.production + echo "VITE_APP_BACKEND_URL=${{ secrets.BACKEND_URL }}" >> .env.production - name: Build frontend run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 49b08bc9..3f2a6cb1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,7 +113,7 @@ export AWS_SECRET_ACCESS_KEY=test export AWS_ENDPOINT_URL_S3='http://127.0.0.1:4566' # For letting the frontend know the backend URL. -export REACT_APP_BACKEND_URL='http://127.0.0.1:8080' +export VITE_APP_BACKEND_URL='http://127.0.0.1:8080' # For SMTP export SMTP_HOST='smtp.gmail.com' @@ -169,13 +169,13 @@ npm run format ### Google Client ID -You will need to set `REACT_APP_GOOGLE_CLIENT_ID`. To do this, first create a Google client id (see [this LogRocket post](https://blog.logrocket.com/guide-adding-google-login-react-app/)). Then create a `.env.local` file in the `frontend` directory and add the following line: +You will need to set `VITE_APP_GOOGLE_CLIENT_ID`. To do this, first create a Google client id (see [this LogRocket post](https://blog.logrocket.com/guide-adding-google-login-react-app/)). Then create a `.env.local` file in the `frontend` directory and add the following line: ``` -REACT_APP_GOOGLE_CLIENT_ID=your-client-id +VITE_APP_GOOGLE_CLIENT_ID=your-client-id ``` -Additionally, you should set `REACT_APP_BACKEND_URL` to the URL of the FastAPI backend. This should be `http://127.0.0.1:8080` when developing locally. +Additionally, you should set `VITE_APP_BACKEND_URL` to the URL of the FastAPI backend. This should be `http://127.0.0.1:8080` when developing locally. ## Testing diff --git a/env.sh.example b/env.sh.example index 25d3224d..0f326f1e 100644 --- a/env.sh.example +++ b/env.sh.example @@ -8,7 +8,7 @@ export AWS_SECRET_ACCESS_KEY=test export AWS_ENDPOINT_URL_S3='http://127.0.0.1:4566' # For letting the frontend know the backend URL. -export REACT_APP_BACKEND_URL='http://127.0.0.1:8080' +export VITE_APP_BACKEND_URL='http://127.0.0.1:8080' # For SMTP export SMTP_HOST='smtp.gmail.com' diff --git a/frontend/package.json b/frontend/package.json index 48ff93aa..bfffb3df 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,7 +4,7 @@ "private": true, "main": "src/index.tsx", "scripts": { - "dev": "vite --host 127.0.0.1", + "dev": "vite --host 127.0.0.1 --port 3000 --open", "build": "tsc && vite build", "preview": "vite preview", "format": "prettier --write src/ && eslint 'src/**/*.{js,jsx,ts,tsx}' --fix", diff --git a/frontend/src/components/auth/LoginForm.tsx b/frontend/src/components/auth/LoginForm.tsx index af01622b..1eab65e8 100644 --- a/frontend/src/components/auth/LoginForm.tsx +++ b/frontend/src/components/auth/LoginForm.tsx @@ -22,7 +22,6 @@ const LoginForm = () => { const onSubmit: SubmitHandler = async (data: LoginType) => { // TODO: Add an api endpoint to send the credentials details to backend and email verification. - console.log(data); }; return ( diff --git a/frontend/src/components/auth/SignupForm.tsx b/frontend/src/components/auth/SignupForm.tsx index f02a8557..b49ffffc 100644 --- a/frontend/src/components/auth/SignupForm.tsx +++ b/frontend/src/components/auth/SignupForm.tsx @@ -25,7 +25,6 @@ const SignupForm = () => { const onSubmit: SubmitHandler = async (data: SignupType) => { // TODO: Add an api endpoint to send the credentials details to backend and email verification. - console.log(data); }; return ( diff --git a/frontend/src/components/listing/ListingSTLs.tsx b/frontend/src/components/listing/ListingSTLs.tsx index e0f75853..ae91ea73 100644 --- a/frontend/src/components/listing/ListingSTLs.tsx +++ b/frontend/src/components/listing/ListingSTLs.tsx @@ -20,8 +20,14 @@ interface SingleStlViewerProps { const SingleStlViewer = (props: SingleStlViewerProps) => { const { url } = props; + const { addErrorAlert } = useAlertQueue(); + + const handleError = (error) => { + addErrorAlert(error); + }; + // return ( - // console.log(error)}> + // // // // diff --git a/frontend/src/constants/backend.ts b/frontend/src/constants/backend.ts deleted file mode 100644 index 19959448..00000000 --- a/frontend/src/constants/backend.ts +++ /dev/null @@ -1,13 +0,0 @@ -export const BACKEND_URL = - import.meta.env.REACT_APP_BACKEND_URL || "http://127.0.0.1:8080"; - -// eslint-disable-next-line -export const humanReadableError = (error: any | undefined) => { - if (typeof error === "string") { - return error; - } - if (error?.message) { - return error.message; - } - return "An unknown error occurred"; -}; diff --git a/frontend/src/constants/env.ts b/frontend/src/constants/env.ts new file mode 100644 index 00000000..16f7c6ab --- /dev/null +++ b/frontend/src/constants/env.ts @@ -0,0 +1,2 @@ +export const BACKEND_URL = + import.meta.env.VITE_APP_BACKEND_URL || "http://127.0.0.1:8080"; diff --git a/frontend/src/hooks/useAlertQueue.tsx b/frontend/src/hooks/useAlertQueue.tsx index f5a192b7..009f0c13 100644 --- a/frontend/src/hooks/useAlertQueue.tsx +++ b/frontend/src/hooks/useAlertQueue.tsx @@ -6,13 +6,22 @@ import { useState, } from "react"; -import { humanReadableError } from "constants/backend"; - import Toast from "components/ui/Toast"; const DELAY = 3000; const MAX_ALERTS = 5; +// eslint-disable-next-line +export const humanReadableError = (error: any | undefined) => { + if (typeof error === "string") { + return error; + } + if (error?.message) { + return error.message; + } + return "An unknown error occurred"; +}; + type AlertType = "error" | "success" | "info"; interface AlertQueueContextProps { diff --git a/frontend/src/hooks/useAuth.tsx b/frontend/src/hooks/useAuth.tsx index ea3cae27..424c308b 100644 --- a/frontend/src/hooks/useAuth.tsx +++ b/frontend/src/hooks/useAuth.tsx @@ -7,7 +7,7 @@ import { } from "react"; import { useNavigate } from "react-router-dom"; -import { BACKEND_URL } from "constants/backend"; +import { BACKEND_URL } from "constants/env"; import type { paths } from "gen/api"; import api from "hooks/api"; import createClient, { Client } from "openapi-fetch"; @@ -50,6 +50,8 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => { getLocalStorageAuth(), ); + console.log(BACKEND_URL); + const client = createClient({ baseUrl: BACKEND_URL, }); diff --git a/frontend/src/vite-env.d.ts b/frontend/src/vite-env.d.ts new file mode 100644 index 00000000..3eaa257a --- /dev/null +++ b/frontend/src/vite-env.d.ts @@ -0,0 +1,7 @@ +interface ImportMetaEnv { + readonly VITE_APP_BACKEND_URL: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/store/app/crud/base.py b/store/app/crud/base.py index 403b4755..c0baf0ef 100644 --- a/store/app/crud/base.py +++ b/store/app/crud/base.py @@ -278,8 +278,6 @@ async def _get_items_from_secondary_index_batch( else: chunk_ids_to_items[item_id] = [item] - print(chunk_ids_to_items) - # Adds the items to the list. items += [chunk_ids_to_items.get(id, []) for id in chunk]