import React, {useState, useEffect} from "react"; import { useNavigate, useParams } from "react-router-dom"; import { AuthService, ResourceService } from "../../services"; import { Spinner, Breadcrumb, BreadcrumbItem, Tabs, Tab } from "react-bootstrap"; import { Download, Pencil, Archive } from "react-bootstrap-icons"; import { RESOURCE_TYPE_TEXT } from "../../shared/constants"; const ViewResource = () => { const navigate = useNavigate(); const urlParams = useParams(); const [currentResource, setCurrentResource] = useState(undefined); const redirectTo = () => { navigate(`/medical/resources/list`); } const goToEdit = (id) => { navigate(`/medical/resources/edit/${id}`); } const deactivateResource = (id) => { const data = { status: 'inactive', edit_by: localStorage.getItem('user') && JSON.parse(localStorage.getItem('user'))?.name, edit_date: new Date() }; ResourceService.disableResource(id, data).then(() => { redirectTo(); }); } // Helper function to format address const formatAddress = () => { const line1 = currentResource?.address_line_1 || currentResource?.address || ''; const line2 = currentResource?.address_line_2 || ''; const city = currentResource?.city || ''; const state = currentResource?.state || ''; const zipcode = currentResource?.zipcode || ''; if (!line1 && !city && !state && !zipcode) return '-'; let address = line1; if (line2) address += `, ${line2}`; if (city) address += `, ${city}`; if (state) address += `, ${state}`; if (zipcode) address += ` ${zipcode}`; return address || '-'; } useEffect(() => { if (!AuthService.canAccessLegacySystem()) { window.alert('You haven\'t login yet OR this user does not have access to this page. Please change an admin account to login.') AuthService.logout(); navigate(`/login`); } ResourceService.getResource(urlParams.id).then(resourceData => { setCurrentResource(resourceData.data); }); }, []); return ( <>
Medical Provider Information View Provider Details

View Provider Information

Basic Information
Provider
{currentResource?.name || '-'}
Office Name
{currentResource?.office_name || currentResource?.name_original || '-'}
Specialty
{currentResource?.specialty || '-'}
Type
{RESOURCE_TYPE_TEXT[currentResource?.type] || currentResource?.type || '-'}
Contact Information
Office Phone Number
{currentResource?.phone || '-'}
Secondary Phone Number
{currentResource?.contact || '-'}
Fax Number
{currentResource?.fax || '-'}
Email
{currentResource?.email || '-'}
Provider Address
Address Line 1
{currentResource?.address_line_1 || currentResource?.address || '-'}
Address Line 2
{currentResource?.address_line_2 || '-'}
City
{currentResource?.city || '-'}
State
{currentResource?.state || '-'}
Zip Code
{currentResource?.zipcode || '-'}
Additional Information
Note
{currentResource?.note || currentResource?.description || '-'}
); }; export default ViewResource;