Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/components/ToolHeader/ToolHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ const ToolHeader: FC<TToolHeader> = ({
const router = useRouter();
const { locale, asPath } = router as TRouter;

const pathname = usePathname();
const pathname = usePathname() ?? '';
const { isMobile } = useMobile()[1];
const [, { isCoreView }] = useUXCoreGlobals();
const { accountData, setAccountData, ourProjectsModalData } =
useContext(GlobalContext);

const isActive = (pathname: string, href: string) =>
pathname === href || (href !== '/' && pathname.startsWith(href + '/'));
pathname === href || (href !== '/' && pathname?.startsWith(href + '/'));

const imageSrc = useMemo(() => accountData?.picture, [accountData]);
const [showDropdown, setShowDropdown] = useState(false);
Expand Down Expand Up @@ -143,10 +143,16 @@ const ToolHeader: FC<TToolHeader> = ({

const title = changedTitle ? userInfo?.title : userInfo?.user?.title;

const normalizedPath = pathname.replace(/\/+$/, '');
const pathnameWithBypass = /^\/uxcp$/i.test(normalizedPath)
? '/uxcp/'
: normalizedPath;
const path = pathnameWithBypass.replace(/\/+$/, '');

const getActiveFromPath = (pathname: string) => {
if (pathname.includes('/uxcore')) return 'uxcore';
if (pathname.includes('/uxcg')) return 'uxcg';
if (pathname.includes('/uxcp')) return 'uxcp';
if (path.includes('/uxcp')) return 'uxcp';
if (pathname.includes('/uxcat') || pathname.includes('/user'))
return 'uxcat';
return null;
Expand Down
7 changes: 1 addition & 6 deletions src/pages/uxcat/ongoing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import SeoGenerator from '@components/SeoGenerator';
import OngoingLayout from 'src/layouts/OngoingLayout';

import { TRouter } from '@local-types/global';
import { TagType } from '@local-types/data';
import { UXCatDataTypes } from '@local-types/uxcat-types/types';

import { getUXCatStartTest } from '@api/uxcat/start-test';
import { getUserInfo } from '@api/uxcat/users-me';
import { getTags } from '@api/tags';
import { UXCatConfigs } from '@api/uxcat/configs';
import { getFinalTest } from '@api/uxcat/final-test';
import { getUXCatData } from '@api/uxcat/uxcat';
Expand All @@ -22,14 +20,13 @@ import { achievementSlugs } from '@data/uxcat/ongoingTest/realTimeAchievements';
import styles from '@layouts/OngoingLayout/OngoingLayout.module.scss';

type OngoingProps = {
tags: TagType[];
configs: {
testExpirationTime: number;
};
uxcatData: UXCatDataTypes;
};

const Ongoing: FC<OngoingProps> = ({ tags, configs, uxcatData }) => {
const Ongoing: FC<OngoingProps> = ({ configs, uxcatData }) => {
const router = useRouter();
const { locale } = router as TRouter;
const currentLocale = locale === 'ru' ? 'ru' : 'en';
Expand Down Expand Up @@ -192,10 +189,8 @@ export async function getServerSideProps() {
};
}

const tags = getTags();
return {
props: {
tags,
configs,
uxcatData,
},
Expand Down
7 changes: 1 addition & 6 deletions src/pages/uxcat/start-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useRouter } from 'next/router';
import { GetServerSideProps } from 'next';

import { TRouter } from '@local-types/global';
import { TagType } from '@local-types/data';
import { UXCatDataTypes } from '@local-types/uxcat-types/types';

import StartTestLayout from '@layouts/StartTestLayout';
Expand All @@ -15,18 +14,16 @@ import GenderModal from '@components/GenderModal';

import startTestData from '@data/startTest';

import { getTags } from '@api/tags';
import { getUXCatData } from '@api/uxcat/uxcat';
import { getUXCatStatistics } from '@api/uxcat/statistics';
import { UXCatConfigs } from '@api/uxcat/configs';

type StartTestProps = {
tags?: TagType[];
uxcatData: UXCatDataTypes;
uxcatConfigs: any;
};

const StartTest: FC<StartTestProps> = ({ tags, uxcatData, uxcatConfigs }) => {
const StartTest: FC<StartTestProps> = ({ uxcatData, uxcatConfigs }) => {
const router = useRouter();
const { locale } = router as TRouter;
const currentLocale = locale === 'ru' ? 'ru' : 'en';
Expand Down Expand Up @@ -122,13 +119,11 @@ const StartTest: FC<StartTestProps> = ({ tags, uxcatData, uxcatConfigs }) => {
export default StartTest;

export const getServerSideProps: GetServerSideProps = async context => {
const tags = getTags();
const uxcatData = await getUXCatData();
const uxcatConfigs = await UXCatConfigs();

return {
props: {
tags,
uxcatData,
uxcatConfigs,
},
Expand Down
3 changes: 0 additions & 3 deletions src/pages/uxcat/test-result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { GlobalContext } from '@components/Context/GlobalContext';

import uxcatData from '@data/uxcat';

import { getTags } from '@api/tags';
import { getUXCatLastTest } from '@api/uxcat/last-test';
import { UXCatConfigs } from '@api/uxcat/configs';
import { getNotifications } from '@api/uxcat/get-notifications';
Expand Down Expand Up @@ -442,7 +441,6 @@ const TestResult: FC<TestResultProps> = ({
export default TestResult;

export const getServerSideProps: GetServerSideProps = async context => {
const tags = getTags();
const uxcatStrapiData = await getUXCatData();
const configs = await UXCatConfigs();

Expand All @@ -455,7 +453,6 @@ export const getServerSideProps: GetServerSideProps = async context => {

return {
props: {
tags,
uxCatLevels,
achievements,
uxcatStrapiData,
Expand Down