diff --git a/.env b/.env index 951db6b..98ae12d 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ -VITE_API_ENDPOINT=/api \ No newline at end of file +VITE_API_ENDPOINT=/api +VITE_BASE= \ No newline at end of file diff --git a/ci/.drone.yml b/ci/.drone.yml index 8b7058d..a282766 100644 --- a/ci/.drone.yml +++ b/ci/.drone.yml @@ -36,6 +36,7 @@ steps: - chmod +x /tmp/moshell_setup.sh - echo n | /tmp/moshell_setup.sh - echo "VITE_API_ENDPOINT=/IQBall/$DRONE_BRANCH/public/api" >> .env.PROD + - echo "VITE_BASE=/IQBall/$DRONE_BRANCH/public" >> .env.PROD - - /root/.local/bin/moshell ci/build_react.msh diff --git a/ci/build_react.msh b/ci/build_react.msh index 32a5923..3d3a8f0 100755 --- a/ci/build_react.msh +++ b/ci/build_react.msh @@ -9,8 +9,6 @@ val drone_branch = std::env("DRONE_BRANCH").unwrap() val base = "/IQBall/$drone_branch/public" npm run build -- --base=$base --mode PROD -npm run build -- --base=/IQBall/public --mode PROD - // Read generated mappings from build val result = $(jq -r 'to_entries|map(.key + " " +.value.file)|.[]' dist/manifest.json) val mappings = $result.split('\n') diff --git a/front/Constants.ts b/front/Constants.ts index 76b37c2..013db50 100644 --- a/front/Constants.ts +++ b/front/Constants.ts @@ -2,3 +2,8 @@ * This constant defines the API endpoint. */ export const API = import.meta.env.VITE_API_ENDPOINT + +/** + * This constant defines the base app's endpoint. + */ +export const BASE = import.meta.env.VITE_BASE diff --git a/front/views/Editor.tsx b/front/views/Editor.tsx index 6b5dbd7..3b6ad4f 100644 --- a/front/views/Editor.tsx +++ b/front/views/Editor.tsx @@ -37,14 +37,14 @@ export interface EditorViewProps { tactic: Tactic onContentChange: (tactic: TacticContent) => Promise onNameChange: (name: string) => Promise - courtType: string + courtType: "PLAIN" | "HALF" } export interface EditorProps { id: number name: string content: string - courtType: string + courtType: "PLAIN" | "HALF" } /** diff --git a/front/views/NewTacticPanel.tsx b/front/views/NewTacticPanel.tsx index 2b7165b..9733c91 100644 --- a/front/views/NewTacticPanel.tsx +++ b/front/views/NewTacticPanel.tsx @@ -3,6 +3,7 @@ import "../style/new_tactic_panel.css" import plainCourt from "../assets/court/court.svg" import halfCourt from "../assets/court/half_court.svg" +import {BASE} from "../Constants"; export default function NewTacticPanel() { return ( @@ -31,11 +32,11 @@ export default function NewTacticPanel() { } function CourtKindButton({ - name, - image, - details, - redirect, -}: { + name, + image, + details, + redirect, + }: { name: string image: string details: string @@ -44,14 +45,14 @@ function CourtKindButton({ return (
(location.href = redirect)}> + onClick={() => location.href = BASE + redirect}>
{details}
{name} + className="court-kind-button-image"/>