Skip to content

Commit

Permalink
Merge pull request #361 from ertush/hotfix
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
ertush authored Apr 25, 2024
2 parents fa59956 + 1d24a31 commit 1dde678
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 116 deletions.
63 changes: 43 additions & 20 deletions components/Forms/BasicDetailsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Spinner from '../Spinner'
import { useRouter } from 'next/router';
import { Alert } from '@mui/lab';
import { UpdateFormIdContext } from './Form';
import { indexOf } from 'underscore';

// import { FacilityIdContext, FacilityWardDataContext } from './Form';

Expand Down Expand Up @@ -691,8 +692,11 @@ export function BasicDeatilsForm({ editMode }) {
parent=facilityTypeDetails[0]?.parent;
if(parent)
{
document.getElementsByName('facility_type_parent')[0].value = parent.toString();
}
const facilityTypeParent = document.getElementsByName('facility_type_parent')
if(facilityTypeParent) facilityTypeParent["value"] = parent;
// console.log({typeParent: facilityTypeParent["value"]})

}
})

getFacilityTypeDetails(parent, options?.token)
Expand All @@ -713,14 +717,12 @@ export function BasicDeatilsForm({ editMode }) {

if (isClient) {

// return(
// <pre>
// {
// JSON.stringify({data: options?.data}, null, 2)
// }
// </pre>
// )

// return (
// <pre>{
// JSON.stringify(formError, null, 2)
// }</pre>
// )

return (
<form name='basic_details_form'
Expand Down Expand Up @@ -1669,24 +1671,45 @@ export function BasicDeatilsForm({ editMode }) {
checklist file upload

</label>

{
editMode ?
<input

editMode ?

<div className='w-full flex flex-col gap-3 p-2 border border-gray-400 rounded'>

{
options?.data?.facility_checklist_document?.url !== (null || undefined) &&
<span className='w-full flex flex-col border border-blue-400 rounded p-3 bg-blue-100'>
<p>Uploaded File:</p>
<a href={`${process.env.NEXT_PUBLIC_API_URL.substring(0, process.env.NEXT_PUBLIC_API_URL.length - 3)}media/${options?.data?.facility_checklist_document?.url}`} className="text-blue-900 hover:underline">
{/* {options?.data?.official_name} Facility Checklist File */}
{options?.data?.facility_checklist_document?.url}
</a>
</span>
}

<input
type='file'
readOnly
// disabled={options?.data?.facility_checklist_document?.url !== (null || undefined)}
name='facility_checklist_document'
disabled={editMode}
defaultValue={options?.data?.facility_checklist_document}
accept="image/png, image/jpeg .doc, .docx, .xml, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document"
// defaultValue={`Checklist File is ${options?.data?.facility_checklist_document?.url ?? 'missing'}`}
className='flex-none w-full bg-transparent p-2 flex-grow border placeholder-gray-500 border-gray-400 rounded focus:shadow-none focus:border-black outline-none'
/> :
className='flex-none w-full bg-transparent border-none outline-none flex-grow placeholder-gray-500 '
/>


</div>
:

<input
type='file'
required
name='facility_checklist_document'
className='flex-none w-full bg-transparent p-2 flex-grow border placeholder-gray-500 border-gray-400 rounded focus:shadow-none focus:border-black outline-none'
className='flex-none w-full bg-transparent p-2 flex-grow border placeholder-gray-500 border-gray-400 rounded focus:shadow-none focus:border-black outline-none'
/>
}



}


</div>
Expand Down
Loading

0 comments on commit 1dde678

Please sign in to comment.