-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Call LearningAssistantSummary endpoint #68
Changes from 2 commits
c702ca1
0e65fc3
f238e09
75dfdb7
4cdc186
5c3b5cf
6a4a2aa
3625ed2
9199c92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,10 @@ | |
disclosureAcknowledged: false, | ||
sidebarIsOpen: false, | ||
isEnabled: false, | ||
auditTrial: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the initial state be |
||
startDate: 0, | ||
expirationDate: null, // TODO: what do we use for a datetime value here? | ||
varshamenon4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}; | ||
|
||
export const learningAssistantSlice = createSlice({ | ||
|
@@ -44,6 +48,10 @@ | |
setIsEnabled: (state, { payload }) => { | ||
state.isEnabled = payload; | ||
}, | ||
setAuditTrial: (state, { payload }) => { | ||
state.auditTrial.startDate = payload.start_date; | ||
state.auditTrial.expirationDate = payload.expiration_date; | ||
}, | ||
}, | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ | |
import { useEffect } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import { updateSidebarIsOpen, getIsEnabled } from '../data/thunks'; | ||
import { updateSidebarIsOpen, getIsEnabled, getAuditTrial } from '../data/thunks'; | ||
import ToggleXpert from '../components/ToggleXpertButton'; | ||
import Sidebar from '../components/Sidebar'; | ||
Check failure on line 7 in src/widgets/Xpert.jsx GitHub Actions / test
|
||
import { ExperimentsProvider } from '../experiments'; | ||
import { useMessageHistory } from '../hooks'; | ||
|
||
|
@@ -15,6 +15,7 @@ | |
const { | ||
isEnabled, | ||
sidebarIsOpen, | ||
auditTrial, | ||
} = useSelector(state => state.learningAssistant); | ||
|
||
const setSidebarIsOpen = (isOpen) => { | ||
|
@@ -25,6 +26,18 @@ | |
dispatch(getIsEnabled(courseId)); | ||
}, [dispatch, courseId]); | ||
|
||
useEffect(() => { | ||
dispatch(getAuditTrial(userId)); | ||
}, [dispatch, userId]); | ||
|
||
const isAuditTrialNotExpired = () => { | ||
const auditTrialExpired = (Date.now() - auditTrial.expirationDate) > 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, that value is stored in Redux as a string, so I'll create a date object from the string here. |
||
if (auditTrialExpired) { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
return isEnabled ? ( | ||
<ExperimentsProvider> | ||
<> | ||
|
@@ -39,6 +52,7 @@ | |
isOpen={sidebarIsOpen} | ||
setIsOpen={setSidebarIsOpen} | ||
unitId={unitId} | ||
auditTrialNotExpired={isAuditTrialNotExpired} | ||
/> | ||
</> | ||
</ExperimentsProvider> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only happening in the case where the user is an audit learner? In other words, where are we handling the logic to check if the learner is audit or verified (since the experience will be different).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following up from a standup discussion we had, I removed the gating here as that functionality will be implemented in another ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great!