From a6e680270a14d9c0e826e30691df1ae076aa1f94 Mon Sep 17 00:00:00 2001 From: Yousif Alrubaye Date: Mon, 15 Dec 2025 21:41:56 -0800 Subject: [PATCH 1/2] Fix environment import paths and configuration --- react-ystemandchess/src/App.tsx | 2 +- react-ystemandchess/src/core/services/badgesApi.ts | 3 +-- react-ystemandchess/src/features/auth/login/Login.tsx | 2 +- .../auth/reset-password/Reset-Password/resetPasswordService.ts | 2 +- react-ystemandchess/src/features/auth/signup/SignUp.tsx | 2 +- .../features/lessons/lessons-selection/LessonsSelection.jsx | 2 +- .../piece-lessons/lesson-overlay/hooks/useLessonManager.ts | 2 +- .../piece-lessons/lesson-overlay/hooks/useSocketChessEngine.ts | 2 +- .../piece-lessons/lesson-overlay/hooks/useTimeTracking.test.ts | 2 +- .../piece-lessons/lesson-overlay/hooks/useTimeTracking.ts | 2 +- .../src/features/mentor/mentor-profile/NewMentorProfile.tsx | 2 +- .../mentor-profile/NewMentorProfile/NewMentorProfile.tsx | 2 +- .../src/features/puzzles/puzzles-page/Puzzles.tsx | 2 +- .../src/features/student/student-page/Student.tsx | 2 +- .../student/student-profile/Modals/ActivitiesModal.tsx | 2 +- .../src/features/student/student-profile/NewStudentProfile.tsx | 2 +- react-ystemandchess/src/globals.ts | 2 +- 17 files changed, 17 insertions(+), 18 deletions(-) diff --git a/react-ystemandchess/src/App.tsx b/react-ystemandchess/src/App.tsx index f0be45f5..aac50eaa 100644 --- a/react-ystemandchess/src/App.tsx +++ b/react-ystemandchess/src/App.tsx @@ -9,7 +9,7 @@ import "./App.css"; import React, { useEffect } from "react"; import { BrowserRouter as Router } from "react-router-dom"; -import { environment } from "./core/environments/environment"; +import { environment } from "./environments/environment"; import { useCookies } from "react-cookie"; import { SetPermissionLevel } from "./globals"; import NavBar from "./components/navbar/NavBar"; diff --git a/react-ystemandchess/src/core/services/badgesApi.ts b/react-ystemandchess/src/core/services/badgesApi.ts index f5d282fc..289a04c7 100644 --- a/react-ystemandchess/src/core/services/badgesApi.ts +++ b/react-ystemandchess/src/core/services/badgesApi.ts @@ -9,8 +9,7 @@ * - getUserBadges: Fetches badges earned by a specific user */ -import { environment } from "../environments/environment"; - +import { environment } from "../../environments/environment"; /** * Fetches the complete catalog of all available badges * diff --git a/react-ystemandchess/src/features/auth/login/Login.tsx b/react-ystemandchess/src/features/auth/login/Login.tsx index 2841ad41..fe5de8d7 100644 --- a/react-ystemandchess/src/features/auth/login/Login.tsx +++ b/react-ystemandchess/src/features/auth/login/Login.tsx @@ -2,7 +2,7 @@ import React from 'react'; // import { Link } from 'react-router-dom'; import './Login.scss'; import { useState } from 'react'; -import { environment } from "../../../core/environments/environment"; +import { environment } from "../../../environments/environment"; import { useCookies } from 'react-cookie'; const Login = () => { diff --git a/react-ystemandchess/src/features/auth/reset-password/Reset-Password/resetPasswordService.ts b/react-ystemandchess/src/features/auth/reset-password/Reset-Password/resetPasswordService.ts index 97798183..cff77239 100644 --- a/react-ystemandchess/src/features/auth/reset-password/Reset-Password/resetPasswordService.ts +++ b/react-ystemandchess/src/features/auth/reset-password/Reset-Password/resetPasswordService.ts @@ -5,7 +5,7 @@ * Uses Nodemailer with Gmail to deliver reset links. */ -import { environment } from "../../../../core/environments/environment"; +import { environment } from "../../../../environments/environment"; const nodemailer = require('nodemailer'); // Configure email transporter with Gmail credentials diff --git a/react-ystemandchess/src/features/auth/signup/SignUp.tsx b/react-ystemandchess/src/features/auth/signup/SignUp.tsx index 5c01df2c..dfe33ed5 100644 --- a/react-ystemandchess/src/features/auth/signup/SignUp.tsx +++ b/react-ystemandchess/src/features/auth/signup/SignUp.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useRef } from 'react'; import './SignUp.scss'; -import { environment } from '../../../core/environments/environment'; +import { environment } from '../../../environments/environment'; // Define the interface for the props of the StudentTemplate component interface StudentTemplateProps { diff --git a/react-ystemandchess/src/features/lessons/lessons-selection/LessonsSelection.jsx b/react-ystemandchess/src/features/lessons/lessons-selection/LessonsSelection.jsx index 8b87c60f..fa888646 100644 --- a/react-ystemandchess/src/features/lessons/lessons-selection/LessonsSelection.jsx +++ b/react-ystemandchess/src/features/lessons/lessons-selection/LessonsSelection.jsx @@ -2,7 +2,7 @@ import profileStyles from "./ProfileStyle.module.scss"; import pageStyles from "./LessonsStyle.module.scss"; import { useNavigate } from "react-router"; import { useState, useEffect, useRef, useCallback, useMemo } from 'react'; -import { environment } from "../../../core/environments/environment"; +import { environment } from "../../../environments/environment"; import { getAllScenarios } from "../lessons-main/Scenarios"; import { useCookies } from "react-cookie"; import ScenarioTemplate from "./ScenarioTemplate/ScenarioTemplate.jsx"; // Importing the ScenarioTemplate component diff --git a/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useLessonManager.ts b/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useLessonManager.ts index 4a45d808..71dd2194 100644 --- a/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useLessonManager.ts +++ b/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useLessonManager.ts @@ -1,5 +1,5 @@ import { useState, useCallback } from "react"; -import { environment } from "../../../../../core/environments/environment"; +import { environment } from "../../../../../environments/environment"; export function useLessonManager(piece: string, cookies: any, initialLessonNum?: number) { const [lessonNum, setLessonNum] = useState(initialLessonNum ?? 0); diff --git a/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useSocketChessEngine.ts b/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useSocketChessEngine.ts index a5f26124..b26aaf97 100644 --- a/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useSocketChessEngine.ts +++ b/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useSocketChessEngine.ts @@ -1,4 +1,4 @@ -import { environment } from "../../../../../core/environments/environment"; +import { environment } from "../../../../../environments/environment"; import { useEffect, useRef } from "react"; import io from "socket.io-client"; diff --git a/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useTimeTracking.test.ts b/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useTimeTracking.test.ts index 48e1a73b..58c48dd0 100644 --- a/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useTimeTracking.test.ts +++ b/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useTimeTracking.test.ts @@ -1,7 +1,7 @@ import { renderHook, act } from "@testing-library/react"; import { useTimeTracking } from "./useTimeTracking"; import { SetPermissionLevel } from "../../../../../globals"; -import { environment } from "../../../../../core/environments/environment"; +import { environment } from "../../../../../environments/environment"; // mock SetPermissionLevel jest.mock("../../../../../globals", () => ({ diff --git a/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useTimeTracking.ts b/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useTimeTracking.ts index 8762ec05..f58b182d 100644 --- a/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useTimeTracking.ts +++ b/react-ystemandchess/src/features/lessons/piece-lessons/lesson-overlay/hooks/useTimeTracking.ts @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from "react"; -import { environment } from "../../../../../core/environments/environment"; +import { environment } from "../../../../../environments/environment"; import { SetPermissionLevel } from "../../../../../globals"; export function useTimeTracking(piece: string, cookies: any) { diff --git a/react-ystemandchess/src/features/mentor/mentor-profile/NewMentorProfile.tsx b/react-ystemandchess/src/features/mentor/mentor-profile/NewMentorProfile.tsx index 220bb75e..20379019 100644 --- a/react-ystemandchess/src/features/mentor/mentor-profile/NewMentorProfile.tsx +++ b/react-ystemandchess/src/features/mentor/mentor-profile/NewMentorProfile.tsx @@ -3,7 +3,7 @@ import "./NewMentorProfile.scss"; import Images from "../../../assets/images/imageImporter"; import { SetPermissionLevel } from '../../../globals'; import { useCookies } from 'react-cookie'; -import { environment } from "../../../core/environments/environment"; +import { environment } from "../../../environments/environment"; import { useNavigate } from "react-router"; import StatsChart from "../../student/student-profile/StatsChart"; import Lessons from "../../lessons/lessons-main/Lessons"; diff --git a/react-ystemandchess/src/features/mentor/mentor-profile/NewMentorProfile/NewMentorProfile.tsx b/react-ystemandchess/src/features/mentor/mentor-profile/NewMentorProfile/NewMentorProfile.tsx index 29147100..1c77cde5 100644 --- a/react-ystemandchess/src/features/mentor/mentor-profile/NewMentorProfile/NewMentorProfile.tsx +++ b/react-ystemandchess/src/features/mentor/mentor-profile/NewMentorProfile/NewMentorProfile.tsx @@ -3,7 +3,7 @@ import "./NewMentorProfile.scss"; import Images from "../../../../assets/images/imageImporter"; import { SetPermissionLevel } from '../../../../globals'; import { useCookies } from 'react-cookie'; -import { environment } from "../../../../core/environments/environment"; +import { environment } from "../../../../environments/environment"; import { useNavigate } from "react-router"; import StatsChart from "../../../student/student-profile/StatsChart"; import Lessons from "../../../lessons/lessons-main/Lessons"; diff --git a/react-ystemandchess/src/features/puzzles/puzzles-page/Puzzles.tsx b/react-ystemandchess/src/features/puzzles/puzzles-page/Puzzles.tsx index d926cbc4..36518693 100644 --- a/react-ystemandchess/src/features/puzzles/puzzles-page/Puzzles.tsx +++ b/react-ystemandchess/src/features/puzzles/puzzles-page/Puzzles.tsx @@ -4,7 +4,7 @@ import profileStyles from "./Puzzles-profile.module.scss"; import { Chess } from "chess.js"; import { themesName, themesDescription } from "../../../core/services/themesService"; import Swal from 'sweetalert2'; -import { environment } from "../../../core/environments/environment"; +import { environment } from "../../../environments/environment"; import { v4 as uuidv4 } from "uuid"; import { SetPermissionLevel } from "../../../globals"; import { useCookies } from 'react-cookie'; diff --git a/react-ystemandchess/src/features/student/student-page/Student.tsx b/react-ystemandchess/src/features/student/student-page/Student.tsx index aadffde3..619bf108 100644 --- a/react-ystemandchess/src/features/student/student-page/Student.tsx +++ b/react-ystemandchess/src/features/student/student-page/Student.tsx @@ -1,6 +1,6 @@ import React, {useState} from "react"; import "./Student.scss"; -import {environment} from "../../../core/environments/environment"; +import {environment} from "../../../environments/environment"; const Student = () => { const chessSrc = environment.urls.chessClientURL; diff --git a/react-ystemandchess/src/features/student/student-profile/Modals/ActivitiesModal.tsx b/react-ystemandchess/src/features/student/student-profile/Modals/ActivitiesModal.tsx index 851d98a3..f7b26883 100644 --- a/react-ystemandchess/src/features/student/student-profile/Modals/ActivitiesModal.tsx +++ b/react-ystemandchess/src/features/student/student-profile/Modals/ActivitiesModal.tsx @@ -25,7 +25,7 @@ import { ReactComponent as TopicBag } from "../../../../assets/images/Activities import { ReactComponent as ShortBottomVine} from "../../../../assets/images/ActivitiesAssets/short_bottom_vine.svg"; import { ReactComponent as BottomVine} from "../../../../assets/images/ActivitiesAssets/bottom_vine.svg"; import { ReactComponent as Stemmy} from "../../../../assets/images/ActivitiesAssets/stemmy.svg"; -import { environment } from "../../../../core/environments/environment"; +import { environment } from "../../../../environments/environment"; import { useCookies } from "react-cookie"; import { parseActivities } from "../../../../core/utils/activityNames"; diff --git a/react-ystemandchess/src/features/student/student-profile/NewStudentProfile.tsx b/react-ystemandchess/src/features/student/student-profile/NewStudentProfile.tsx index 163535e3..527e7f41 100644 --- a/react-ystemandchess/src/features/student/student-profile/NewStudentProfile.tsx +++ b/react-ystemandchess/src/features/student/student-profile/NewStudentProfile.tsx @@ -3,7 +3,7 @@ import "./NewStudentProfile.scss"; import Images from "../../../assets/images/imageImporter"; import { SetPermissionLevel } from '../../../globals'; import { useCookies } from 'react-cookie'; -import { environment } from "../../../core/environments/environment"; +import { environment } from "../../../environments/environment"; import { useNavigate } from "react-router"; import { useLocation } from "react-router"; import StatsChart from "./StatsChart"; diff --git a/react-ystemandchess/src/globals.ts b/react-ystemandchess/src/globals.ts index ed668f5a..9cc4a323 100644 --- a/react-ystemandchess/src/globals.ts +++ b/react-ystemandchess/src/globals.ts @@ -5,7 +5,7 @@ * components, particularly for authentication and permission management. */ -import { environment } from "./core/environments/environment"; +import { environment } from "./environments/environment"; /** * Global variable to store user information after authentication From a998df334c9adf856158beba5519228717085d7d Mon Sep 17 00:00:00 2001 From: Yousif Alrubaye Date: Tue, 16 Dec 2025 13:43:25 -0800 Subject: [PATCH 2/2] Add environment configuration files --- .gitignore | 3 ++- react-ystemandchess/src/environments/environment.js | 13 +++++++++++++ .../src/environments/environment.prod.js | 12 ++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 react-ystemandchess/src/environments/environment.js create mode 100644 react-ystemandchess/src/environments/environment.prod.js diff --git a/.gitignore b/.gitignore index 1ae98ad2..07e1fe56 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,8 @@ react-ystemandchess/environment.prod.ts react-ystemandchess/environment.ts environment.php .env -environment.* +environment.*.local +environment.secret.* create_envs.sh create_env.sh create_dev_envs.sh diff --git a/react-ystemandchess/src/environments/environment.js b/react-ystemandchess/src/environments/environment.js new file mode 100644 index 00000000..2a84a330 --- /dev/null +++ b/react-ystemandchess/src/environments/environment.js @@ -0,0 +1,13 @@ +export const environment = { + production: false, + agora: { + appId: '6b7772f2a76f406192d8167460181be0', + }, + urls: { + middlewareURL: 'http://localhost:8000', + chessClientURL: 'http://localhost', + stockFishURL: 'http://localhost:8080/stockfishserver/', + chessServer: 'http://localhost:3001/', + }, + productionType: 'development', // development/production +}; \ No newline at end of file diff --git a/react-ystemandchess/src/environments/environment.prod.js b/react-ystemandchess/src/environments/environment.prod.js new file mode 100644 index 00000000..f86e300f --- /dev/null +++ b/react-ystemandchess/src/environments/environment.prod.js @@ -0,0 +1,12 @@ +export const environment = { + production: false, + agora: { + appId: '6c368b93b82a4b3e9fb8e57da830f2a4', + }, + urls: { + middlewareURL: 'http://localhost/middleware/', + chessClientURL: 'http://localhost/chessclient/', + stockFishURL: 'http://localhost/stockfishserver/', + chessServer: 'http://localhost/chessserver/', + }, +}; \ No newline at end of file