Skip to content

Conversation

@yoavs8
Copy link

@yoavs8 yoavs8 commented Dec 7, 2025

the project makes a schedule for playoff and events that happened and will happen

Comment on lines 1 to 35
// בס"ד
// const eventsInYear = t.type({// if you need this
// address: t.string,
// city: t.string,
// country: t.string,
// district: t.unknown,
// division_keys: t.array(t.string),
// end_date: t.string,
// event_code: t.string,
// event_type: t.number,
// event_type_string: t.string,
// first_event_code: t.string,
// first_event_id: t.unknown,
// gmaps_place_id: t.string,
// gmaps_url: t.string,
// key: t.string,
// lat: t.number,
// lng: t.number,
// location_name: t.string,
// name: t.string,
// parent_event_key: t.unknown,
// playoff_type: t.number,
// playoff_type_string: t.string,
// postal_code: t.string,
// remap_teams: t.unknown,
// short_name: t.string,
// start_date: t.string,
// state_prov: t.string,
// timezone: t.string,
// webcasts: t.array(
// t.type({
// channel: t.string,
// type: t.string,
// })
// ),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is unused, why is this here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ask oded


app.use(express.static(distDirectory));

app.get(/^(.*)$/, (req, res) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is magic, I don't like magic

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, consider copying what is in the updated master branch. either look at it through github or git pull and merge

@YoniKiriaty YoniKiriaty changed the title close to end added alot of things including css and html waiting for cr Playoff Schedule Dec 9, 2025
Copy link
Contributor

@YoniKiriaty YoniKiriaty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought this was good then I saw the App.tsx

"type": "shell",
"command": "./node_modules/.bin/dotenv -e .dev.env -e .public.env -e .secret.env -- 'turbo run dev --filter=${input:project}-frontend --filter=${input:project}-backend'"
"command": "./node_modules/.bin/dotenv -e .dev.env -e .public.env -e .secret.env -- 'turbo run dev --filter=${input:project}-frontend --filter=${input:project}-backend'",
"problemMatcher": []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider removing this.

Comment on lines +18 to +20
const statusBadServer = 500;
const statusGood = 200;
const statusBadUser = 400;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using the status codes library http-status-codes:
use StatusCodes.OK instead of statusGood

const statusBadUser = 400;

// enter a valid api key
const apiKey = "YOUR_API_KEY";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using enviromental variables to pass in sensitive information. create a .secret.env file near the .public.env file (the .secret.env file is already gitignored and used in the files). consider looking at the .public.env at how to make enviromental variables.

Suggested change
const apiKey = "YOUR_API_KEY";
const apiKey = process.env.TBA_API_KEY ?? "YOUR_API_KEY";

Comment on lines 26 to 61
export const fetchData = async (url: string): Promise<unknown> => {
const response = await fetch(url, {
method: "GET",
headers: {
"X-TBA-Auth-Key": apiKey,
"Content-Type": "application/json",
},
mode: "cors",
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log("TBA data:", data);
return data;

};


app.get("/fetch", async (req, res) => {
try {
const encodedUrl = req.query.url;
if (!encodedUrl || typeof encodedUrl !== "string") {
res.status(statusBadUser).json({ error: "missing url param" });
return;
}
const fullUrl = decodeURIComponent(encodedUrl);
console.log("Incoming /fetch with url:", fullUrl);

const data = await fetchData(fullUrl);
res.status(statusGood).json(data);
} catch (error) {
console.error("Error in /fetch:", error);
res.status(statusBadServer).json({ error: "Failed to fetch data" });
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider making a file called tba.ts in the routes directory, and use Router syntax to show the data. consider looking into how the index.ts in routes works and reading on it

Comment on lines +45 to +61
app.get("/fetch", async (req, res) => {
try {
const encodedUrl = req.query.url;
if (!encodedUrl || typeof encodedUrl !== "string") {
res.status(statusBadUser).json({ error: "missing url param" });
return;
}
const fullUrl = decodeURIComponent(encodedUrl);
console.log("Incoming /fetch with url:", fullUrl);

const data = await fetchData(fullUrl);
res.status(statusGood).json(data);
} catch (error) {
console.error("Error in /fetch:", error);
res.status(statusBadServer).json({ error: "Failed to fetch data" });
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting the URL from the user and making a fetch with that can be pretty unsafe. a person can send malicious requests which will make you send requests he makes. consider making multiple get endpoints for different cases, for example an endpoint for matches, for teams and for event data.

const [teamRank, setTeamRank] = useState<RankItem | null>(null);
const [searchStatus, setSearchStatus] = useState<"idle" | "loading" | "success" | "error">("idle");

const resetInSearch = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using useCallback

Comment on lines 101 to 113
const sortMatches = useCallback((a: MatchesSimpleType, b: MatchesSimpleType) => {
const timeA = a.predicted_time ?? a.time ?? matchTimeDefault;
const timeB = b.predicted_time ?? b.time ?? matchTimeDefault;
const weightA = getLevelWeight(a.comp_level);
const weightB = getLevelWeight(b.comp_level);

return (timeA > matchTimeMissing && timeB > matchTimeMissing) ? timeA - timeB
: (timeA === matchTimeMissing && timeB > matchTimeMissing) ? sortABeforeB
: (timeA > matchTimeMissing && timeB === matchTimeMissing) ? sortBBeforeA
: (weightA !== weightB)
? weightA - weightB
: a.match_number - b.match_number;
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't this function be defined outside of the component?


useEffect(() => {
const intervalId: number | undefined = searchStatus === "success" && activeEventKey ?
window.setInterval(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider not using window

Comment on lines 187 to 188
const map: Map<string, string> = new Map();
teams.forEach(team => map.set(team.key, team.nickname));
Copy link
Contributor

@YoniKiriaty YoniKiriaty Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using a Record<string,string> instead of a map.

Suggested change
const map: Map<string, string> = new Map();
teams.forEach(team => map.set(team.key, team.nickname));
const map: Record<string, string> = {};
teams.forEach(team => {map[team.key] = team.nickname;});

Comment on lines 192 to 195
const { currentGlobalMatch, targetTeamMatches, isEventOver, isTeamDone, isFutureEvent } = useMemo(() => {
// normal one
const currentTimeSecs = Math.floor(Date.now() / timeMultiplier);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ctrl+S 🙏🏻

@YoniKiriaty YoniKiriaty added the project-init A PR to start off a project label Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

project-init A PR to start off a project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants