diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2024-10-21 14:54:11 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2024-10-21 14:54:11 +0700 |
| commit | 83d1a1c558293e1b14c9a5847628e7661f749c66 (patch) | |
| tree | 5f083f90192df0fc2aff41e3dd1c3c84f2592352 /app/lib/camera/hooks | |
| parent | 30c5eb5776fcc60f023ad6aa51153cb375c87930 (diff) | |
initial commit
Diffstat (limited to 'app/lib/camera/hooks')
| -rw-r--r-- | app/lib/camera/hooks/useCamera.ts | 32 | ||||
| -rw-r--r-- | app/lib/camera/hooks/useCameraStore.ts | 22 |
2 files changed, 54 insertions, 0 deletions
diff --git a/app/lib/camera/hooks/useCamera.ts b/app/lib/camera/hooks/useCamera.ts new file mode 100644 index 0000000..d85d978 --- /dev/null +++ b/app/lib/camera/hooks/useCamera.ts @@ -0,0 +1,32 @@ +import { useState } from "react" + +const useCamera = () => { + + const [imageSJ, setImageSj] = useState<string | null>(null) + const [imagePackage, setImagePackage] = useState<string | null>(null) + const [barcode, setBarcode] = useState<string | null>(null) + + const [isWebcamVisibleSj, setIsWebcamVisibleSJ] = useState<boolean>(false) + const [isWebcamVisiblePackage, setIsWebcamVisiblePackage] = useState<boolean>(false) + + const handleSubmit = () => { + setIsWebcamVisibleSJ(false) + } + + + return { + barcode, + setBarcode, + imageSJ, + imagePackage, + setImageSj, + setImagePackage, + isWebcamVisibleSj, + isWebcamVisiblePackage, + setIsWebcamVisibleSJ, + setIsWebcamVisiblePackage, + handleSubmit + } +} + +export default useCamera
\ No newline at end of file diff --git a/app/lib/camera/hooks/useCameraStore.ts b/app/lib/camera/hooks/useCameraStore.ts new file mode 100644 index 0000000..c922d1c --- /dev/null +++ b/app/lib/camera/hooks/useCameraStore.ts @@ -0,0 +1,22 @@ +// store/useCameraStore.ts +import { create } from 'zustand' + +interface CameraStore { + barcode: string | null + setBarcode: (barcode: string) => void + imageSj: string | null + setImageSj: (image: string) => void + imagePackage: string | null + setImagePackage: (image: string) => void +} + +const useCameraStore = create<CameraStore>((set) => ({ + barcode: null, + setBarcode: (barcode: string) => set({ barcode: barcode }), + imageSj: null, + setImageSj: (image: string) => set({ imageSj: image }), + imagePackage: null, + setImagePackage: (image: string) => set({ imagePackage: image }), +})) + +export default useCameraStore
\ No newline at end of file |
