Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: support CAR uploads #82

Merged
merged 1 commit into from
Jan 19, 2024
Merged
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
22 changes: 18 additions & 4 deletions src/components/Uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export const Done = ({ dataCID }: DoneProps): JSX.Element => {

enum UploadType {
File = 'File',
Directory = 'Directory'
Directory = 'Directory',
CAR = 'CAR'
}

function uploadPrompt (uploadType: UploadType) {
Expand All @@ -115,18 +116,26 @@ function uploadPrompt (uploadType: UploadType) {
case UploadType.Directory: {
return 'Drag Directory or Click to Browse'
}
case UploadType.CAR: {
return 'Drag CAR or Click to Browse'
}
}
}

const UploaderForm = (): JSX.Element => {
const [{ status, file }] = useUploader()
const [{ file }, { setUploadAsCAR }] = useUploader()
const [allowDirectory, setAllowDirectory] = useState(false)
const [uploadType, setUploadType] = useState(UploadType.File)
function changeUploadType (type: UploadType) {
if (type === UploadType.File) {
setUploadAsCAR(false)
setAllowDirectory(false)
} else if (type === UploadType.Directory) {
setUploadAsCAR(false)
setAllowDirectory(true)
} else if (type === UploadType.CAR) {
setUploadAsCAR(true)
setAllowDirectory(false)
}
setUploadType(type)
}
Expand All @@ -142,13 +151,18 @@ const UploaderForm = (): JSX.Element => {
</RadioGroup.Option>
<RadioGroup.Option value={UploadType.Directory}>
{({ checked }) => (
<div className={`${checked ? 'bg-blue-200' : ''} w-24 border p-2 rounded-r`}>Directory</div>
<div className={`${checked ? 'bg-blue-200' : ''} w-24 border p-2`}>Directory</div>
)}
</RadioGroup.Option>
<RadioGroup.Option value={UploadType.CAR}>
{({ checked }) => (
<div className={`${checked ? 'bg-blue-200' : ''} w-24 border p-2 rounded-r`}>CAR</div>
)}
</RadioGroup.Option>
</RadioGroup>
{uploadType === UploadType.File && (
<label className='flex flex-row items-center mb-1'>
<WrapInDirectoryCheckbox />
<WrapInDirectoryCheckbox />
<span className='text-sm ml-1'>Wrap In Directory</span>
</label>
)}
Expand Down
Loading