From d6a56e8be29c1e8ea77d970434b8c441f23acdef Mon Sep 17 00:00:00 2001 From: Miqdad Date: Fri, 19 Sep 2025 17:16:54 +0700 Subject: add role --- app/lib/camera/component/dispatchCamera.tsx | 43 +++++++++++++++++++++++++++++ app/lib/camera/component/hedear.tsx | 37 ++++++++++++++++++------- app/lib/camera/hooks/useCameraStore.ts | 4 +++ 3 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 app/lib/camera/component/dispatchCamera.tsx (limited to 'app/lib/camera') 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) => { + const file = event.target.files?.[0]; + if (file) { + const reader = new FileReader(); + reader.onloadend = () => { + setImageDispatch(reader.result as string); + }; + reader.readAsDataURL(file); + } + }; + + return ( +
+ + +
+ ); +}; + +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(null); + + useEffect(() => { + setMounted(true); + try { + setAuth(getAuth()); + } catch { + setAuth(null); + } + }, []); - const handleSigOut = () => { + const handleSignOut = () => { deleteAuth(); - route.push('/login'); + router.push("/login"); }; + return ( ); 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((set) => ({ @@ -17,6 +19,8 @@ const useCameraStore = create((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 -- cgit v1.2.3 From 5c3d6cfd6f68b6eb7192aba47463bd0541bfbf48 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Sat, 20 Sep 2025 09:27:05 +0700 Subject: add role --- app/lib/camera/hooks/useCameraStore.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/lib/camera') diff --git a/app/lib/camera/hooks/useCameraStore.ts b/app/lib/camera/hooks/useCameraStore.ts index 359bcb3..ad83074 100644 --- a/app/lib/camera/hooks/useCameraStore.ts +++ b/app/lib/camera/hooks/useCameraStore.ts @@ -13,13 +13,13 @@ interface CameraStore { } const useCameraStore = create((set) => ({ - barcode: null, + barcode: '', setBarcode: (barcode: string) => set({ barcode: barcode }), - imageSj: null, + imageSj: '', setImageSj: (image: string) => set({ imageSj: image }), - imagePackage: null, + imagePackage: '', setImagePackage: (image: string) => set({ imagePackage: image }), - imageDispatch: null, + imageDispatch: '', setImageDispatch: (image: string) => set({ imageDispatch: image }), })) -- cgit v1.2.3