diff options
Diffstat (limited to 'app/lib/camera')
| -rw-r--r-- | app/lib/camera/component/dispatchCamera.tsx | 43 | ||||
| -rw-r--r-- | app/lib/camera/component/hedear.tsx | 37 | ||||
| -rw-r--r-- | app/lib/camera/hooks/useCameraStore.ts | 4 |
3 files changed, 74 insertions, 10 deletions
diff --git a/app/lib/camera/component/dispatchCamera.tsx b/app/lib/camera/component/dispatchCamera.tsx new file mode 100644 index 0000000..2591413 --- /dev/null +++ b/app/lib/camera/component/dispatchCamera.tsx @@ -0,0 +1,43 @@ +import React from "react"; +import useCameraStore from "../hooks/useCameraStore"; +import { IconButton } from "@mui/material"; +import { LocalShipping } from "@mui/icons-material"; + +const DispatchCamera: React.FC = () => { + const { setImageDispatch } = useCameraStore(); + const handleCapture = (event: React.ChangeEvent<HTMLInputElement>) => { + const file = event.target.files?.[0]; + if (file) { + const reader = new FileReader(); + reader.onloadend = () => { + setImageDispatch(reader.result as string); + }; + reader.readAsDataURL(file); + } + }; + + return ( + <div className="px-4 py-8 items-center border-2 rounded-md shadow-sm w-[49%] text-center "> + <input + type="file" + accept="image/*" + onChange={handleCapture} + className="hidden" + id="dispatchCameraInput" + /> + <label htmlFor="dispatchCameraInput" className="text-gray-600"> + <IconButton + color="primary" + aria-label="upload picture" + component="span" + > + <LocalShipping fontSize="large" /> + </IconButton> + <br /> + Foto Dispatch + </label> + </div> + ); +}; + +export default DispatchCamera; diff --git a/app/lib/camera/component/hedear.tsx b/app/lib/camera/component/hedear.tsx index 2a8bfc6..81f5d01 100644 --- a/app/lib/camera/component/hedear.tsx +++ b/app/lib/camera/component/hedear.tsx @@ -1,36 +1,53 @@ // components/Header.tsx +"use client"; + import Image from "next/image"; import { deleteAuth, getAuth } from "../../api/auth"; import { Button } from "@mui/material"; import { useRouter } from "next/navigation"; +import { useEffect, useState } from "react"; export default function Header() { - const auth = getAuth(); - const route = useRouter(); + const router = useRouter(); + const [mounted, setMounted] = useState(false); + const [auth, setAuth] = useState<any>(null); + + useEffect(() => { + setMounted(true); + try { + setAuth(getAuth()); + } catch { + setAuth(null); + } + }, []); - const handleSigOut = () => { + const handleSignOut = () => { deleteAuth(); - route.push('/login'); + router.push("/login"); }; + return ( <nav className="fixed top-0 left-0 w-full bg-white border-b-2 border-red-500 py-4 px-4 sm:px-96 z-50 shadow-md"> <div className="flex justify-between items-center"> <div className="flex items-center"> <Image - src="/images/indoteknik-logo.png" // Ganti dengan path logo Anda + src="/images/indoteknik-logo.png" alt="Logo" width={120} height={60} className="rounded-full" + priority /> </div> - {auth && ( - <div> - <Button size="small" onClick={() => handleSigOut()}> + <div> + {mounted && auth ? ( + <Button size="small" onClick={handleSignOut}> Logout </Button> - </div> - )} + ) : ( + <span className="inline-block h-8 w-16" aria-hidden /> + )} + </div> </div> </nav> ); diff --git a/app/lib/camera/hooks/useCameraStore.ts b/app/lib/camera/hooks/useCameraStore.ts index c922d1c..359bcb3 100644 --- a/app/lib/camera/hooks/useCameraStore.ts +++ b/app/lib/camera/hooks/useCameraStore.ts @@ -8,6 +8,8 @@ interface CameraStore { setImageSj: (image: string) => void imagePackage: string | null setImagePackage: (image: string) => void + imageDispatch: string | null + setImageDispatch: (image: string) => void } const useCameraStore = create<CameraStore>((set) => ({ @@ -17,6 +19,8 @@ const useCameraStore = create<CameraStore>((set) => ({ setImageSj: (image: string) => set({ imageSj: image }), imagePackage: null, setImagePackage: (image: string) => set({ imagePackage: image }), + imageDispatch: null, + setImageDispatch: (image: string) => set({ imageDispatch: image }), })) export default useCameraStore
\ No newline at end of file |
