Skip to content

Commit 4bbb12b

Browse files
committed
fix(): Fixing the add article UI
1 parent c0738a1 commit 4bbb12b

4 files changed

Lines changed: 72 additions & 60 deletions

File tree

src/screens/articleEditor/ArticleEditor.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,7 @@ const ArticleEditor = () => {
150150
>
151151
Article editor
152152
</Text>
153-
<RadioGroup
154-
value={articleType}
155-
onChange={(value) => {
156-
setArticleType(value as 'New' | 'Update');
157-
}}
158-
>
159-
<Radio value="New">New Article</Radio>
160-
<Radio value="Update">Update Article</Radio>
161-
</RadioGroup>
153+
162154
<Button
163155
onClick={() => {
164156
setState(ARTICLE_DEFAULT);
@@ -252,6 +244,19 @@ const ArticleEditor = () => {
252244
</Button>
253245
</VStack>
254246
<VStack borderLeft={'1px solid gray'} p={1}>
247+
<RadioGroup
248+
value={articleType}
249+
onChange={(value) => {
250+
setArticleType(value as 'New' | 'Update');
251+
}}
252+
>
253+
<Radio value="New" padding={2}>
254+
New Article
255+
</Radio>
256+
<Radio value="Update" padding={2}>
257+
Update Article
258+
</Radio>
259+
</RadioGroup>
255260
<HStack>
256261
<Input
257262
placeholder="Article Key"
@@ -279,7 +284,6 @@ const ArticleEditor = () => {
279284
</Text>
280285
<HStack
281286
width={'100%'}
282-
height={'100%'}
283287
border={'1px solid white'}
284288
borderRadius={'md'}
285289
p={2}
@@ -289,15 +293,17 @@ const ArticleEditor = () => {
289293
<Box
290294
w={'50%'}
291295
height={'100%'}
292-
minH={'100vh'}
296+
minH={'200vh'}
293297
borderRight={'1px solid white'}
294298
>
295299
<MdPreview mdString={state.md_data} />
296300
</Box>
297301
<Textarea
298302
w={'50%'}
299-
h={'100%'}
300-
minH={'100vh'}
303+
height={'200vh'}
304+
resize={'none'}
305+
bgSize={'cover'}
306+
boxSizing="border-box"
301307
value={state.md_data}
302308
onChange={(e) =>
303309
setState((prev) => ({

src/screens/common/NavigationBar.tsx

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { Box, HStack, IconButton, Img, Text } from '@chakra-ui/react';
1+
import { Box, HStack, Img } from '@chakra-ui/react';
22
import { LinkButton, useCursor } from '@components';
33
import AmitRaikwarLogo from '@assets/images/AmitRaikwarLogo.png';
4-
import { RefreshIcon, SearchIcon } from '@assets';
4+
import { SearchIcon } from '@assets';
55
import { useRef } from 'react';
66
import { useTranslation } from 'react-i18next';
77
import { useLocation, useNavigate } from 'react-router-dom';
88
import { useMoveToTop } from '@hooks';
99
import { BASE_URL_ROUTE } from '@router';
10-
import { usePingTest } from '@services';
11-
import { isUndefined } from 'lodash';
10+
import PingTest from './PingTest';
1211

1312
const NavigationLink = [
1413
{
@@ -36,7 +35,6 @@ const ArticleLink = {
3635

3736
const NavigationBar = () => {
3837
const moveToTop = useMoveToTop();
39-
const { data, refetch, isPending } = usePingTest();
4038
const location = useLocation();
4139
const pathName = location.pathname;
4240
const navigate = useNavigate();
@@ -136,46 +134,7 @@ const NavigationBar = () => {
136134
<HStack
137135
onClick={() => {}} // eslint-disable-line
138136
>
139-
<HStack
140-
display={
141-
pathName !== BASE_URL_ROUTE + '/privateRoute' ? 'none' : 'flex'
142-
}
143-
border={'1px solid gray'}
144-
p={2}
145-
>
146-
<IconButton
147-
size={'sm'}
148-
aria-label={''}
149-
icon={<RefreshIcon />}
150-
isDisabled={isPending}
151-
isLoading={isPending}
152-
onClick={() => refetch()}
153-
/>
154-
<Text color={'white'} fontSize={'lg'}>
155-
Server :{' '}
156-
{isUndefined(data) || isPending ? (
157-
<>
158-
<Box
159-
as="span"
160-
w={3}
161-
h={3}
162-
borderRadius="50%"
163-
bg={'red.500'}
164-
display="inline-block"
165-
/>
166-
</>
167-
) : (
168-
<Box
169-
as="span"
170-
w={3}
171-
h={3}
172-
borderRadius="50%"
173-
bg={'green.500'}
174-
display="inline-block"
175-
/>
176-
)}
177-
</Text>
178-
</HStack>
137+
{pathName === BASE_URL_ROUTE + '/privateRoute' && <PingTest />}
179138
<Box
180139
onMouseEnter={onMouseEnter}
181140
onMouseLeave={onMouseLeave}

src/screens/common/PingTest.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { RefreshIcon } from '@assets';
2+
import { HStack, IconButton, Box, Text } from '@chakra-ui/react';
3+
import { usePingTest } from '@services';
4+
5+
const PingTest = () => {
6+
const { isPending, isError, refetch, isRefetching } = usePingTest();
7+
8+
console.log(isError, isPending);
9+
10+
return (
11+
<HStack border={'1px solid gray'} p={2}>
12+
<IconButton
13+
size={'sm'}
14+
aria-label={''}
15+
icon={<RefreshIcon />}
16+
isDisabled={isPending || isRefetching}
17+
isLoading={isPending || isRefetching}
18+
onClick={() => {
19+
refetch();
20+
}}
21+
/>
22+
<Text color={'white'} fontSize={'lg'}>
23+
Server :{' '}
24+
{isPending || isError || isRefetching ? (
25+
<Box
26+
as="span"
27+
w={3}
28+
h={3}
29+
borderRadius="50%"
30+
bg={'red.500'}
31+
display="inline-block"
32+
/>
33+
) : (
34+
<Box
35+
as="span"
36+
w={3}
37+
h={3}
38+
borderRadius="50%"
39+
bg={'green.500'}
40+
display="inline-block"
41+
/>
42+
)}
43+
</Text>
44+
</HStack>
45+
);
46+
};
47+
48+
export default PingTest;

src/services/hooks/articles/usePingTest.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ const usePingTest = () => {
66
method: () => pingTest(),
77
queryOptions: {
88
queryKey: ['ping'],
9-
staleTime: 0,
10-
gcTime: 0,
9+
refetchInterval: 600000,
1110
},
1211
});
1312
};

0 commit comments

Comments
 (0)