Skip to content

Commit

Permalink
more formatting / vite stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Aug 7, 2024
1 parent 9b5f866 commit a1967f7
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion env.sh.example
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/auth/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const LoginForm = () => {

const onSubmit: SubmitHandler<LoginType> = async (data: LoginType) => {
// TODO: Add an api endpoint to send the credentials details to backend and email verification.
console.log(data);
};

return (
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/auth/SignupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const SignupForm = () => {

const onSubmit: SubmitHandler<SignupType> = async (data: SignupType) => {
// TODO: Add an api endpoint to send the credentials details to backend and email verification.
console.log(data);
};

return (
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/listing/ListingSTLs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ interface SingleStlViewerProps {
const SingleStlViewer = (props: SingleStlViewerProps) => {
const { url } = props;

const { addErrorAlert } = useAlertQueue();

const handleError = (error) => {
addErrorAlert(error);
};

// return (
// <Canvas onError={(error) => console.log(error)}>
// <Canvas onError={handleError}>
// <ambientLight />
// <pointLight position={[10, 10, 10]} />
// <Model url={url} />
Expand Down
13 changes: 0 additions & 13 deletions frontend/src/constants/backend.ts

This file was deleted.

2 changes: 2 additions & 0 deletions frontend/src/constants/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const BACKEND_URL =
import.meta.env.VITE_APP_BACKEND_URL || "http://127.0.0.1:8080";
13 changes: 11 additions & 2 deletions frontend/src/hooks/useAlertQueue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/hooks/useAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -50,6 +50,8 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => {
getLocalStorageAuth(),
);

console.log(BACKEND_URL);

const client = createClient<paths>({
baseUrl: BACKEND_URL,
});
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface ImportMetaEnv {
readonly VITE_APP_BACKEND_URL: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
2 changes: 0 additions & 2 deletions store/app/crud/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit a1967f7

Please sign in to comment.