Skip to content

Commit

Permalink
Merge pull request #16 from tekdi/v0.1.3
Browse files Browse the repository at this point in the history
Merge V0.1.3 to main
  • Loading branch information
sudeeppr1998 authored Nov 26, 2024
2 parents 9b64df2 + 1474bcb commit 73cb73c
Show file tree
Hide file tree
Showing 9 changed files with 10,915 additions and 195 deletions.
10,622 changes: 10,622 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/DocumentSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const DocumentSelector = () => {
}}
>
<ListItemText
primary={doc.doc_type}
primary={doc.doc_name}
secondary={doc.doc_id}
sx={{ flexGrow: 1 }}
/>
Expand Down
79 changes: 58 additions & 21 deletions src/components/Fetch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,39 @@ import { useNavigate } from "react-router-dom";
import Header from "./Header";
import BottomNavigationBar from "./BottomNavigationBar";

const Fetch = ({ documentType, onDocumentTypeChange }) => {
const Fetch = () => {
const [open, setOpen] = useState(false);
const navigate = useNavigate();
const [selectedDocument, setSelectedDocument] = useState(documentType || "");
const [selectedDocument, setSelectedDocument] = useState(null);
const [docId, setDocId] = useState("");
const [errors, setErrors] = useState({ documentType: "", docId: "" });

// Handle document selection
const handleDocumentChange = (e) => {
const selected = e.target.value;
const selectedDoc = documentTypes.find((doc) => doc.value === selected);
setSelectedDocument(selectedDoc);
};

const handleFetch = () => {
let formErrors = { documentType: "", docId: "" };

// Validate document type and document ID
if (!selectedDocument) {
formErrors.documentType = "Document type is required.";
}

if (!docId) {
formErrors.docId = "Document ID is required.";
}

setErrors(formErrors);

// Proceed only if no errors
if (!formErrors.documentType && !formErrors.docId) {
setOpen(true); // Open the confirmation dialog
}
};

return (
<Box sx={{ display: "flex", flexDirection: "column", minHeight: "100vh" }}>
Expand Down Expand Up @@ -54,13 +82,13 @@ const Fetch = ({ documentType, onDocumentTypeChange }) => {
Select Document Type
</Typography>

<FormControl fullWidth sx={{ my: 2 }}>
<FormControl fullWidth sx={{ my: 2 }} error={Boolean(errors.documentType)}>
<InputLabel sx={{ fontFamily: "Poppins, sans-serif" }}>
Select Document Type
</InputLabel>
<Select
value={selectedDocument}
onChange={(e) => setSelectedDocument(e.target.value)}
value={selectedDocument?.value || ""}
onChange={handleDocumentChange}
label="Select Document Type"
sx={{ fontFamily: "Poppins, sans-serif" }}
>
Expand All @@ -70,6 +98,9 @@ const Fetch = ({ documentType, onDocumentTypeChange }) => {
</MenuItem>
))}
</Select>
{errors.documentType && (
<FormHelperText>{errors.documentType}</FormHelperText>
)}
</FormControl>

{/* Document ID Input */}
Expand All @@ -86,39 +117,45 @@ const Fetch = ({ documentType, onDocumentTypeChange }) => {
placeholder="Paste Here"
value={docId}
onChange={(e) => setDocId(e.target.value)}
error={Boolean(errors.docId)}
helperText={
<Box
sx={{
display: "flex",
alignItems: "center",
fontFamily: "Poppins, sans-serif",
}}
>
<Info />
<FormHelperText sx={{ ml: 0.4 }}>
Hint Text: Where this ID can be found
</FormHelperText>
</Box>
errors.docId && (
<Box
sx={{
display: "flex",
alignItems: "center",
fontFamily: "Poppins, sans-serif",
}}
>
<Info />
<FormHelperText sx={{ ml: 0.4 }}>
Hint Text: Where this ID can be found
</FormHelperText>
</Box>
)
}
/>
</Box>

{/* Fetch Button */}
<Button
variant="contained"
fullWidth
startIcon={<DownloadIcon />}
onClick={() => setOpen(true)}
onClick={handleFetch} // Trigger fetch only if valid
sx={{ borderRadius: 7 }}
>
Fetch
</Button>

{/* Confirmation Dialog */}
{/* ShareConfirmationDialog with necessary props */}
<ShareConfirmationDialog
open={open}
onClose={() => setOpen(false)}
documentType={selectedDocument}
docId={docId}
documentType={selectedDocument?.doc_type} // Passing the document type
documentSubType={selectedDocument?.doc_subtype} // Passing the document subtype
documentName={selectedDocument?.value} // Passing the document name
docId={docId} // Passing the document ID
/>
</Container>

Expand Down
2 changes: 1 addition & 1 deletion src/components/MainContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const MainContent = () => {
</ListItemIcon>
<Box sx={{ display: "flex", flexDirection: "column" }}>
<ListItemText
primary={doc.doc_type}
primary={doc.doc_name}
primaryTypographyProps={{
sx: {
fontSize: "1rem",
Expand Down
2 changes: 1 addition & 1 deletion src/components/PrivateRoute.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useLocation, useNavigate } from "react-router-dom";
import { useKeycloak } from "@react-keycloak/web";
import { useEffect } from "react";

const PrivateRoute = ({ children }) => {
// const isLoggedIn = localStorage.getItem("authToken");
const navigate = useNavigate();
const { keycloak } = useKeycloak();
const location = useLocation();
Expand Down
13 changes: 8 additions & 5 deletions src/components/ShareConfirmationDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
import axios from 'axios';
import { useNavigate } from 'react-router-dom';

const ShareConfirmationDialog = ({ open, onClose, documentType, docId, file }) => {
const ShareConfirmationDialog = ({ open, onClose, documentType,documentSubType,documentName, docId, file }) => {
const navigate = useNavigate();
const [checked, setChecked] = useState(false);
const [showSuccess, setShowSuccess] = useState(false);
Expand All @@ -28,11 +28,13 @@ const ShareConfirmationDialog = ({ open, onClose, documentType, docId, file }) =
try {
let response;
const authToken = localStorage.getItem('authToken');
console.log(documentType,documentSubType,documentName)

if (file) {
const formData = new FormData();
// formData.append('sso_id', ssoId);
formData.append('doc_type', documentType);
formData.append('doc_subtype', documentSubType);
formData.append('doc_name',documentName);
formData.append('file', file);

// API request for upload
Expand All @@ -42,8 +44,9 @@ const ShareConfirmationDialog = ({ open, onClose, documentType, docId, file }) =
});
} else {
const data = new URLSearchParams();
// data.append('sso_id', ssoId);
data.append('doc_type', documentType);
data.append('doc_subtype', documentSubType);
data.append('doc_name',documentName);
data.append('doc_id', docId);

// API request for fetch
Expand Down Expand Up @@ -105,7 +108,7 @@ const ShareConfirmationDialog = ({ open, onClose, documentType, docId, file }) =
<Box sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
<FormControlLabel
control={<Checkbox checked={checked} onChange={handleCheckboxChange} />}
label={documentType}
label={documentName}
/>
</Box>
</DialogContent>
Expand Down Expand Up @@ -144,7 +147,7 @@ const ShareConfirmationDialog = ({ open, onClose, documentType, docId, file }) =
}}>
<Typography variant="h6" sx={{ mb: 3, fontFamily: 'Poppins, sans-serif' }}>
Your <Typography component="span" color="primary" variant="h6" sx={{ fontFamily: 'Poppins, sans-serif' }}>
{documentType}
{documentName}
</Typography> has been added to your documents set in the E-Wallet!
</Typography>

Expand Down
2 changes: 1 addition & 1 deletion src/components/SlideMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const SlideMenu = () => {
localStorage.clear();
localStorage.setItem('logout',true);
// Logout from Keycloak
console.log('Logging out...');
console.log('Logging out...',window.location.origin);
};

return (
Expand Down
Loading

0 comments on commit 73cb73c

Please sign in to comment.