Skip to content

Commit

Permalink
fix: merge cause code bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhiter committed Feb 21, 2025
1 parent 1251c97 commit 6a8dc68
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 130 deletions.
3 changes: 3 additions & 0 deletions frontend/providers/devbox/api/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const listOfficialTemplateRepository = () =>
kind: TemplateRepositoryKind;
iconId: string;
description: string | null;
templateRepositoryTags: {
tag: Tag;
}[];
}[];
}>(`/api/templateRepository/listOfficial`);
export const listTemplateRepository = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function GpuSelector({
['list-official-template-repository'],
listOfficialTemplateRepository
);

const templateData = useMemo(
() => templateRepositoryQuery.data?.templateRepositoryList || [],
[templateRepositoryQuery.data]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
'use client';
'use client';

import { Box, Flex, Grid, useTheme } from '@chakra-ui/react';
import { Tabs } from '@sealos/ui';
import { throttle } from 'lodash';
import { useTranslations } from 'next-intl';
import { useEffect, useState } from 'react';
import { useFormContext } from 'react-hook-form';
import { Box, Flex, Grid, useTheme } from '@chakra-ui/react';
import { Tabs } from '@sealos/ui';
import { throttle } from 'lodash';
import { useTranslations } from 'next-intl';
import { useEffect, useState } from 'react';
import { useFormContext } from 'react-hook-form';

import MyIcon from '@/components/Icon';
import PriceBox from '@/components/PriceBox';
import QuotaBox from '@/components/QuotaBox';
import { useRouter } from '@/i18n';
import MyIcon from '@/components/Icon';
import PriceBox from '@/components/PriceBox';
import QuotaBox from '@/components/QuotaBox';
import { useRouter } from '@/i18n';

import { useDevboxStore } from '@/stores/devbox';
import { useDevboxStore } from '@/stores/devbox';

import type { DevboxEditTypeV2 } from '@/types/devbox';
import { obj2Query } from '@/utils/tools';
import BasicConfiguration from './BasicConfiguration';
import NetworkConfiguration from './NetworkConfiguration';
import type { DevboxEditTypeV2 } from '@/types/devbox';
import { obj2Query } from '@/utils/tools';
import BasicConfiguration from './BasicConfiguration';
Expand Down Expand Up @@ -60,58 +45,42 @@ const Form = ({
icon: 'network'
}
];
const [activeNav, setActiveNav] = useState(navList[0].id);
const { devboxList } = useDevboxStore();
];

const [activeNav, setActiveNav] = useState(navList[0].id);
const { devboxList } = useDevboxStore();

// listen scroll and set activeNav
useEffect(() => {
const scrollFn = throttle((e: Event) => {
if (!e.target) return;
if (!e.target) return;
const doms = navList.map((item) => ({
dom: document.getElementById(item.id),
id: item.id
}));
}));

const dom = e.target as HTMLDivElement;
const scrollTop = dom.scrollTop;
const dom = e.target as HTMLDivElement;
const scrollTop = dom.scrollTop;
for (let i = doms.length - 1; i >= 0; i--) {
const offsetTop = doms[i].dom?.offsetTop || 0;
const offsetTop = doms[i].dom?.offsetTop || 0;

if (scrollTop + 500 >= offsetTop) {
setActiveNav(doms[i].id);
break;
setActiveNav(doms[i].id);
break;
}
}
}, 200);
document.getElementById('form-container')?.addEventListener('scroll', scrollFn);
}, 200);
document.getElementById('form-container')?.addEventListener('scroll', scrollFn);
return () => {
document.getElementById('form-container')?.removeEventListener('scroll', scrollFn);
};
document.getElementById('form-container')?.removeEventListener('scroll', scrollFn);
};
// eslint-disable-next-line
}, []);
}, []);

const boxStyles = {
border: theme.borders.base,
borderRadius: 'lg',
mb: 4,
bg: 'white'
};
};

return (
<Grid
Expand Down Expand Up @@ -222,4 +191,3 @@ const Form = ({
};

export default Form;
export default Form;
Loading

0 comments on commit 6a8dc68

Please sign in to comment.