Skip to content

Commit

Permalink
(PC-30783)[PRO] feat: image in form can be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
smokhtari-passculture committed Nov 25, 2024
1 parent c8c31ca commit 65f0637
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type ButtonImageEditProps = {
mode: UploaderModeEnum
onClickButtonImage?: () => void
children?: React.ReactNode
disableForm?: boolean
}

export const ButtonImageEdit = ({
Expand All @@ -33,6 +34,7 @@ export const ButtonImageEdit = ({
onImageDelete,
onClickButtonImage,
children,
disableForm
}: ButtonImageEditProps): JSX.Element => {
const { imageUrl, originalImageUrl } = initialValues

Expand Down Expand Up @@ -78,6 +80,7 @@ export const ButtonImageEdit = ({
})}
onClick={onClickButtonImageAdd}
type="button"
disabled={disableForm}
>
<>
<SvgIcon
Expand Down
4 changes: 4 additions & 0 deletions pro/src/components/ImageUploader/ImageUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface ImageUploaderProps {
mode: UploaderModeEnum
onClickButtonImageAdd?: () => void
hideActionButtons?: boolean
disableForm?: boolean
}

export const ImageUploader = ({
Expand All @@ -26,6 +27,7 @@ export const ImageUploader = ({
mode,
onClickButtonImageAdd,
hideActionButtons = false,
disableForm = false
}: ImageUploaderProps) => {
const { imageUrl, originalImageUrl, credit, cropParams } = initialValues

Expand Down Expand Up @@ -58,6 +60,7 @@ export const ImageUploader = ({
onImageUpload={onImageUpload}
onImageDelete={onImageDelete}
onClickButtonImage={onClickButtonImageAdd}
disableForm={disableForm}
/>
{mode !== UploaderModeEnum.OFFER_COLLECTIVE && (
<ButtonAppPreview imageUrl={imageUrl} mode={mode} />
Expand All @@ -73,6 +76,7 @@ export const ImageUploader = ({
onImageUpload={onImageUpload}
onImageDelete={onImageDelete}
onClickButtonImage={onClickButtonImageAdd}
disableForm={disableForm}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ImageUploaderOfferProps {
onImageUpload: (values: OnImageUploadArgs) => void
onImageDelete: () => void
imageOffer: OfferCollectiveImage | null
disableForm: boolean
}

const buildInitialValues = (
Expand All @@ -25,6 +26,7 @@ export const FormImageUploader = ({
onImageUpload,
onImageDelete,
imageOffer,
disableForm
}: ImageUploaderOfferProps) => (
<FormLayout.Section title="Image de l’offre">
<FormLayout.Row>
Expand All @@ -33,6 +35,7 @@ export const FormImageUploader = ({
onImageDelete={onImageDelete}
initialValues={buildInitialValues(imageOffer)}
mode={UploaderModeEnum.OFFER_COLLECTIVE}
disableForm={disableForm}
/>
</FormLayout.Row>
</FormLayout.Section>
Expand Down

0 comments on commit 65f0637

Please sign in to comment.