-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.tsx
More file actions
44 lines (37 loc) · 1.08 KB
/
App.tsx
File metadata and controls
44 lines (37 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import './App.css';
import DuplicatePop from './pages/DuplicatePop';
import MainPop from './pages/MainPop';
import { useState, useEffect } from 'react';
import { useGetArticleSaved } from '@apis/query/queries';
import { usePageMeta } from './hooks/usePageMeta';
const App = () => {
const { url } = usePageMeta();
const { data: isSaved } = useGetArticleSaved(url);
const [isDuplicatePop, setIsDuplicatePop] = useState(false);
const [mainPopType, setMainPopType] = useState<"add" | "edit">("add");
useEffect(() => {
if (isSaved?.data) {
setIsDuplicatePop(true);
}
}, [isSaved]);
const handleDuplicateLeftClick = () => {
setIsDuplicatePop(false);
setMainPopType("edit");
};
const handleDuplicateRightClick = () => {
window.location.href = "/dashboard";
};
return (
<>
{isDuplicatePop ? (
<DuplicatePop
onLeftClick={handleDuplicateLeftClick}
onRightClick={handleDuplicateRightClick}
/>
) : (
<MainPop type={mainPopType} savedData={isSaved?.data}/>
)}
</>
);
};
export default App;