Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CRDCDH-561 Added "Update" upload Metadata Intention #232

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/components/DataSubmissions/DataSubmissionUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ const VisuallyHiddenInput = styled("input")(() => ({

const UploadRoles: User["role"][] = ["Organization Owner"]; // and submission owner

type UploadType = "New" | "Update";

type Props = {
submitterID: string;
readOnly?: boolean;
Expand All @@ -121,7 +119,7 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
const { submissionId } = useParams();
const { user } = useAuthContext();

const [uploadType, setUploadType] = useState<UploadType>("New");
const [metadataIntention, setMetadataIntention] = useState<MetadataIntention>("New");
const [selectedFiles, setSelectedFiles] = useState<FileList | null>(null);
const [isUploading, setIsUploading] = useState<boolean>(false);
const uploadMetatadataInputRef = useRef<HTMLInputElement>(null);
Expand Down Expand Up @@ -195,7 +193,7 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
variables: {
submissionID: submissionId,
type: "metadata",
metadataIntention: "New",
metadataIntention,
files: formattedFiles,
}
});
Expand Down Expand Up @@ -299,9 +297,9 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
<RadioInput
id="data-submission-dashboard-upload-type"
label="Upload Type"
value={uploadType}
onChange={(event, value: UploadType) => setUploadType(value)}
options={[{ label: "New", value: "New" }, { label: "Update", value: "Update", disabled: true }]}
value={metadataIntention}
onChange={(_event, value: MetadataIntention) => setMetadataIntention(value)}
options={[{ label: "New", value: "New", disabled: !canUpload }, { label: "Update", value: "Update", disabled: !canUpload }]}
gridWidth={4}
readOnly={readOnly}
inline
Expand Down
6 changes: 5 additions & 1 deletion src/components/DataSubmissions/RadioInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const StyledAsterisk = styled("span")(() => ({

const StyledRadio = styled(Radio)((props) => ({
"& input": {
cursor: props.readOnly ? "not-allowed" : "initial",
cursor: props.readOnly ? "not-allowed" : "pointer",
},
"& .radio-icon": {
backgroundColor: props.readOnly ? "#D2DFE9 !important" : "initial",
Expand Down Expand Up @@ -173,6 +173,10 @@ const RadioYesNoInput: FC<Props> = ({
};
}, [radioGroupInputRef]);

useEffect(() => {
setVal(value?.toString() ?? null);
}, [value]);

return (
<GridStyled md={gridWidth || 6} xs={12} item $containerWidth={containerWidth}>
<FormControl className="formControl" error={error}>
Expand Down