Skip to content

Commit

Permalink
fix: [AXIMST-517] certificates window scroll, modal title (#195)
Browse files Browse the repository at this point in the history
Co-authored-by: Kyrylo Hudym-Levkovych <[email protected]>
  • Loading branch information
khudym and Kyrylo Hudym-Levkovych authored Mar 1, 2024
1 parent 6c8f4ca commit b450cea
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getConfig } from '@edx/frontend-platform';

import ModalDropzone from '../../../generic/modal-dropzone/ModalDropzone';
import ModalNotification from '../../../generic/modal-notification';
import { updateSavingStatus } from '../../data/slice';
import { updateSavingImageStatus } from '../../data/slice';
import commonMessages from '../../messages';
import messages from '../messages';

Expand Down Expand Up @@ -37,7 +37,7 @@ const SignatoryForm = ({
};

const handleSavingStatusDispatch = (status) => {
dispatch(updateSavingStatus(status));
dispatch(updateSavingImageStatus(status));
};

const formData = [
Expand Down Expand Up @@ -71,6 +71,15 @@ const SignatoryForm = ({
},
];

const uploadReplaceText = intl.formatMessage(
messages.uploadImageButton,
{
uploadText: signatureImagePath
? intl.formatMessage(messages.uploadModalReplace)
: intl.formatMessage(messages.uploadModal),
},
);

return (
<div className="bg-light-200 p-2.5 signatory-form" data-testid="signatory-form">
<Stack className="justify-content-between mb-4" direction="horizontal">
Expand Down Expand Up @@ -120,16 +129,7 @@ const SignatoryForm = ({
<span className="x-small">{intl.formatMessage(messages.imageDescription)}</span>
</Form.Control.Feedback>
</Stack>
<Button onClick={open}>
{intl.formatMessage(
messages.uploadImageButton,
{
uploadText: signatureImagePath
? intl.formatMessage(messages.uploadModalReplace)
: intl.formatMessage(messages.uploadModal),
},
)}
</Button>
<Button onClick={open}>{uploadReplaceText}</Button>
</Stack>
</Form.Group>
</Stack>
Expand All @@ -155,7 +155,7 @@ const SignatoryForm = ({
fileTypes={['png']}
onSavingStatus={handleSavingStatusDispatch}
imageHelpText={intl.formatMessage(messages.imageDescription)}
modalTitle={intl.formatMessage(messages.uploadImageButton)}
modalTitle={uploadReplaceText}
/>
<ModalNotification
isOpen={isConfirmOpen}
Expand Down
1 change: 1 addition & 0 deletions src/certificates/data/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createSelector } from '@reduxjs/toolkit';

export const getLoadingStatus = (state) => state.certificates.loadingStatus;
export const getSavingStatus = (state) => state.certificates.savingStatus;
export const getSavingImageStatus = (state) => state.certificates.savingImageStatus;
export const getSendRequestErrors = (state) => state.certificates.sendRequestErrors.developer_message;
export const getCertificates = state => state.certificates.certificatesData.certificates;
export const getHasCertificateModes = state => state.certificates.certificatesData.hasCertificateModes;
Expand Down
5 changes: 5 additions & 0 deletions src/certificates/data/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ const slice = createSlice({
componentMode: MODE_STATES.noModes,
loadingStatus: RequestStatus.PENDING,
savingStatus: '',
savingImageStatus: '',
},
reducers: {
updateSavingStatus: (state, { payload }) => {
state.savingStatus = payload.status;
},
updateSavingImageStatus: (state, { payload }) => {
state.savingImageStatus = payload.status;
},
updateLoadingStatus: (state, { payload }) => {
state.loadingStatus = payload.status;
},
Expand Down Expand Up @@ -45,6 +49,7 @@ export const {
setMode,
updateSavingStatus,
updateLoadingStatus,
updateSavingImageStatus,
fetchCertificatesSuccess,
createCertificateSuccess,
updateCertificateSuccess,
Expand Down
7 changes: 4 additions & 3 deletions src/certificates/layout/hooks/useLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import { useSelector } from 'react-redux';

import { RequestStatus } from '../../../data/constants';
import { getProcessingNotification } from '../../../generic/processing-notification/data/selectors';
import { getSavingStatus } from '../../data/selectors';
import { getSavingStatus, getSavingImageStatus } from '../../data/selectors';

const useLayout = () => {
const savingStatus = useSelector(getSavingStatus);
const savingImageStatus = useSelector(getSavingImageStatus);
const {
isShow: isShowProcessingNotification,
title: processingNotificationTitle,
} = useSelector(getProcessingNotification);

const isQueryPending = savingStatus === RequestStatus.PENDING;
const isQueryFailed = savingStatus === RequestStatus.FAILED;
const isQueryPending = savingStatus === RequestStatus.PENDING || savingImageStatus === RequestStatus.PENDING;
const isQueryFailed = savingStatus === RequestStatus.FAILED || savingImageStatus === RequestStatus.FAILED;

useEffect(() => {
if (savingStatus === RequestStatus.SUCCESSFUL) {
Expand Down

0 comments on commit b450cea

Please sign in to comment.