summaryrefslogtreecommitdiff
path: root/app/lib/camera/component/sjCamera.tsx
blob: 5cc39ad0474cd64e3d8f3d596b416aa46ecf64f9 (plain)
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
45
46
47
48
import React from "react";
import useCameraStore from "../hooks/useCameraStore";
import { IconButton } from "@mui/material";
import { PendingActions } from "@mui/icons-material";

const SjCamera: React.FC = () => {
  const { setImageSj } = useCameraStore();
  const handleSuratJalanCapture = (
    event: React.ChangeEvent<HTMLInputElement>
  ) => {
    const file = event.target.files?.[0];
    if (file) {
      const reader = new FileReader();
      reader.onloadend = () => {
        setImageSj(reader.result as string);
      };
      reader.readAsDataURL(file);
    }
  };

  return (
    <>
      <div className="p-4 py-8 items-center border-2 rounded-md shadow-sm w-[49%] text-center">
        <input
          type="file"
          accept="image/*"
          capture="environment"
          onChange={handleSuratJalanCapture}
          className="hidden"
          id="suratJalanInput"
        />
        <label htmlFor="suratJalanInput" className="text-gray-600">
          <IconButton
            color="primary"
            aria-label="upload picture"
            component="span"
          >
            <PendingActions fontSize="large" />
          </IconButton>
          <br />
          Foto Surat Jalan
        </label>
      </div>
    </>
  );
};

export default SjCamera;