Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,593 changes: 4,593 additions & 0 deletions frontend/package-lock.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "grindmap-frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^4.29.19",
"axios": "^1.4.0",
"framer-motion": "^10.12.16",
"lucide-react": "^0.263.1",
"react": "^18.2.0",
"react-calendar-heatmap": "^1.9.0",
"react-circular-progressbar": "^2.1.0",
"react-confetti": "^6.1.0",
"react-dom": "^18.2.0",
"recharts": "^2.7.2"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^4.4.5"
}
}
5 changes: 3 additions & 2 deletions frontend/src/components/BadgeCollection.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import Badge from './Badge';
import { API_BASE_URL } from '../utils/api';
import './BadgeCollection.css';

const BadgeCollection = ({ userId }) => {
Expand All @@ -16,7 +17,7 @@ const BadgeCollection = ({ userId }) => {
try {
setLoading(true);
const token = localStorage.getItem('token');
const response = await fetch('/api/badges/', {
const response = await fetch(`${API_BASE_URL}/badges/`, {
headers: {
'Authorization': `Bearer ${token}`
}
Expand All @@ -38,7 +39,7 @@ const BadgeCollection = ({ userId }) => {
const markBadgesAsSeen = async (badgeIds) => {
try {
const token = localStorage.getItem('token');
await fetch('/api/badges/seen', {
await fetch(`${API_BASE_URL}/badges/seen`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/components/Friends.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
import { API_BASE_URL } from '../utils/api';
import './Friends.css';

const Friends = ({ onBack }) => {
Expand All @@ -14,7 +15,7 @@ const Friends = ({ onBack }) => {
const fetchFriends = async () => {
try {
const token = localStorage.getItem('token');
const response = await fetch('/api/friends', {
const response = await fetch(`${API_BASE_URL}/friends`, {
headers: { Authorization: `Bearer ${token}` }
});
const data = await response.json();
Expand Down Expand Up @@ -45,7 +46,7 @@ const Friends = ({ onBack }) => {
const addFriend = async (friendId) => {
try {
const token = localStorage.getItem('token');
await fetch('/api/friends/add', {
await fetch(`${API_BASE_URL}/friends/add`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -64,7 +65,7 @@ const Friends = ({ onBack }) => {
const removeFriend = async (friendId) => {
try {
const token = localStorage.getItem('token');
await fetch(`/api/friends/${friendId}`, {
await fetch(`${API_BASE_URL}/friends/${friendId}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${token}` }
});
Expand Down
13 changes: 7 additions & 6 deletions frontend/src/components/GoalDashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import GoalCard from './GoalCard';
import { API_BASE_URL } from '../utils/api';
import './GoalDashboard.css';

const GoalDashboard = () => {
Expand All @@ -19,7 +20,7 @@ const GoalDashboard = () => {
const fetchGoals = async (status = null) => {
try {
const token = localStorage.getItem('token');
const url = status ? `/api/goals?status=${status}` : '/api/goals';
const url = status ? `${API_BASE_URL}/goals?status=${status}` : `${API_BASE_URL}/goals`;
const response = await fetch(url, {
headers: { 'Authorization': `Bearer ${token}` }
});
Expand All @@ -34,7 +35,7 @@ const GoalDashboard = () => {

const fetchTemplates = async () => {
try {
const response = await fetch('/api/goals/templates');
const response = await fetch(`${API_BASE_URL}/goals/templates`);
if (response.ok) {
const data = await response.json();
setTemplates(data);
Expand All @@ -47,7 +48,7 @@ const GoalDashboard = () => {
const fetchStats = async () => {
try {
const token = localStorage.getItem('token');
const response = await fetch('/api/goals/stats', {
const response = await fetch(`${API_BASE_URL}/goals/stats`, {
headers: { 'Authorization': `Bearer ${token}` }
});
if (response.ok) {
Expand All @@ -64,7 +65,7 @@ const GoalDashboard = () => {
const handleUpdateProgress = async (goalId, newValue, note = null) => {
try {
const token = localStorage.getItem('token');
const response = await fetch(`/api/goals/${goalId}/progress`, {
const response = await fetch(`${API_BASE_URL}/goals/${goalId}/progress`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -92,7 +93,7 @@ const GoalDashboard = () => {

try {
const token = localStorage.getItem('token');
const response = await fetch(`/api/goals/${goalId}`, {
const response = await fetch(`${API_BASE_URL}/goals/${goalId}`, {
method: 'DELETE',
headers: { 'Authorization': `Bearer ${token}` }
});
Expand All @@ -109,7 +110,7 @@ const GoalDashboard = () => {
const handleCreateFromTemplate = async (templateId) => {
try {
const token = localStorage.getItem('token');
const response = await fetch('/api/goals/template', {
const response = await fetch(`${API_BASE_URL}/goals/template`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/Leaderboard.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
import { API_BASE_URL } from '../utils/api';
import './Leaderboard.css';

const Leaderboard = ({ onBack }) => {
Expand All @@ -15,7 +16,7 @@ const Leaderboard = ({ onBack }) => {
const fetchLeaderboard = async () => {
try {
const token = localStorage.getItem('token');
const response = await fetch(`/api/leaderboard?type=${type}`, {
const response = await fetch(`${API_BASE_URL}/leaderboard?type=${type}`, {
headers: { Authorization: `Bearer ${token}` }
});
const data = await response.json();
Expand All @@ -30,7 +31,7 @@ const Leaderboard = ({ onBack }) => {
const fetchUserRank = async () => {
try {
const token = localStorage.getItem('token');
const response = await fetch('/api/leaderboard/rank', {
const response = await fetch(`${API_BASE_URL}/leaderboard/rank`, {
headers: { Authorization: `Bearer ${token}` }
});
const data = await response.json();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useGrindMapData.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import { PLATFORMS } from "../utils/platforms";
import { API_BASE_URL } from "../utils/api";

const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:5001";
export const useGrindMapData = () => {
const [usernames, setUsernames] = useState({
leetcode: "",
Expand Down
Loading