Skip to content

Commit

Permalink
fixup: fix Elyse's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriel-Sautron committed Jan 9, 2025
1 parent ef600c1 commit 9e3dc3d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type { SimulationReportSheetProps } from '../../types';
import { getStopDurationTime } from '../../utils/formatSimulationReportSheet';

const getSecondaryCode = ({ location }: StdcmPathStep) => location!.secondary_code;
const lmrLogoPath = '../../overrides/[email protected]';

const getStopType = (step: StdcmPathStep, t: TFunction) => {
if (!step.isVia) {
Expand All @@ -37,7 +36,7 @@ const getArrivalTime = (step: StdcmPathStep, t: TFunction) => {

const LogoSTDCM = ({ logo, t }: { logo: string | undefined; t: TFunction }) => {
if (logo) {
return <Image src={lmrLogoPath} style={styles.header.lmrLogo} />;
return <Image src={logo} style={styles.header.lmrLogo} />;
}
return (
<>
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 @@ -27,7 +27,7 @@ type Props = {

const LegacyNavBarSNCF = ({ appName, logo }: Props) => {
const { openModal } = useModal();
const { digitalTwin, isIntenalProd } = useLogo();
const { digitalTwin, customizedDeployment } = useLogo();
const safeWord = useSelector(getUserSafeWord);
const { t } = useTranslation('home/navbar');
const { logout, username } = useAuth();
Expand All @@ -38,7 +38,7 @@ const LegacyNavBarSNCF = ({ appName, logo }: Props) => {
<div className="mastheader">
<div
className={cx(
isIntenalProd && logo ? `mastheader-logo__horizon` : `mastheader-logo`,
customizedDeployment && logo ? `mastheader-logo__horizon` : `mastheader-logo`,
`flex-grow-0`
)}
>
Expand Down
27 changes: 15 additions & 12 deletions front/src/utils/hooks/useLogo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,50 @@ const MONTH_VALUES = {
DECEMBER: 11,
};

const lmrLogoPath = '../../overrides/Logotype_LastMinuteRequest_light.svg';
const horizonFullLogoPath = '../../overrides/Logotype_Horizon_dark.svg';
const horizonLogoPath = '../../overrides/Logo_Horizon.svg';
const lmrPngLogoPath = '../../overrides/[email protected]';

const useLogo = () => {
const [digitalTwin, setDigitalTwin] = useState<{ logo: string; digitalTwinLogo: string }>({
logo: defaultLogo,
digitalTwinLogo: defaultOsrdLogo,
});
const [stdcm, setStdcm] = useState<{ stdcmLogo?: string; stdcmPngLogo: string }>({
const [stdcm, setStdcm] = useState<{ stdcmLogo?: string; stdcmPngLogo?: string }>({
stdcmLogo: undefined,
stdcmPngLogo: defaultLogo,
stdcmPngLogo: undefined,
});
const [isIntenalProd, setIsIntenalProd] = useState(false);
const [customizedDeployment, setCustomizedDeployment] = useState(false);

useEffect(() => {
const fetchInternalProd = async () => {
try {
const response = await fetch('/overrides/overrides.json');
if (!response.ok || response.headers.get('Content-Type') !== 'application/json') {
setIsIntenalProd(false);
setCustomizedDeployment(false);
if (new Date().getMonth() === MONTH_VALUES.JUNE) {
setDigitalTwin({ logo: proudLogo, digitalTwinLogo: proudOsrdLogo });
}
if (new Date().getMonth() === MONTH_VALUES.DECEMBER) {
setDigitalTwin({ logo: xmasLogo, digitalTwinLogo: xmasOsrdLogo });
}
} else {
setIsIntenalProd(true);
const overridesData = await response.json();
const { icons } = overridesData;

const lmrLogoPath = `../../overrides/${icons.stdcm.light}.svg`;
const lmrPngLogoPath = `../../overrides/${icons.stdcm.light}@2x.png`;
const horizonFullLogoPath = `../../overrides/${icons.digital_twin.dark}.svg`;
const horizonLogoPath = `../../overrides/${icons.digital_twin.dark}_logo.svg`;

setCustomizedDeployment(true);
setStdcm({ stdcmLogo: lmrLogoPath, stdcmPngLogo: lmrPngLogoPath });
setDigitalTwin({ logo: horizonLogoPath, digitalTwinLogo: horizonFullLogoPath });
}
} catch {
setIsIntenalProd(false);
setCustomizedDeployment(false);
}
};
fetchInternalProd();
}, []);

return { digitalTwin, stdcm, isIntenalProd };
return { digitalTwin, stdcm, customizedDeployment };
};

export default useLogo;

0 comments on commit 9e3dc3d

Please sign in to comment.