Skip to content

Commit

Permalink
- change hook useLoge to useDeploymentSetting
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriel-Sautron committed Jan 16, 2025
1 parent 490b727 commit 6936ddb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions front/src/applications/stdcm/components/StdcmHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';

import { getIsSuperUser } from 'reducers/user/userSelectors';
import useLogo from 'utils/hooks/useLogo';
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';

const LogoSTDCM = ({ logo }: { logo: string | undefined }) => {
if (logo) {
Expand All @@ -28,7 +28,7 @@ const StdcmHeader = ({
}: StdcmHeaderProps) => {
const { t } = useTranslation(['stdcm', 'translation']);
const isSuperUser = useSelector(getIsSuperUser);
const { stdcmLogo } = useLogo();
const { stdcmLogo } = useDeploymentSettings();

return (
<div className="stdcm-header d-flex">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import logoSNCF from 'assets/simulationReportSheet/logo_sncf_reseau.png';
import i18n from 'i18n';
import type { StdcmPathStep } from 'reducers/osrdconf/types';
import { dateToHHMMSS, formatDateToString, formatDay } from 'utils/date';
import useLogo from 'utils/hooks/useLogo';
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';
import { msToKmh } from 'utils/physics';
import { capitalizeFirstLetter } from 'utils/strings';
import { secToMin } from 'utils/timeManipulation';
Expand Down Expand Up @@ -55,7 +55,7 @@ const SimulationReportSheet = ({
simulationReportSheetNumber,
operationalPointsList,
}: SimulationReportSheetProps) => {
const { stdcmSimulationSheetLogo } = useLogo();
const { stdcmSimulationSheetLogo } = useDeploymentSettings();
const { t } = useTranslation(['stdcm-simulation-report-sheet', 'stdcm']);
let renderedIndex = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { hasConflicts, hasResults } from 'applications/stdcm/utils/simulationOutputUtils';
import { type TrackRange } from 'common/api/osrdEditoastApi';
import NewMap from 'modules/trainschedule/components/ManageTrainSchedule/NewMap';
import useLogo from 'utils/hooks/useLogo';
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';

import SimulationReportSheet from './SimulationReportSheet';
import StdcmDebugResults from './StdcmDebugResults';
Expand Down Expand Up @@ -51,7 +51,7 @@ const StcdmResults = ({
pathTrackRanges,
}: StcdmResultsProps) => {
const { t } = useTranslation('stdcm', { keyPrefix: 'simulation.results' });
const { stdcmName } = useLogo();
const { stdcmName } = useDeploymentSettings();

const selectedSimulation = simulationsList[selectedSimulationIndex];
const { outputs } = selectedSimulation || {};
Expand Down
4 changes: 2 additions & 2 deletions front/src/common/BootstrapSNCF/NavBarSNCF.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ReleaseInformations from 'common/ReleaseInformations/ReleaseInformations'
import UserSettings from 'common/UserSettings';
import { getUserSafeWord } from 'reducers/user/userSelectors';
import useAuth from 'utils/hooks/OsrdAuth';
import useLogo from 'utils/hooks/useLogo';
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';
import { language2flag } from 'utils/strings';

import DropdownSNCF, { DROPDOWN_STYLE_TYPES } from './DropdownSNCF';
Expand All @@ -27,7 +27,7 @@ type Props = {

const LegacyNavBarSNCF = ({ appName, logo }: Props) => {
const { openModal } = useModal();
const { digitalTwinLogo, digitalTwinName, isCustomizedDeployment } = useLogo();
const { digitalTwinLogo, digitalTwinName, isCustomizedDeployment } = useDeploymentSettings();
const safeWord = useSelector(getUserSafeWord);
const { t } = useTranslation('home/navbar');
const { logout, username } = useAuth();
Expand Down
4 changes: 2 additions & 2 deletions front/src/common/ReleaseInformations/ReleaseInformations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { osrdEditoastApi } from 'common/api/osrdEditoastApi';
import ModalBodySNCF from 'common/BootstrapSNCF/ModalSNCF/ModalBodySNCF';
import ModalHeaderSNCF from 'common/BootstrapSNCF/ModalSNCF/ModalHeaderSNCF';
import motriceParty from 'common/MotriceRelated/motriceParty';
import useLogo from 'utils/hooks/useLogo';
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';

import LicenseAttributions from './LicenseAttributions';

function ReleaseInformations() {
const { t } = useTranslation('home/navbar');
const { digitalTwinLogo } = useLogo();
const { digitalTwinLogo } = useDeploymentSettings();
const { data: editoastVersion } = osrdEditoastApi.endpoints.getVersion.useQuery();
const { data: coreVersion } = osrdEditoastApi.endpoints.getVersionCore.useQuery();

Expand Down
4 changes: 2 additions & 2 deletions front/src/main/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useAllowedUserRoles from 'common/authorization/hooks/useAllowedUserRoles'
import Card from 'common/BootstrapSNCF/CardSNCF/CardSNCF';
import { ModalProvider } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider';
import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF';
import useLogo from 'utils/hooks/useLogo';
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';

export default function Home() {
const { t } = useTranslation('home/home');
Expand All @@ -20,7 +20,7 @@ export default function Home() {
rollingStockEditorAllowed,
mapAllowed,
} = useAllowedUserRoles();
const { digitalTwinLogoWithName } = useLogo();
const { digitalTwinLogoWithName } = useDeploymentSettings();

return (
<ModalProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const MONTH_VALUES = {
JUNE: 5,
DECEMBER: 11,
};
type DeploymentSetting = {
type DeploymentSettings = {
digitalTwinName: string;
digitalTwinLogo: string;
digitalTwinLogoWithName: string;
Expand All @@ -21,18 +21,17 @@ type DeploymentSetting = {
isCustomizedDeployment: boolean;
};

const useLogo = () => {
const [customizedDeploymentSetting, setCustomizedDeploymentSetting] = useState<DeploymentSetting>(
{
const useDeploymentSettings = () => {
const [customizedDeploymentSetting, setCustomizedDeploymentSetting] =
useState<DeploymentSettings>({
digitalTwinName: 'Osrd',
digitalTwinLogo: defaultLogo,
digitalTwinLogoWithName: defaultOsrdLogo,
stdcmName: 'Stdcm',
stdcmLogo: undefined,
stdcmSimulationSheetLogo: undefined,
isCustomizedDeployment: false,
}
);
});

useEffect(() => {
const fetchInternalProd = async () => {
Expand Down Expand Up @@ -60,19 +59,19 @@ const useLogo = () => {
}
} else {
const overridesData = await response.json();
const { icons, name } = overridesData;
const { icons, names } = overridesData;

const lmrLogoPath = `/overrides/${icons.stdcm.light}.svg`;
const lmrPngLogoPath = `/overrides/${icons.stdcm.light}@2x.png`;
const horizonLogoWithNamePath = `/overrides/${icons.digital_twin.dark}_Grey10.svg`;
const horizonLogoPath = `/overrides/Logo_OSRD_Grey40.svg`;
const horizonLogoPath = `/overrides/${icons.digital_twin.dark}_Logo_Grey40.svg`;

setCustomizedDeploymentSetting((prev) => ({
...prev,
digitalTwinName: name.digital_twin,
digitalTwinName: names.digital_twin,
digitalTwinLogo: horizonLogoPath,
digitalTwinLogoWithName: horizonLogoWithNamePath,
stdcmName: name.stdcm,
stdcmName: names.stdcm,
stdcmLogo: lmrLogoPath,
stdcmSimulationSheetLogo: lmrPngLogoPath,
isCustomizedDeployment: true,
Expand All @@ -88,4 +87,4 @@ const useLogo = () => {
return { ...customizedDeploymentSetting };
};

export default useLogo;
export default useDeploymentSettings;

0 comments on commit 6936ddb

Please sign in to comment.