Repository navigation
Connect front back #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect front back #205
Changes from all commits
3ba0b31
9eb1aee
4391fa8
ffe544a
991cdab
bdea949
879258b
4674d1b
b567e77
ab91286
a327d00
26123be
9108830
8e3c5c5
8600e23
5b73589
5b90594
1d6ef8b
0b611a5
f680a64
450c1c1
d329673
6a38afc
5f9056f
e9f8fb9
f284415
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| VITE_API_URL=http://localhost:4590 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| VITE_API_URL=https://fullstack-projects-wn6p.onrender.com |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ import { | |
| } from "@repo/scouting_types"; | ||
| import { isEmpty } from "@repo/array-functions"; | ||
| import { TierCosmeticBadge } from "../components/TierCosmeticBadge"; | ||
| import { Link } from "react-router-dom"; | ||
| import { API_URL } from "../../App"; | ||
|
|
||
| const leaderboardUrl = "/api/v1/leaderboard/"; | ||
|
|
||
|
|
@@ -17,9 +19,11 @@ export const scouterColor: Record<string, string> = { | |
| }; | ||
|
|
||
| export const fetchCompetitionData = async () => { | ||
| const response = await axios.get(leaderboardUrl).catch((errorText) => { | ||
| throw new Error(`Server Error: ${errorText}`); | ||
| }); | ||
| const response = await axios | ||
| .get(`${API_URL}${leaderboardUrl}`) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just do
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or concat or smthing |
||
| .catch((errorText) => { | ||
| throw new Error(`Server Error: ${errorText}`); | ||
| }); | ||
| const data = response.data; | ||
| return data.competitionScouters as CompetitionLeaderboard; | ||
| }; | ||
|
|
@@ -77,12 +81,12 @@ export const Leaderboard: React.FC = () => { | |
| <h2 className="text-emerald-400 font-black tracking-tighter text-xl uppercase"> | ||
| scouter Leaderboard | ||
| </h2> | ||
| <a | ||
| href="/scouting-pass" | ||
| <Link | ||
| to="/scouting-pass" | ||
| className="px-4 py-2 bg-white font-bold tracking-widest rounded-md hover:bg-gray-300 text-md" | ||
| > | ||
| View Scouting Pass | ||
| </a> | ||
| </Link> | ||
| </div> | ||
|
|
||
| <div className="p-2"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| import { API_URL } from "../../App"; | ||
|
|
||
| //בס"ד | ||
| const teamPageUrl = "/api/v1/teamPage/"; | ||
|
|
||
| export const fetchTeamNumbers = async () => { | ||
| const url = `${teamPageUrl}teamNumbers`; | ||
| const url = `${API_URL}${teamPageUrl}teamNumbers`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of concatinating every url with this, cant you use the vite config to make every fetch have this prefixed? Thats how it was when i did it |
||
|
|
||
| const response = await fetch(url, { | ||
| method: "GET", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| // בס"ד | ||
| /// <reference types="vite/client" /> | ||
| /// <reference types="vite-plugin-pwa/client" /> | ||
|
|
||
| interface ImportMetaEnv { | ||
| readonly VITE_API_URL: string; | ||
| } | ||
|
|
||
| interface ImportMeta { | ||
| readonly env: ImportMetaEnv; | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want to use env variables like this and not just put them in the .dev.env at the root project?