-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: global data state
- Loading branch information
Showing
59 changed files
with
2,029 additions
and
2,022 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,17 +1,28 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import ProgressBar from 'components/ProgressBar'; | ||
|
||
import { useIsPageDataLoaded, useIsORAConfigLoaded } from 'data/services/lms/hooks/selectors'; | ||
|
||
/* The purpose of this component is to wrap views with a header/footer for situations | ||
* where we need to run non-embedded | ||
*/ | ||
|
||
const AppContainer = ({ Component }) => ( | ||
<div className="bg-light-300"> | ||
<Component /> | ||
</div> | ||
); | ||
const AppContainer = ({ children }) => { | ||
const isConfigLoaded = useIsORAConfigLoaded(); | ||
const isPageDataLoaded = useIsPageDataLoaded(); | ||
if (!isConfigLoaded || !isPageDataLoaded) { | ||
return null; | ||
} | ||
return ( | ||
<div style={{ width: '100%' }}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
AppContainer.propTypes = { | ||
Component: PropTypes.elementType.isRequired, | ||
children: PropTypes.node.isRequired, | ||
}; | ||
|
||
export default AppContainer; |
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
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 PropTypes from 'prop-types'; | ||
|
||
import { stepStates } from 'data/services/lms/constants'; | ||
import { useStepState } from 'data/services/lms/hooks/selectors'; | ||
|
||
import useInstructionsMessage from './useInstructionsMessage'; | ||
|
||
const Instructions = ({ step }) => { | ||
const message = useInstructionsMessage(step); | ||
const stepState = useStepState({ step }); | ||
if (stepState !== stepStates.inProgress) { | ||
return null; | ||
} | ||
return ( | ||
<div> | ||
<h2>Instructions</h2> | ||
{message} | ||
</div> | ||
); | ||
}; | ||
Instructions.defaultProps = { | ||
step: null, | ||
}; | ||
Instructions.propTypes = { | ||
step: PropTypes.string, | ||
}; | ||
export default Instructions; |
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,33 @@ | ||
import { defineMessages } from '@edx/frontend-platform/i18n'; | ||
|
||
import { stepNames } from 'data/services/lms/constants'; | ||
|
||
const messages = defineMessages({ | ||
[stepNames.submission]: { | ||
defaultMessage: 'Submittion Instructions: TODO', | ||
description: 'Submission step instructions', | ||
id: 'frontend-app-ora.instructions.submisison', | ||
}, | ||
[stepNames.studentTraining]: { | ||
defaultMessage: 'Student Training Instructions: TODO', | ||
description: 'StudentTraining step instructions', | ||
id: 'frontend-app-ora.instructions.studentTraining', | ||
}, | ||
[stepNames.self]: { | ||
defaultMessage: 'Self Assessment Instructions: TODO', | ||
description: 'Self Assessment step instructions', | ||
id: 'frontend-app-ora.instructions.selfAssessment', | ||
}, | ||
[stepNames.peer]: { | ||
defaultMessage: 'Peer Assessment Instructions: TODO', | ||
description: 'Peer Assessment step instructions', | ||
id: 'frontend-app-ora.instructions.peerAssessment', | ||
}, | ||
[stepNames.done]: { | ||
defaultMessage: 'You have successfully completed this problem and received a {earned}/{possible}.', | ||
description: 'Graded step instructions', | ||
id: 'frontend-app-ora.instructions.done', | ||
}, | ||
}); | ||
|
||
export default messages; |
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,25 @@ | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
|
||
import { useGlobalState } from 'data/services/lms/hooks/selectors'; | ||
import { stepNames, stepStates } from 'data/services/lms/constants'; | ||
|
||
import messages from './messages'; | ||
|
||
const useInstructionsMessage = (step = null) => { | ||
const { formatMessage } = useIntl(); | ||
const { | ||
activeStepName, | ||
effectiveGrade, | ||
stepState, | ||
} = useGlobalState(); | ||
if (step || stepState !== stepStates.inProgress) { | ||
return null; | ||
} | ||
const stepName = step || activeStepName; | ||
if (stepName === stepNames.done) { | ||
return formatMessage(messages[stepNames.done], effectiveGrade); | ||
} | ||
return formatMessage(messages[activeStepName]); | ||
}; | ||
|
||
export default useInstructionsMessage; |
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
Oops, something went wrong.