diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 698b929..c94c1d9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,210 +1,210 @@ name: CI on: - push: - branches: - - dev - tags: - - 'v*' - pull_request: - branches: - - dev - - prod + push: + branches: + - dev + tags: + - 'v*' + pull_request: + branches: + - dev + - prod env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true' jobs: - lint-api: - runs-on: self-hosted - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 11 - - - name: Set up Node.js - uses: actions/setup-node@v5 - with: - node-version: '23' - cache: 'pnpm' - cache-dependency-path: ./backend/pnpm-lock.yaml - - - name: Install dependencies - working-directory: ./backend - run: pnpm install --frozen-lockfile - - - name: Lint - working-directory: ./backend - run: pnpm run lint - - lint-front: - runs-on: self-hosted - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 11 - - - name: Set up Node.js - uses: actions/setup-node@v5 - with: - node-version: '23' - cache: 'pnpm' - cache-dependency-path: ./frontend/pnpm-lock.yaml - - - name: Install dependencies - working-directory: ./frontend - run: pnpm install --frozen-lockfile - - - name: Lint - working-directory: ./frontend - run: pnpm run lint - - build-api: - runs-on: self-hosted - if: github.event_name == 'pull_request' || github.event_name == 'push' - needs: - - lint-api - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 11 - - - name: Set up Node.js - uses: actions/setup-node@v5 - with: - node-version: '23' - cache: 'pnpm' - cache-dependency-path: ./backend/pnpm-lock.yaml - - - name: Install dependencies - working-directory: ./backend - run: pnpm install --frozen-lockfile - - - name: Build - working-directory: ./backend - run: pnpm run build-test - - build-front: - runs-on: self-hosted - if: github.event_name == 'pull_request' || github.event_name == 'push' - needs: - - lint-front - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 11 - - - name: Set up Node.js - uses: actions/setup-node@v5 - with: - node-version: '23' - cache: 'pnpm' - cache-dependency-path: ./frontend/pnpm-lock.yaml - - - name: Install dependencies - working-directory: ./frontend - run: pnpm install --frozen-lockfile - - - name: Build - working-directory: ./frontend - run: pnpm run build - - deploy-api: - runs-on: self-hosted - if: github.event_name == 'push' && (github.ref == 'refs/heads/dev' || startswith(github.ref, 'refs/tags/v')) - environment: ${{ startswith(github.ref, 'refs/tags/') && 'production' || 'development' }} - needs: - - lint-api - - build-api - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Login to registry - uses: docker/login-action@v3 - with: - registry: ${{ secrets.REGISTRY_URL }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Install docker - uses: docker/setup-buildx-action@v3 - - - name: API - Build and push - uses: docker/build-push-action@v6 - with: - context: ./backend - push: true - tags: | - ${{ secrets.REGISTRY_URL }}/integration/api:${{ startswith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }} - ${{ startswith(github.ref, 'refs/tags/') && format('{0}/integration/api:prod', secrets.REGISTRY_URL) || '' }} - - deploy-front: - runs-on: self-hosted - if: github.event_name == 'push' && (github.ref == 'refs/heads/dev' || startswith(github.ref, 'refs/tags/v')) - environment: ${{ startswith(github.ref, 'refs/tags/') && 'production' || 'development' }} - needs: - - lint-front - - build-front - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Login to registry - uses: docker/login-action@v3 - with: - registry: ${{ secrets.REGISTRY_URL }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Install docker - uses: docker/setup-buildx-action@v3 - - - name: Front - Build and push - uses: docker/build-push-action@v6 - with: - context: ./frontend - push: true - build-args: | - VITE_API_URL=${{ vars.API_URL }} - VITE_SERVICE_URL=${{ vars.SERVICE_URL }} - VITE_ANALYTICS_WEBSITE_ID=${{ secrets.ANALYTICS_WEBSITE_ID }} - VITE_ROADBOOK_URL_FRENCH=${{ vars.ROADBOOK_URL_FRENCH }} - VITE_ROADBOOK_URL_ENGLISH=${{ vars.ROADBOOK_URL_ENGLISH }} - VITE_CAS_LOGIN_URL=${{ vars.CAS_LOGIN_URL }} - VITE_ASSOCIATION_ADDRESS=${{ vars.ASSOCIATION_ADDRESS }} - VITE_ASSOCIATION_EMAIL=${{ vars.ASSOCIATION_EMAIL }} - VITE_ASSOCIATION_NAME=${{ vars.ASSOCIATION_NAME }} - VITE_ASSOCIATION_PHONE=${{ vars.ASSOCIATION_PHONE }} - VITE_ASSOCIATION_RNA=${{ vars.ASSOCIATION_RNA }} - VITE_ASSOCIATION_RCS=${{ vars.ASSOCIATION_RCS }} - VITE_BDE_ADDRESS=${{ vars.BDE_ADDRESS }} - VITE_BDE_EMAIL=${{ vars.BDE_EMAIL }} - VITE_BDE_NAME=${{ vars.BDE_NAME }} - VITE_BDE_PHONE=${{ vars.BDE_PHONE }} - VITE_BDE_RNA=${{ vars.BDE_RNA }} - VITE_BDE_SIRET=${{ vars.BDE_SIRET }} - VITE_BDE_SIREN=${{ vars.BDE_SIREN }} - VITE_DPO_EMAIL=${{ vars.DPO_EMAIL }} - VITE_DPO_NAME=${{ vars.DPO_NAME }} - VITE_APP_VERSION=${{ startswith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }} - VITE_RELEASE_URL=${{ startswith(github.ref, 'refs/tags/') && format('https://github.com/{0}/releases/tag/{1}', github.repository, github.ref_name) || '' }} - tags: | - ${{ secrets.REGISTRY_URL }}/integration/front:${{ startswith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }} - ${{ startswith(github.ref, 'refs/tags/') && format('{0}/integration/front:prod', secrets.REGISTRY_URL) || '' }} + lint-api: + runs-on: self-hosted + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 11 + + - name: Set up Node.js + uses: actions/setup-node@v5 + with: + node-version: '23' + cache: 'pnpm' + cache-dependency-path: ./backend/pnpm-lock.yaml + + - name: Install dependencies + working-directory: ./backend + run: pnpm install --frozen-lockfile + + - name: Lint + working-directory: ./backend + run: pnpm run lint + + lint-front: + runs-on: self-hosted + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 11 + + - name: Set up Node.js + uses: actions/setup-node@v5 + with: + node-version: '23' + cache: 'pnpm' + cache-dependency-path: ./frontend/pnpm-lock.yaml + + - name: Install dependencies + working-directory: ./frontend + run: pnpm install --frozen-lockfile + + - name: Lint + working-directory: ./frontend + run: pnpm run lint + + build-api: + runs-on: self-hosted + if: github.event_name == 'pull_request' || github.event_name == 'push' + needs: + - lint-api + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 11 + + - name: Set up Node.js + uses: actions/setup-node@v5 + with: + node-version: '23' + cache: 'pnpm' + cache-dependency-path: ./backend/pnpm-lock.yaml + + - name: Install dependencies + working-directory: ./backend + run: pnpm install --frozen-lockfile + + - name: Build + working-directory: ./backend + run: pnpm run build-test + + build-front: + runs-on: self-hosted + if: github.event_name == 'pull_request' || github.event_name == 'push' + needs: + - lint-front + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 11 + + - name: Set up Node.js + uses: actions/setup-node@v5 + with: + node-version: '23' + cache: 'pnpm' + cache-dependency-path: ./frontend/pnpm-lock.yaml + + - name: Install dependencies + working-directory: ./frontend + run: pnpm install --frozen-lockfile + + - name: Build + working-directory: ./frontend + run: pnpm run build + + deploy-api: + runs-on: self-hosted + if: github.event_name == 'push' && (github.ref == 'refs/heads/dev' || startswith(github.ref, 'refs/tags/v')) + environment: ${{ startswith(github.ref, 'refs/tags/') && 'production' || 'development' }} + needs: + - lint-api + - build-api + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: ${{ secrets.REGISTRY_URL }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Install docker + uses: docker/setup-buildx-action@v3 + + - name: API - Build and push + uses: docker/build-push-action@v6 + with: + context: ./backend + push: true + tags: | + ${{ secrets.REGISTRY_URL }}/integration/api:${{ startswith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }} + ${{ startswith(github.ref, 'refs/tags/') && format('{0}/integration/api:prod', secrets.REGISTRY_URL) || '' }} + + deploy-front: + runs-on: self-hosted + if: github.event_name == 'push' && (github.ref == 'refs/heads/dev' || startswith(github.ref, 'refs/tags/v')) + environment: ${{ startswith(github.ref, 'refs/tags/') && 'production' || 'development' }} + needs: + - lint-front + - build-front + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: ${{ secrets.REGISTRY_URL }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Install docker + uses: docker/setup-buildx-action@v3 + + - name: Front - Build and push + uses: docker/build-push-action@v6 + with: + context: ./frontend + push: true + build-args: | + VITE_API_URL=${{ vars.API_URL }} + VITE_SERVICE_URL=${{ vars.SERVICE_URL }} + VITE_ANALYTICS_WEBSITE_ID=${{ secrets.ANALYTICS_WEBSITE_ID }} + VITE_ROADBOOK_URL_FRENCH=${{ vars.ROADBOOK_URL_FRENCH }} + VITE_ROADBOOK_URL_ENGLISH=${{ vars.ROADBOOK_URL_ENGLISH }} + VITE_CAS_LOGIN_URL=${{ vars.CAS_LOGIN_URL }} + VITE_ASSOCIATION_ADDRESS=${{ vars.ASSOCIATION_ADDRESS }} + VITE_ASSOCIATION_EMAIL=${{ vars.ASSOCIATION_EMAIL }} + VITE_ASSOCIATION_NAME=${{ vars.ASSOCIATION_NAME }} + VITE_ASSOCIATION_PHONE=${{ vars.ASSOCIATION_PHONE }} + VITE_ASSOCIATION_RNA=${{ vars.ASSOCIATION_RNA }} + VITE_ASSOCIATION_RCS=${{ vars.ASSOCIATION_RCS }} + VITE_BDE_ADDRESS=${{ vars.BDE_ADDRESS }} + VITE_BDE_EMAIL=${{ vars.BDE_EMAIL }} + VITE_BDE_NAME=${{ vars.BDE_NAME }} + VITE_BDE_PHONE=${{ vars.BDE_PHONE }} + VITE_BDE_RNA=${{ vars.BDE_RNA }} + VITE_BDE_SIRET=${{ vars.BDE_SIRET }} + VITE_BDE_SIREN=${{ vars.BDE_SIREN }} + VITE_DPO_EMAIL=${{ vars.DPO_EMAIL }} + VITE_DPO_NAME=${{ vars.DPO_NAME }} + VITE_APP_VERSION=${{ startswith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }} + VITE_RELEASE_URL=${{ startswith(github.ref, 'refs/tags/') && format('https://github.com/{0}/releases/tag/{1}', github.repository, github.ref_name) || '' }} + tags: | + ${{ secrets.REGISTRY_URL }}/integration/front:${{ startswith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }} + ${{ startswith(github.ref, 'refs/tags/') && format('{0}/integration/front:prod', secrets.REGISTRY_URL) || '' }} diff --git a/frontend/src/components/challenge/challengeList.tsx b/frontend/src/components/challenge/challengeList.tsx index 9859ebd..74bd9e4 100644 --- a/frontend/src/components/challenge/challengeList.tsx +++ b/frontend/src/components/challenge/challengeList.tsx @@ -2,16 +2,16 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import Swal from 'sweetalert2'; import { type Challenge } from '../../interfaces/challenge.interface'; -import { type Faction } from '../../interfaces/faction.interface'; -import { getAllChallenges, getFactionsPoints } from '../../services/requests/challenge.service'; -import { getAllFactionsUser } from '../../services/requests/faction.service'; +//import { type Faction } from '../../interfaces/faction.interface'; +import { getAllChallenges /*getFactionsPoints*/ } from '../../services/requests/challenge.service'; +//import { getAllFactionsUser } from '../../services/requests/faction.service'; import { checkChallengeStatus } from '../../services/requests/settings.service'; import { Card, CardContent, CardHeader, CardTitle } from '../ui/card'; export const UserChallengeList = () => { const [availableChallenges, setAvailableChallenges] = useState([]); - const [factions, setFactions] = useState([]); - const [factionPoints, setFactionPoints] = useState<{ [key: number]: number }>({}); + //const [factions, setFactions] = useState([]); + //const [factionPoints, setFactionPoints] = useState<{ [key: number]: number }>({}); const [selectedCategory, setSelectedCategory] = useState('Tous'); const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('asc'); const [isChallOpen, setIsChallOpen] = useState(false); @@ -27,36 +27,39 @@ export const UserChallengeList = () => { } }, []); - const fetchFactions = useCallback(async () => { - try { - const data = await getAllFactionsUser(); - setFactions(data); - } catch (err) { - console.error('Erreur lors du chargement des factions', err); - } - }, []); - - const fetchFactionPoints = useCallback(async () => { - try { - const points: { [key: number]: number } = {}; - const fetchedFactions = await getAllFactionsUser(); - await Promise.all( - fetchedFactions.map(async (faction: Faction) => { - const res = await getFactionsPoints(faction.factionId); - points[faction.factionId] = Number(res); - }), - ); - setFactionPoints(points); - } catch (err) { - console.error('Erreur lors du chargement des points des factions', err); - } - }, []); + //const fetchFactions = useCallback(async () => { + // try { + // const data = await getAllFactionsUser(); + // setFactions(data); + // } catch (err) { + // console.error('Erreur lors du chargement des factions', err); + // } + // }, []); + + // const fetchFactionPoints = useCallback(async () => { + // try { + // const points: { [key: number]: number } = {}; + // const fetchedFactions = await getAllFactionsUser(); + // await Promise.all( + // fetchedFactions.map(async (faction: Faction) => { + // const res = await getFactionsPoints(faction.factionId); + // points[faction.factionId] = Number(res); + // }), + // ); + // setFactionPoints(points); + // } catch (err) { + // console.error('Erreur lors du chargement des points des factions', err); + // } + // }, []); + + // const fetchInitialData = useCallback(async () => { + // await Promise.all([fetchChallenges(), fetchFactions()]); + // await fetchFactionPoints(); + // }, [fetchChallenges, fetchFactions, fetchFactionPoints]); const fetchInitialData = useCallback(async () => { - await Promise.all([fetchChallenges(), fetchFactions()]); - await fetchFactionPoints(); - }, [fetchChallenges, fetchFactions, fetchFactionPoints]); - + await Promise.all([fetchChallenges()]); + }, [fetchChallenges]); useEffect(() => { const init = async () => { try { @@ -105,12 +108,10 @@ export const UserChallengeList = () => { - {!isChallOpen ? ( -

- 🚫 Les points des factions sont actuellement cachés. -

- ) : ( -
+

+ 🚫 Les points des factions sont actuellement cachés. +

+ {/*
{factions.length > 0 ? (
{factions.map((faction) => ( @@ -122,8 +123,7 @@ export const UserChallengeList = () => { ) : (

Chargement des points...

)} -
- )} +
*/} @@ -135,9 +135,7 @@ export const UserChallengeList = () => { {!isChallOpen ? ( -

- 🚫 Les défis sont actuellement fermés. -

+

🚫 Les défis sont actuellement fermés.

) : (