Skip to content

Commit

Permalink
Merge pull request #370 from openedx/pwnage101/ENT-8107
Browse files Browse the repository at this point in the history
fix: can create new plans with test plan unchecked
  • Loading branch information
pwnage101 authored Dec 11, 2023
2 parents 439e611 + cdaa47a commit 1541f15
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/Configuration/Provisioning/ProvisioningContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const ProvisioningContextProvider = ({ children }) => {
// `policies` is a list of all policies/budgets inputs for this plan. After form completion, length should be 1 if
// multipleFunds = false, and 2 and multipleFunds = true.
policies: [],
// `internalOnly` backs the "Test plan" checkbox. A true value means the plan will not be customer facing.
internalOnly: false,
},
// `showInvalidField` indicates when form fields are valid/invalid, possibly triggering invalid attributes to be set
// on various form field containers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ const ProvisioningFormInternalOnly = () => {
const { INTERNAL_ONLY } = PROVISIONING_PAGE_TEXT.FORM;
const [formData, isEditMode, hasEdits] = selectProvisioningContext('formData', 'isEditMode', 'hasEdits');

let submittedFormInternalOnly;
if (isEditMode) {
submittedFormInternalOnly = formData.internalOnly;
}
const [value, setValue] = useState(submittedFormInternalOnly || false);
// formData.internalOnly is always defined, whether it's hydrated from an API call (isEditMode = true) or not
// (isEditMode = false) in which case ProvisioningContextProvider supplies a default.
const [value, setValue] = useState(formData.internalOnly || false);

const handleChange = (e) => {
const checkedState = e.target.checked;
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/Provisioning/data/tests/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ describe('transformSubsidyData', () => {
const transformedSinglePolicyData = {
enterpriseUUID,
financialIdentifier: '00kc1230abc1234321',
internalOnly: 'No',
internalOnly: false,
isoStartDate: '2023-04-18T00:00:00.000Z',
isoEndDate: '2023-04-21T00:00:00.000Z',
revenueCategory: 'partner-no-rev-prepay',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const initialStateValue = {
},
formData: {
policies: [],
internalOnly: false,
},
showInvalidField: {
subsidy: [],
Expand Down
8 changes: 4 additions & 4 deletions src/Configuration/testData/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const sampleMultiplePolicyFormData = {
financialIdentifier: '00kc1230abc1234321',
startDate: '2023-04-18',
endDate: '2023-04-21',
internalOnly: 'Yes',
internalOnly: true,
subsidyRevReq: 'partner-no-rev-prepay',
subsidyUuid: '123testSubsidyUuid',
subsidyTitle: 'Test Subsidy',
Expand All @@ -212,7 +212,7 @@ export const sampleSinglePolicyPredefinedCatalogQueryFormData = {
financialIdentifier: '00kc1230abc1234321',
startDate: '2023-04-18',
endDate: '2023-04-21',
internalOnly: 'No',
internalOnly: false,
subsidyRevReq: 'partner-no-rev-prepay',
subsidyTitle: 'Test Subsidy',
};
Expand All @@ -235,7 +235,7 @@ export const sampleSinglePolicyCustomCatalogQueryFormData = {
financialIdentifier: '00kc1230abc1234321',
startDate: '2023-04-06',
endDate: '2023-04-27',
internalOnly: 'Yes',
internalOnly: true,
subsidyRevReq: 'partner-no-rev-prepay',
subsidyTitle: 'Test Subsidy',
};
Expand All @@ -258,7 +258,7 @@ export const sampleSingleEmptyData = {
financialIdentifier: '00kc1230abc1234321',
startDate: '2023-04-06',
endDate: '2023-04-27',
internalOnly: 'Yes',
internalOnly: true,
subsidyRevReq: 'partner-no-rev-prepay',
subsidyTitle: 'Test Subsidy',
};
Expand Down

0 comments on commit 1541f15

Please sign in to comment.