Skip to content

Commit

Permalink
preview config
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnsantoss committed Feb 7, 2024
1 parent 6e16578 commit 6d9430f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 43 deletions.
6 changes: 0 additions & 6 deletions .env.example

This file was deleted.

29 changes: 21 additions & 8 deletions src/api/backend.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { CheckedCourse, Major } from '../@types'
import { extraCoursesData } from '../utils/data'
import { getSemester, config, dev_config } from '../utils/utils'

import { CheckedCourse, Major } from '../@types';
import { extraCoursesData } from '../utils/data';
import { config, dev_config, getSemester, preview_config } from '../utils/utils';

const prod_val = Number(process.env.REACT_APP_PROD)
let BE_CONFIG

switch (prod_val) {
case 1:
BE_CONFIG = config
break
case 2:
BE_CONFIG = preview_config
break
default:
BE_CONFIG = dev_config
}

const prod_val = process.env.REACT_APP_PROD
const BE_CONFIG = Number(prod_val) ? config : dev_config
const BACKEND_URL = process.env.REACT_APP_BACKEND_URL || `${BE_CONFIG.api.protocol}://${BE_CONFIG.api.host}:${BE_CONFIG.api.port}${BE_CONFIG.api.pathPrefix}`
const BACKEND_URL =
process.env.REACT_APP_BACKEND_URL ||
`${BE_CONFIG.api.protocol}://${BE_CONFIG.api.host}:${BE_CONFIG.api.port}${BE_CONFIG.api.pathPrefix}`
const SEMESTER = process.env.REACT_APP_SEMESTER || getSemester()

/**
Expand Down Expand Up @@ -114,7 +127,7 @@ const api = {
getCoursesSchedules,
getMajorCoursesSchedules,
getExtraCourses,
getInfo
getInfo,
}

export default api
19 changes: 19 additions & 0 deletions src/config/preview.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"pathPrefix": "/",
"paths": {
"about": "about",
"profile": "profile",
"planner": "planner",
"exchange": "exchange",
"faqs": "faqs",
"notfound": "*",
"home": "home"
},
"api": {
"port": 443,
"protocol": "https",
"host": "ni.fe.up.pt",
"pathPrefix": "/tts/api",
"year": 2023
}
}
39 changes: 10 additions & 29 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import config from '../config/prod.json'
import dev_config from '../config/local.json'
import { CourseOption, CourseSchedule, Lesson } from '../@types'
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
import { CourseOption, CourseSchedule, Lesson } from '../@types';
import dev_config from '../config/local.json';
import preview_config from '../config/preview.json';
import config from '../config/prod.json';
const minHour = 8
const maxHour = 23
const dayNames = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab']
Expand Down Expand Up @@ -204,27 +205,7 @@ const removeDuplicatesFromCourseOption = (courses: CourseOption[]): CourseOption
}

export {
config,
dev_config,
getPath,
minHour,
maxHour,
dayNames,
monthNames,
getDisplayDate,
getSemester,
getSchoolYear,
convertWeekday,
convertWeekdayLong,
convertHour,
timesCollide,
schedulesConflict,
getScheduleOptionDisplayText,
getLessonBoxTime,
getLessonBoxStyles,
getClassTypeClassName,
getLessonTypeLongName,
getCourseTeachers,
cn,
removeDuplicatesFromCourseOption
}
cn, config, convertHour, convertWeekday,
convertWeekdayLong, dayNames, dev_config, getClassTypeClassName, getCourseTeachers, getDisplayDate, getLessonBoxStyles, getLessonBoxTime, getLessonTypeLongName, getPath, getScheduleOptionDisplayText, getSchoolYear, getSemester, maxHour, minHour, monthNames, preview_config, removeDuplicatesFromCourseOption, schedulesConflict, timesCollide
};

0 comments on commit 6d9430f

Please sign in to comment.