Skip to content

Commit

Permalink
Added attachment, fixed discharge summary
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Aug 20, 2024
1 parent a41d41e commit 28102c6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/Components/Common/components/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ export default function Tabs(props: {
tabSwitcherRef.current.style.left =
tabButton.getBoundingClientRect().left -
ref.current.getBoundingClientRect().left +
ref.current.scrollLeft +
"px";
}, [currentTab, tabSwitcherRef.current, ref.current, dimensions]);

return (
<div
className={classNames(
"relative inline-flex w-full items-center justify-between rounded-md bg-primary-500/10 p-2 md:w-auto",
"relative inline-flex w-full items-center justify-between overflow-auto rounded-md bg-primary-500/10 p-2 md:w-auto",
className,
)}
ref={ref}
Expand All @@ -53,7 +54,7 @@ export default function Tabs(props: {
{tab.text}
</div>
))}
<div className="absolute inset-2 z-20 flex items-center justify-between">
<div className="absolute inset-2 z-10 flex items-center justify-between">
{tabs.map((tab, i) => (
<button
key={i}
Expand Down
11 changes: 9 additions & 2 deletions src/Components/Files/FileBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ export interface FileBlockProps {
fileManager: FileManagerResult;
associating_id: string;
editable: boolean;
archivable?: boolean;
}

export default function FileBlock(props: FileBlockProps) {
const { file, fileManager, associating_id, editable = false } = props;
const {
file,
fileManager,
associating_id,
editable = false,
archivable = false,
} = props;

const filetype = fileManager.getFileType(file);

Expand Down Expand Up @@ -104,7 +111,7 @@ export default function FileBlock(props: FileBlockProps) {
Rename
</ButtonV2>
)}
{(file.is_archived || editable) && (
{(file.is_archived || editable) && archivable && (
<ButtonV2
variant={file.is_archived ? "primary" : "secondary"}
onClick={() => fileManager.archiveFile(file, associating_id)}
Expand Down
27 changes: 26 additions & 1 deletion src/Components/Files/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ export const FileUpload = (props: FileUploadProps) => {
onEdit: refetchAll,
});

const dischargeSummaryFileManager = useFileManager({
type: "DISCHARGE_SUMMARY",
onArchive: refetchAll,
onEdit: refetchAll,
});

const uploadButtons: {
name: string;
icon: IconName;
Expand Down Expand Up @@ -237,6 +243,7 @@ export const FileUpload = (props: FileUploadProps) => {
<div className={`md:p-4 ${props.className}`}>
{fileUpload.Dialogues}
{fileManager.Dialogues}
{dischargeSummaryFileManager.Dialogues}
{!hideUpload && (
<AuthorizedChild authorizeFor={NonReadOnlyUsers}>
{({ isAuthorized }) =>
Expand All @@ -245,6 +252,19 @@ export const FileUpload = (props: FileUploadProps) => {
<h4 className="mb-6 text-2xl">{UPLOAD_HEADING[type]}</h4>
{fileUpload.file ? (
<div className="mb-8 rounded-lg border border-secondary-300 bg-white p-4">
<div className="mb-4 flex items-center justify-between gap-2 rounded-md bg-secondary-300 px-4 py-2">
<span>
<CareIcon icon="l-paperclip" className="mr-2" />
{fileUpload.file.name}
</span>
<button
onClick={fileUpload.clearFile}
disabled={!!fileUpload.progress}
className="text-lg"
>
<CareIcon icon="l-times" />
</button>
</div>
<TextFormField
name="consultation_file"
type="text"
Expand Down Expand Up @@ -322,13 +342,18 @@ export const FileUpload = (props: FileUploadProps) => {
<FileBlock
file={item}
key={item.id}
fileManager={fileManager}
fileManager={
tab !== "DISCHARGE_SUMMARY"
? fileManager
: dischargeSummaryFileManager
}
associating_id={associatedId}
editable={
item?.uploaded_by?.username === authUser.username ||
authUser.user_type === "DistrictAdmin" ||
authUser.user_type === "StateAdmin"
}
archivable={tab !== "DISCHARGE_SUMMARY"}
/>
))}
{!(fileQuery?.data?.results || []).length && (
Expand Down

0 comments on commit 28102c6

Please sign in to comment.