diff --git a/src/components/home/ChooseFileBox.tsx b/src/components/home/ChooseFileBox.tsx new file mode 100644 index 0000000..de6a38a --- /dev/null +++ b/src/components/home/ChooseFileBox.tsx @@ -0,0 +1,33 @@ +import { useMemo, useState } from 'react'; +import { Dialog, DialogBody } from '@material-tailwind/react'; +import { useUploadDocumentBox } from './UploadDocumentBox'; + +// Loc's task in here. +// This style is using custom hook. See ../common/SidebarMenu.tsx +// This hook is used in ./src/pages/HomePage.tsx + +export function useChooseFileBox() { + const { openUploadDocumentBox, UploadDocumentBox } = useUploadDocumentBox(); + + const [openBox, setOpenBox] = useState(false); + + const ChooseFileBox = useMemo( + () => () => { + const handleOpenBox = () => setOpenBox(!openBox); + return ( + <> + + A + + {} + + ); + }, + [openBox, openUploadDocumentBox, UploadDocumentBox] + ); + + return { + openChooseFileBox: () => setOpenBox(true), + ChooseFileBox: ChooseFileBox + }; +} diff --git a/src/components/home/UploadDocumentBox.tsx b/src/components/home/UploadDocumentBox.tsx new file mode 100644 index 0000000..6ae5bbd --- /dev/null +++ b/src/components/home/UploadDocumentBox.tsx @@ -0,0 +1,18 @@ +import { useState } from 'react'; +import { Dialog, DialogBody } from '@material-tailwind/react'; + +export function useUploadDocumentBox() { + const [openBox, setOpenBox] = useState(false); + const handleOpenBox = () => setOpenBox(!openBox); + + const UploadDocumentBox = () => ( + + A + + ); + + return { + openUploadDocumentBox: () => setOpenBox(true), + UploadDocumentBox: UploadDocumentBox + }; +} diff --git a/src/components/home/index.ts b/src/components/home/index.ts index bff3a4f..abab2da 100644 --- a/src/components/home/index.ts +++ b/src/components/home/index.ts @@ -2,5 +2,7 @@ * @file Automatically generated by barrelsby. */ +export * from './ChooseFileBox'; export * from './Orders'; export * from './Slides'; +export * from './UploadDocumentBox'; diff --git a/src/main.tsx b/src/main.tsx index 191f012..7088fa0 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -8,12 +8,10 @@ import './index.css'; import App from './App'; ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - - - - - - - - + + + + + + ); diff --git a/src/pages/HomePage.tsx b/src/pages/HomePage.tsx index 4409d33..72a1a75 100644 --- a/src/pages/HomePage.tsx +++ b/src/pages/HomePage.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react'; import { ArrowRightIcon, PrinterIcon } from '@heroicons/react/24/outline'; -import { Orders, Slides } from '@components/home'; +import { Orders, Slides, useChooseFileBox } from '@components/home'; import { useOrderStore, useSlideStore, useUserInfoStore } from '@states/home'; export function HomePage() { @@ -8,6 +8,8 @@ export function HomePage() { const { slideData, getSlideData } = useSlideStore(); const { getUserInfoData } = useUserInfoStore(); + const { openChooseFileBox, ChooseFileBox } = useChooseFileBox(); + useEffect(() => { getOrderData(); getSlideData(); @@ -15,27 +17,34 @@ export function HomePage() { }, [getOrderData, getSlideData, getUserInfoData]); return ( -
-
-

- Student Smart Printing Service (SSPS) -

-

Welcome Username!

-
-
- -
-
-
- - Order printing + <> +
+
+

+ Student Smart Printing Service (SSPS) +

+

Welcome Username!

- +
+ +
+
+
+ + Order printing +
+ +
+
- -
+ + {} + ); }