diff --git a/docker-compose.yml b/docker-compose.yml index 758d10b98f6c3712db0c7f386c54141f1979857d..03b47b9b554f39b0de3772293e62702ccc1b2fd0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.7' services: nginx: - image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:dev + image: test restart: unless-stopped ports: - 443:443 @@ -29,7 +29,7 @@ services: retries: 60 backend: - image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:dev + image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:back networks: backoffice: depends_on: diff --git a/public/index.html b/public/index.html index f7cd167053b03ced42bf2abb6ee99c15e304f5cc..155760c816c393333c07e247e646ba9604043c3a 100644 --- a/public/index.html +++ b/public/index.html @@ -1,6 +1,7 @@ <!DOCTYPE html> <html lang="en"> <head> + <base href="%PUBLIC_URL%/"> <meta charset="utf-8" /> <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> diff --git a/src/App.tsx b/src/App.tsx index 2495ec0a34b50573029838c2607328603cec7508..ba353aff2a38fe7f4717b594201e8b5d11ca0b88 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,7 +10,7 @@ function App() { const { user, setUser, isLoading } = useFindUser() return ( - <BrowserRouter> + <BrowserRouter basename={process.env.PUBLIC_URL}> <UserContext.Provider value={{ user, setUser, isLoading }}> <Layout> <Routes /> diff --git a/src/components/MonthlyNews/MonthlyNews.tsx b/src/components/MonthlyNews/MonthlyNews.tsx index b3481458a6b30f488c0f11c093ab2fc4af15d2c6..0d9c5ac6ab0c75665ef74e741339129eaa543fbf 100644 --- a/src/components/MonthlyNews/MonthlyNews.tsx +++ b/src/components/MonthlyNews/MonthlyNews.tsx @@ -28,6 +28,7 @@ const MonthlyNews: React.FC<MonthlyNewsProps> = ({ </div> <div> <Editor + apiKey="2abhh1p06eeeybqtiohaz5u6pvqjk6kg3mh25acw56cknqeg" init={{ menubar: false, toolbar: @@ -43,6 +44,7 @@ const MonthlyNews: React.FC<MonthlyNewsProps> = ({ </div> <Editor + apiKey="2abhh1p06eeeybqtiohaz5u6pvqjk6kg3mh25acw56cknqeg" init={{ menubar: false, toolbar: @@ -57,7 +59,7 @@ const MonthlyNews: React.FC<MonthlyNewsProps> = ({ text: 'consumption', onAction: function () { editor.insertContent( - ' <a href="https://ecolyo.{cozyUrl}/consumption">Page de consommation</a>' + ' <a href="https://ecolyo.{cozyUrl}/consumption">page de consommation</a>' ) }, }, @@ -66,7 +68,7 @@ const MonthlyNews: React.FC<MonthlyNewsProps> = ({ text: 'challenges', onAction: function () { editor.insertContent( - ' <a href="https://ecolyo.{cozyUrl}/challenges">Page challenges</a>' + ' <a href="https://ecolyo.{cozyUrl}/challenges">page challenges</a>' ) }, }, @@ -75,7 +77,7 @@ const MonthlyNews: React.FC<MonthlyNewsProps> = ({ text: 'ecogestures', onAction: function () { editor.insertContent( - ' <a href="https://ecolyo.{cozyUrl}/ecogestures">Page ecogestures</a>' + ' <a href="https://ecolyo.{cozyUrl}/ecogestures">page ecogestures</a>' ) }, }, @@ -84,7 +86,7 @@ const MonthlyNews: React.FC<MonthlyNewsProps> = ({ text: 'analysis', onAction: function () { editor.insertContent( - ' <a href="https://ecolyo.{cozyUrl}/analysis">Page analyse</a>' + ' <a href="https://ecolyo.{cozyUrl}/analysis">page analyse</a>' ) }, }, @@ -93,7 +95,7 @@ const MonthlyNews: React.FC<MonthlyNewsProps> = ({ text: 'options', onAction: function () { editor.insertContent( - ' <a href="https://ecolyo.{cozyUrl}/options">Page options</a>' + ' <a href="https://ecolyo.{cozyUrl}/options">page options</a>' ) }, }, diff --git a/src/components/Poll/Poll.tsx b/src/components/Poll/Poll.tsx index 25c71fb08287e6decc8071a9171656bdad06ec2e..910860997d5cc3acc2b2a601536eaaa0c7b4258c 100644 --- a/src/components/Poll/Poll.tsx +++ b/src/components/Poll/Poll.tsx @@ -40,6 +40,7 @@ const Poll: React.FC<PollProps> = ({ <p className="title">Question</p> <Editor + apiKey="2abhh1p06eeeybqtiohaz5u6pvqjk6kg3mh25acw56cknqeg" init={{ menubar: false, toolbar: diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts index 5033ce15bcea29d77a1e410c8f70ba7839ade792..4bc30ac1d1df96056a8f0ab99a156e13d779a584 100644 --- a/src/hooks/useAuth.ts +++ b/src/hooks/useAuth.ts @@ -3,8 +3,6 @@ import axios from 'axios' import { UserContext } from './userContext' import { useHistory } from 'react-router-dom' -const _apiUrl: string = 'https://localhost:443/' - export interface Auth { loginUser: () => Promise<void> error: null @@ -18,7 +16,9 @@ export const useAuth = (): Auth => { //login user const loginUser = async (): Promise<void> => { try { - await axios.get(`${_apiUrl}OAuth2Login`, { withCredentials: true }) + await axios.get(`${process.env.PUBLIC_URL}OAuth2Login`, { + withCredentials: true, + }) await setUserContext() } catch (e) { setError(e) @@ -28,7 +28,7 @@ export const useAuth = (): Auth => { const logoutUser = async (): Promise<void> => { try { if (setUser) setUser(null) - await axios.get(`${_apiUrl}Logout`) + await axios.get(`${process.env.PUBLIC_URL}Logout`) } catch (e) { setError(e) } @@ -37,9 +37,12 @@ export const useAuth = (): Auth => { //set user in context and push them home const setUserContext = async (): Promise<void> => { try { - const { data } = await axios.get(`${_apiUrl}api/common/WhoAmI`, { - withCredentials: true, - }) + const { data } = await axios.get( + `${process.env.PUBLIC_URL}api/common/WhoAmI`, + { + withCredentials: true, + } + ) if (data && setUser) { setUser(data) history.push('/editing') diff --git a/src/hooks/useFindUser.ts b/src/hooks/useFindUser.ts index 2d3ae84939351b8b64a9d19a34de65e241064609..8e1f51c8a3ff385ae5fb1aaa384233a386567fd0 100644 --- a/src/hooks/useFindUser.ts +++ b/src/hooks/useFindUser.ts @@ -5,11 +5,12 @@ import { User } from '../models/user.model' const useFindUser = () => { const [user, setUser] = useState<User | null>(null) const [isLoading, setLoading] = useState<boolean>(true) - const _apiUrl: string = 'https://localhost:443/' useEffect(() => { async function findUser() { - const { data } = await axios.get(`${_apiUrl}api/common/WhoAmI`) + const { data } = await axios.get( + `${process.env.PUBLIC_URL}api/common/WhoAmI` + ) if (data) { setUser(data) setLoading(false) diff --git a/src/services/monthlyNews.service.ts b/src/services/monthlyNews.service.ts index 2185f2a010e2184d7f5de11d1396a09eeebc7917..417519ace092fe291c040ccf537cdfa8817574ea 100644 --- a/src/services/monthlyNews.service.ts +++ b/src/services/monthlyNews.service.ts @@ -21,7 +21,7 @@ export class MonthlyNewsService { ): Promise<void> => { try { await axios.put( - `${this._apiUrl}api/admin/monthlyNews`, + `${process.env.PUBLIC_URL}/api/admin/monthlyNews`, { month: date.getMonth(), year: date.getFullYear(), @@ -51,17 +51,13 @@ export class MonthlyNewsService { ): Promise<IMonthlyNews | null> => { try { const { data } = await axios.get( - `${this._apiUrl}api/admin/monthlyNews/${year}/${month}`, + `${process.env.PUBLIC_URL}/api/admin/monthlyNews/${year}/${month}`, { headers: { 'XSRF-TOKEN': token, }, } ) - // if (data == {}) { - // return null - // } - return data as IMonthlyNews } catch (e) { console.log('error', e) @@ -79,16 +75,13 @@ export class MonthlyNewsService { ): Promise<IPoll | null> => { try { const { data } = await axios.get( - `${this._apiUrl}api/admin/poll/${year}/${month}`, + `${process.env.PUBLIC_URL}/api/admin/poll/${year}/${month}`, { headers: { 'XSRF-TOKEN': token, }, } ) - // if (data === {}) { - // return null - // } return data as IPoll } catch (e) { console.log('error', e) @@ -110,7 +103,7 @@ export class MonthlyNewsService { ): Promise<void> => { try { await axios.put( - `${this._apiUrl}api/admin/poll`, + `${process.env.PUBLIC_URL}/api/admin/poll`, { month: date.getMonth(), year: date.getFullYear(), @@ -141,11 +134,14 @@ export class MonthlyNewsService { token: string ): Promise<void> => { try { - await axios.delete(`${this._apiUrl}api/admin/poll/${year}/${month}`, { - headers: { - 'XSRF-TOKEN': token, - }, - }) + await axios.delete( + `${process.env.PUBLIC_URL}api/admin/poll/${year}/${month}`, + { + headers: { + 'XSRF-TOKEN': token, + }, + } + ) toast.success('Poll succesfully deleted !') } catch (e) { toast.error('Failed to delete poll') @@ -165,7 +161,7 @@ export class MonthlyNewsService { ): Promise<void> => { try { await axios.delete( - `${this._apiUrl}api/admin/monthlyNews/${year}/${month}`, + `${process.env.PUBLIC_URL}api/admin/monthlyNews/${year}/${month}`, { headers: { 'XSRF-TOKEN': token,