import { Add, CalendarMonth, Description, PersonOutline, Upload } from '@mui/icons-material' import { Box, Button, Tooltip, Typography } from '@mui/material' import { useNavigate } from 'react-router-dom' import { appPrivateRoutes, appPublicRoutes } from '../../routes' import styles from './style.module.scss' import { useRef } from 'react' import JSZip from 'jszip' import { toast } from 'react-toastify' export const HomePage = () => { const navigate = useNavigate() const fileInputRef = useRef(null) const handleUploadClick = () => { if (fileInputRef.current) { fileInputRef.current.click() } } const handleFileChange = async ( event: React.ChangeEvent ) => { const file = event.target.files?.[0] if (file) { // Check if the file extension is .sigit.zip const fileName = file.name const fileExtension = fileName.slice(-10) // ".sigit.zip" has 10 characters if (fileExtension === '.sigit.zip') { const zip = await JSZip.loadAsync(file).catch((err) => { console.log('err in loading zip file :>> ', err) toast.error(err.message || 'An error occurred in loading zip file.') return null }) if (!zip) return // navigate to sign page if zip contains keys.json if ('keys.json' in zip.files) { return navigate(appPrivateRoutes.sign, { state: { uploadedZip: file } }) } // navigate to verify page if zip contains meta.json if ('meta.json' in zip.files) { return navigate(appPublicRoutes.verify, { state: { uploadedZip: file } }) } toast.error('Invalid zip file') return } // navigate to create page navigate(appPrivateRoutes.create, { state: { uploadedFile: file } }) } } return ( Sigits {/* This is for desktop view */} {/* This is for mobile view */} ) } const PlaceHolder = () => { return ( Title Sigit 07 Jun 10:23 AM Sent placeholder@sigit.io Awaiting placeholder@sigit.io ) }