-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '3214-links-repository-per-cycle' into 3214-links-reposi…
…tory-per-cycle_api-delete-repository-item
- Loading branch information
Showing
44 changed files
with
319 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { createContext, Dispatch, SetStateAction, useContext, useMemo, useState } from 'react' | ||
|
||
type FileUploadContextType = { | ||
files: FileList | ||
setFiles: Dispatch<SetStateAction<FileList>> | ||
} | ||
|
||
const FileUploadContext = createContext<FileUploadContextType | undefined>(undefined) | ||
|
||
export const FileUploadProvider: React.FC<React.PropsWithChildren> = ({ children }) => { | ||
const [files, setFiles] = useState<FileList | null>(null) | ||
|
||
const value = useMemo<FileUploadContextType>(() => ({ files, setFiles }), [files]) | ||
|
||
return <FileUploadContext.Provider value={value}>{children}</FileUploadContext.Provider> | ||
} | ||
|
||
export const useFileUploadContext = (): FileUploadContextType => useContext(FileUploadContext) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { FileUploadProvider, useFileUploadContext } from './FileUploadProvider' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 19 additions & 27 deletions
46
src/client/pages/CountryHome/Repository/Actions/Actions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 15 additions & 19 deletions
34
src/client/pages/CountryHome/Repository/Panel/InputField/InputField.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,33 @@ | ||
import './InputField.scss' | ||
import React from 'react' | ||
import React, { useCallback } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
type Props = { | ||
className?: string | ||
label: string | ||
name: string | ||
onChange: (name: string, value: File | string) => void | ||
type: string | ||
onChange: (name: string, value: string) => void | ||
value: string | ||
} | ||
|
||
const InputField: React.FC<Props> = (props: Props) => { | ||
const { label, name, type, className, onChange } = props | ||
const { label, name, onChange, value = '' } = props | ||
const { t } = useTranslation() | ||
|
||
const _onChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
if (name === 'file') { | ||
onChange(name, event.target.files[0]) | ||
return | ||
} | ||
onChange(name, event.target.value) | ||
} | ||
const _onChange = useCallback( | ||
(event: React.ChangeEvent<HTMLInputElement>) => onChange(name, event.target.value), | ||
[name, onChange] | ||
) | ||
|
||
const id = `repository_edit-input-${name}` | ||
|
||
return ( | ||
<div className={`repository-form__input-field ${className}`}> | ||
<div className="repository-form__label">{t(label)}</div> | ||
<input onChange={_onChange} className="repository-form__input" name={name} type={type} /> | ||
<div className="repository-form__input-field"> | ||
<label htmlFor={id} className="repository-form__label"> | ||
{t(label)} | ||
</label> | ||
<input id={id} value={value} onChange={_onChange} className="repository-form__input" name={name} type="text" /> | ||
</div> | ||
) | ||
} | ||
|
||
InputField.defaultProps = { | ||
className: '', | ||
} | ||
|
||
export default InputField |
28 changes: 28 additions & 0 deletions
28
src/client/pages/CountryHome/Repository/Panel/InputFieldFile/InputFieldFile.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { useFileUploadContext } from 'client/components/FileUpload' | ||
|
||
const FileInputField: React.FC = () => { | ||
const { t } = useTranslation() | ||
|
||
const { setFiles } = useFileUploadContext() | ||
|
||
const _onChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setFiles(event.target.files) | ||
} | ||
|
||
const label = `common.file` | ||
const id = `repository_form-input-file` | ||
|
||
return ( | ||
<div className="repository-form__input-field"> | ||
<label htmlFor={id} className="repository-form__label"> | ||
{t(label)} | ||
</label> | ||
<input id={id} onChange={_onChange} className="repository-form__input" name="file" type="file" /> | ||
</div> | ||
) | ||
} | ||
|
||
export default FileInputField |
1 change: 1 addition & 0 deletions
1
src/client/pages/CountryHome/Repository/Panel/InputFieldFile/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './InputFieldFile' |
Oops, something went wrong.