@openedx/frontend-app-instructor-dashboard 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.rst +235 -0
- package/dist/Main.d.ts +3 -0
- package/dist/Main.js +13 -0
- package/dist/Main.js.map +1 -0
- package/dist/app.d.ts +3 -0
- package/dist/app.js +18 -0
- package/dist/app.js.map +1 -0
- package/dist/app.scss +10 -0
- package/dist/certificates/CertificatesPage.d.ts +2 -0
- package/dist/certificates/CertificatesPage.js +6 -0
- package/dist/certificates/CertificatesPage.js.map +1 -0
- package/dist/cohorts/CohortsPage.d.ts +3 -0
- package/dist/cohorts/CohortsPage.js +41 -0
- package/dist/cohorts/CohortsPage.js.map +1 -0
- package/dist/cohorts/CohortsPage.scss +14 -0
- package/dist/cohorts/components/CohortCard.d.ts +6 -0
- package/dist/cohorts/components/CohortCard.js +53 -0
- package/dist/cohorts/components/CohortCard.js.map +1 -0
- package/dist/cohorts/components/CohortContext.d.ts +14 -0
- package/dist/cohorts/components/CohortContext.js +46 -0
- package/dist/cohorts/components/CohortContext.js.map +1 -0
- package/dist/cohorts/components/CohortsForm.d.ts +11 -0
- package/dist/cohorts/components/CohortsForm.js +58 -0
- package/dist/cohorts/components/CohortsForm.js.map +1 -0
- package/dist/cohorts/components/DisableCohortsModal.d.ts +7 -0
- package/dist/cohorts/components/DisableCohortsModal.js +10 -0
- package/dist/cohorts/components/DisableCohortsModal.js.map +1 -0
- package/dist/cohorts/components/DisabledCohortsView.d.ts +5 -0
- package/dist/cohorts/components/DisabledCohortsView.js +10 -0
- package/dist/cohorts/components/DisabledCohortsView.js.map +1 -0
- package/dist/cohorts/components/EnabledCohortsView.d.ts +2 -0
- package/dist/cohorts/components/EnabledCohortsView.js +96 -0
- package/dist/cohorts/components/EnabledCohortsView.js.map +1 -0
- package/dist/cohorts/components/ManageLearners.d.ts +2 -0
- package/dist/cohorts/components/ManageLearners.js +64 -0
- package/dist/cohorts/components/ManageLearners.js.map +1 -0
- package/dist/cohorts/components/SelectedCohortInfo.d.ts +2 -0
- package/dist/cohorts/components/SelectedCohortInfo.js +43 -0
- package/dist/cohorts/components/SelectedCohortInfo.js.map +1 -0
- package/dist/cohorts/constants.d.ts +4 -0
- package/dist/cohorts/constants.js +5 -0
- package/dist/cohorts/constants.js.map +1 -0
- package/dist/cohorts/data/api.d.ts +9 -0
- package/dist/cohorts/data/api.js +54 -0
- package/dist/cohorts/data/api.js.map +1 -0
- package/dist/cohorts/data/apiHook.d.ts +14 -0
- package/dist/cohorts/data/apiHook.js +64 -0
- package/dist/cohorts/data/apiHook.js.map +1 -0
- package/dist/cohorts/data/queryKeys.d.ts +7 -0
- package/dist/cohorts/data/queryKeys.js +9 -0
- package/dist/cohorts/data/queryKeys.js.map +1 -0
- package/dist/cohorts/messages.d.ts +233 -0
- package/dist/cohorts/messages.js +235 -0
- package/dist/cohorts/messages.js.map +1 -0
- package/dist/cohorts/types.d.ts +15 -0
- package/dist/cohorts/types.js +2 -0
- package/dist/cohorts/types.js.map +1 -0
- package/dist/components/ActionCard.d.ts +11 -0
- package/dist/components/ActionCard.js +7 -0
- package/dist/components/ActionCard.js.map +1 -0
- package/dist/components/CSVComponent.d.ts +10 -0
- package/dist/components/CSVComponent.js +21 -0
- package/dist/components/CSVComponent.js.map +1 -0
- package/dist/components/ObjectCell.d.ts +5 -0
- package/dist/components/ObjectCell.js +7 -0
- package/dist/components/ObjectCell.js.map +1 -0
- package/dist/components/PageNotFound.d.ts +2 -0
- package/dist/components/PageNotFound.js +12 -0
- package/dist/components/PageNotFound.js.map +1 -0
- package/dist/components/PendingTasks.d.ts +5 -0
- package/dist/components/PendingTasks.js +38 -0
- package/dist/components/PendingTasks.js.map +1 -0
- package/dist/components/SpecifyLearnerField.d.ts +5 -0
- package/dist/components/SpecifyLearnerField.js +10 -0
- package/dist/components/SpecifyLearnerField.js.map +1 -0
- package/dist/components/messages.d.ts +108 -0
- package/dist/components/messages.js +110 -0
- package/dist/components/messages.js.map +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -0
- package/dist/courseInfo/CourseInfoPage.d.ts +2 -0
- package/dist/courseInfo/CourseInfoPage.js +7 -0
- package/dist/courseInfo/CourseInfoPage.js.map +1 -0
- package/dist/courseInfo/components/EnrollmentSummary/EnrollmentCounter.d.ts +8 -0
- package/dist/courseInfo/components/EnrollmentSummary/EnrollmentCounter.js +13 -0
- package/dist/courseInfo/components/EnrollmentSummary/EnrollmentCounter.js.map +1 -0
- package/dist/courseInfo/components/EnrollmentSummary/EnrollmentSummary.d.ts +2 -0
- package/dist/courseInfo/components/EnrollmentSummary/EnrollmentSummary.js +24 -0
- package/dist/courseInfo/components/EnrollmentSummary/EnrollmentSummary.js.map +1 -0
- package/dist/courseInfo/components/EnrollmentSummary/index.d.ts +2 -0
- package/dist/courseInfo/components/EnrollmentSummary/index.js +3 -0
- package/dist/courseInfo/components/EnrollmentSummary/index.js.map +1 -0
- package/dist/courseInfo/components/EnrollmentSummary/messages.d.ts +83 -0
- package/dist/courseInfo/components/EnrollmentSummary/messages.js +85 -0
- package/dist/courseInfo/components/EnrollmentSummary/messages.js.map +1 -0
- package/dist/courseInfo/components/EnrollmentSummary/utils.d.ts +1 -0
- package/dist/courseInfo/components/EnrollmentSummary/utils.js +9 -0
- package/dist/courseInfo/components/EnrollmentSummary/utils.js.map +1 -0
- package/dist/courseInfo/components/generalCourseInfo/GeneralCourseInfo.d.ts +2 -0
- package/dist/courseInfo/components/generalCourseInfo/GeneralCourseInfo.js +46 -0
- package/dist/courseInfo/components/generalCourseInfo/GeneralCourseInfo.js.map +1 -0
- package/dist/courseInfo/components/generalCourseInfo/StatusBadge.d.ts +5 -0
- package/dist/courseInfo/components/generalCourseInfo/StatusBadge.js +15 -0
- package/dist/courseInfo/components/generalCourseInfo/StatusBadge.js.map +1 -0
- package/dist/courseInfo/components/generalCourseInfo/index.d.ts +1 -0
- package/dist/courseInfo/components/generalCourseInfo/index.js +2 -0
- package/dist/courseInfo/components/generalCourseInfo/index.js.map +1 -0
- package/dist/courseInfo/components/generalCourseInfo/messages.d.ts +8 -0
- package/dist/courseInfo/components/generalCourseInfo/messages.js +10 -0
- package/dist/courseInfo/components/generalCourseInfo/messages.js.map +1 -0
- package/dist/courseInfo/messages.d.ts +8 -0
- package/dist/courseInfo/messages.js +10 -0
- package/dist/courseInfo/messages.js.map +1 -0
- package/dist/courseInfo/types.d.ts +27 -0
- package/dist/courseInfo/types.js +2 -0
- package/dist/courseInfo/types.js.map +1 -0
- package/dist/courseTeam/CourseTeamPage.d.ts +2 -0
- package/dist/courseTeam/CourseTeamPage.js +6 -0
- package/dist/courseTeam/CourseTeamPage.js.map +1 -0
- package/dist/data/api.d.ts +14 -0
- package/dist/data/api.js +33 -0
- package/dist/data/api.js.map +1 -0
- package/dist/data/apiHook.d.ts +4 -0
- package/dist/data/apiHook.js +28 -0
- package/dist/data/apiHook.js.map +1 -0
- package/dist/data/queryKeys.d.ts +8 -0
- package/dist/data/queryKeys.js +10 -0
- package/dist/data/queryKeys.js.map +1 -0
- package/dist/dataDownloads/DataDownloadsPage.d.ts +2 -0
- package/dist/dataDownloads/DataDownloadsPage.js +162 -0
- package/dist/dataDownloads/DataDownloadsPage.js.map +1 -0
- package/dist/dataDownloads/components/DataDownloadTable.d.ts +8 -0
- package/dist/dataDownloads/components/DataDownloadTable.js +42 -0
- package/dist/dataDownloads/components/DataDownloadTable.js.map +1 -0
- package/dist/dataDownloads/components/DownloadLinkCell.d.ts +6 -0
- package/dist/dataDownloads/components/DownloadLinkCell.js +13 -0
- package/dist/dataDownloads/components/DownloadLinkCell.js.map +1 -0
- package/dist/dataDownloads/components/GenerateReports.d.ts +8 -0
- package/dist/dataDownloads/components/GenerateReports.js +20 -0
- package/dist/dataDownloads/components/GenerateReports.js.map +1 -0
- package/dist/dataDownloads/components/ReportNameCell.d.ts +3 -0
- package/dist/dataDownloads/components/ReportNameCell.js +6 -0
- package/dist/dataDownloads/components/ReportNameCell.js.map +1 -0
- package/dist/dataDownloads/data/api.d.ts +2 -0
- package/dist/dataDownloads/data/api.js +23 -0
- package/dist/dataDownloads/data/api.js.map +1 -0
- package/dist/dataDownloads/data/apiHook.d.ts +7 -0
- package/dist/dataDownloads/data/apiHook.js +22 -0
- package/dist/dataDownloads/data/apiHook.js.map +1 -0
- package/dist/dataDownloads/data/queryKeys.d.ts +5 -0
- package/dist/dataDownloads/data/queryKeys.js +7 -0
- package/dist/dataDownloads/data/queryKeys.js.map +1 -0
- package/dist/dataDownloads/messages.d.ts +338 -0
- package/dist/dataDownloads/messages.js +341 -0
- package/dist/dataDownloads/messages.js.map +1 -0
- package/dist/dataDownloads/types.d.ts +8 -0
- package/dist/dataDownloads/types.js +2 -0
- package/dist/dataDownloads/types.js.map +1 -0
- package/dist/dataDownloads/utils.d.ts +26 -0
- package/dist/dataDownloads/utils.js +49 -0
- package/dist/dataDownloads/utils.js.map +1 -0
- package/dist/dateExtensions/DateExtensionsPage.d.ts +2 -0
- package/dist/dateExtensions/DateExtensionsPage.js +87 -0
- package/dist/dateExtensions/DateExtensionsPage.js.map +1 -0
- package/dist/dateExtensions/components/AddExtensionModal.d.ts +13 -0
- package/dist/dateExtensions/components/AddExtensionModal.js +34 -0
- package/dist/dateExtensions/components/AddExtensionModal.js.map +1 -0
- package/dist/dateExtensions/components/DateExtensionsList.d.ts +7 -0
- package/dist/dateExtensions/components/DateExtensionsList.js +103 -0
- package/dist/dateExtensions/components/DateExtensionsList.js.map +1 -0
- package/dist/dateExtensions/components/ResetExtensionsModal.d.ts +10 -0
- package/dist/dateExtensions/components/ResetExtensionsModal.js +10 -0
- package/dist/dateExtensions/components/ResetExtensionsModal.js.map +1 -0
- package/dist/dateExtensions/components/SelectGradedSubsection.d.ts +8 -0
- package/dist/dateExtensions/components/SelectGradedSubsection.js +15 -0
- package/dist/dateExtensions/components/SelectGradedSubsection.js.map +1 -0
- package/dist/dateExtensions/data/api.d.ts +6 -0
- package/dist/dateExtensions/data/api.js +40 -0
- package/dist/dateExtensions/data/api.js.map +1 -0
- package/dist/dateExtensions/data/apiHook.d.ts +11 -0
- package/dist/dateExtensions/data/apiHook.js +31 -0
- package/dist/dateExtensions/data/apiHook.js.map +1 -0
- package/dist/dateExtensions/data/queryKeys.d.ts +10 -0
- package/dist/dateExtensions/data/queryKeys.js +17 -0
- package/dist/dateExtensions/data/queryKeys.js.map +1 -0
- package/dist/dateExtensions/messages.d.ts +128 -0
- package/dist/dateExtensions/messages.js +130 -0
- package/dist/dateExtensions/messages.js.map +1 -0
- package/dist/dateExtensions/types.d.ts +24 -0
- package/dist/dateExtensions/types.js +2 -0
- package/dist/dateExtensions/types.js.map +1 -0
- package/dist/enrollments/EnrollmentsPage.d.ts +2 -0
- package/dist/enrollments/EnrollmentsPage.js +32 -0
- package/dist/enrollments/EnrollmentsPage.js.map +1 -0
- package/dist/enrollments/components/EnrollmentStatusModal.d.ts +6 -0
- package/dist/enrollments/components/EnrollmentStatusModal.js +23 -0
- package/dist/enrollments/components/EnrollmentStatusModal.js.map +1 -0
- package/dist/enrollments/components/EnrollmentsList.d.ts +6 -0
- package/dist/enrollments/components/EnrollmentsList.js +99 -0
- package/dist/enrollments/components/EnrollmentsList.js.map +1 -0
- package/dist/enrollments/components/UnenrollModal.d.ts +8 -0
- package/dist/enrollments/components/UnenrollModal.js +7 -0
- package/dist/enrollments/components/UnenrollModal.js.map +1 -0
- package/dist/enrollments/data/api.d.ts +4 -0
- package/dist/enrollments/data/api.js +32 -0
- package/dist/enrollments/data/api.js.map +1 -0
- package/dist/enrollments/data/apiHook.d.ts +3 -0
- package/dist/enrollments/data/apiHook.js +14 -0
- package/dist/enrollments/data/apiHook.js.map +1 -0
- package/dist/enrollments/data/queryKeys.d.ts +7 -0
- package/dist/enrollments/data/queryKeys.js +8 -0
- package/dist/enrollments/data/queryKeys.js.map +1 -0
- package/dist/enrollments/messages.d.ts +108 -0
- package/dist/enrollments/messages.js +110 -0
- package/dist/enrollments/messages.js.map +1 -0
- package/dist/enrollments/types.d.ts +15 -0
- package/dist/enrollments/types.js +2 -0
- package/dist/enrollments/types.js.map +1 -0
- package/dist/grading/GradingPage.d.ts +2 -0
- package/dist/grading/GradingPage.js +6 -0
- package/dist/grading/GradingPage.js.map +1 -0
- package/dist/hooks/useDebouncedFilter.d.ts +16 -0
- package/dist/hooks/useDebouncedFilter.js +27 -0
- package/dist/hooks/useDebouncedFilter.js.map +1 -0
- package/dist/i18n/index.d.ts +25 -0
- package/dist/i18n/index.js +26 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/instructorNav/InstructorNav.d.ts +8 -0
- package/dist/instructorNav/InstructorNav.js +42 -0
- package/dist/instructorNav/InstructorNav.js.map +1 -0
- package/dist/openResponses/OpenResponsesPage.d.ts +2 -0
- package/dist/openResponses/OpenResponsesPage.js +8 -0
- package/dist/openResponses/OpenResponsesPage.js.map +1 -0
- package/dist/openResponses/components/DetailAssessmentsList.d.ts +2 -0
- package/dist/openResponses/components/DetailAssessmentsList.js +44 -0
- package/dist/openResponses/components/DetailAssessmentsList.js.map +1 -0
- package/dist/openResponses/components/OpenResponsesSummary.d.ts +2 -0
- package/dist/openResponses/components/OpenResponsesSummary.js +30 -0
- package/dist/openResponses/components/OpenResponsesSummary.js.map +1 -0
- package/dist/openResponses/data/api.d.ts +4 -0
- package/dist/openResponses/data/api.js +23 -0
- package/dist/openResponses/data/api.js.map +1 -0
- package/dist/openResponses/data/apiHook.d.ts +2 -0
- package/dist/openResponses/data/apiHook.js +14 -0
- package/dist/openResponses/data/apiHook.js.map +1 -0
- package/dist/openResponses/data/queryKeys.d.ts +6 -0
- package/dist/openResponses/data/queryKeys.js +8 -0
- package/dist/openResponses/data/queryKeys.js.map +1 -0
- package/dist/openResponses/messages.d.ts +83 -0
- package/dist/openResponses/messages.js +85 -0
- package/dist/openResponses/messages.js.map +1 -0
- package/dist/openResponses/types.d.ts +12 -0
- package/dist/openResponses/types.js +2 -0
- package/dist/openResponses/types.js.map +1 -0
- package/dist/pageWrapper/PageWrapper.d.ts +4 -0
- package/dist/pageWrapper/PageWrapper.js +11 -0
- package/dist/pageWrapper/PageWrapper.js.map +1 -0
- package/dist/pageWrapper/messages.d.ts +8 -0
- package/dist/pageWrapper/messages.js +10 -0
- package/dist/pageWrapper/messages.js.map +1 -0
- package/dist/providers/AlertProvider.d.ts +41 -0
- package/dist/providers/AlertProvider.js +117 -0
- package/dist/providers/AlertProvider.js.map +1 -0
- package/dist/providers/QueryProvider.d.ts +6 -0
- package/dist/providers/QueryProvider.js +16 -0
- package/dist/providers/QueryProvider.js.map +1 -0
- package/dist/providers.d.ts +3 -0
- package/dist/providers.js +8 -0
- package/dist/providers.js.map +1 -0
- package/dist/routes.d.ts +20 -0
- package/dist/routes.js +72 -0
- package/dist/routes.js.map +1 -0
- package/dist/slots/PlaceholderSlot/PlaceholderSlot.d.ts +1 -0
- package/dist/slots/PlaceholderSlot/PlaceholderSlot.js +6 -0
- package/dist/slots/PlaceholderSlot/PlaceholderSlot.js.map +1 -0
- package/dist/slots/SlotUtils.d.ts +3 -0
- package/dist/slots/SlotUtils.js +17 -0
- package/dist/slots/SlotUtils.js.map +1 -0
- package/dist/slots.d.ts +3 -0
- package/dist/slots.js +3 -0
- package/dist/slots.js.map +1 -0
- package/dist/specialExams/SpecialExamsPage.d.ts +2 -0
- package/dist/specialExams/SpecialExamsPage.js +6 -0
- package/dist/specialExams/SpecialExamsPage.js.map +1 -0
- package/dist/testUtils.d.ts +4 -0
- package/dist/testUtils.js +24 -0
- package/dist/testUtils.js.map +1 -0
- package/dist/types/index.d.ts +40 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/formatters.d.ts +1 -0
- package/dist/utils/formatters.js +12 -0
- package/dist/utils/formatters.js.map +1 -0
- package/package.json +79 -0
|
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S,eACR,KAAC,MAAM,IAAC,OAAO,EAAC,UAAU,EAAC,OAAO,EAAE,QAAQ,YAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAU,EACjG,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,YAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAU,IAC3F,IACP,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,eAAe,WAAW,CAAC","sourcesContent":["import { useParams } from 'react-router-dom';\nimport { useState, useEffect, forwardRef, useImperativeHandle, useCallback } from 'react';\nimport { ActionRow, Button, Form, FormControl, FormGroup, FormLabel, FormRadioSet, Hyperlink, Icon, OverlayTrigger, Tooltip } from '@openedx/paragon';\nimport { useIntl } from '@openedx/frontend-base';\nimport messages from '@src/cohorts/messages';\nimport { useContentGroupsData } from '@src/cohorts/data/apiHook';\nimport { Warning } from '@openedx/paragon/icons';\nimport { assignmentTypes } from '@src/cohorts/constants';\nimport { CohortData } from '@src/cohorts/types';\nimport { useCohortContext } from '@src/cohorts/components/CohortContext';\n\ninterface CohortsFormProps {\n disableManualAssignment?: boolean,\n onCancel: () => void,\n onSubmit: (data: Partial<CohortData>) => void,\n}\n\nexport interface CohortsFormRef {\n resetForm: () => void,\n}\n\nconst CohortsForm = forwardRef<CohortsFormRef, CohortsFormProps>(({ disableManualAssignment = false, onCancel, onSubmit }, ref) => {\n const intl = useIntl();\n const { courseId = '' } = useParams<{ courseId: string }>();\n const { data = { groups: [], id: null, studioContentGroupsLink: '' } } = useContentGroupsData(courseId);\n const { selectedCohort } = useCohortContext();\n\n const initialCohortName = (selectedCohort?.name) ?? '';\n const initialAssignmentType = selectedCohort?.assignmentType ?? assignmentTypes.automatic;\n const initialContentGroupOption = selectedCohort?.groupId ? 'selectContentGroup' : 'noContentGroup';\n const initialContentGroup = selectedCohort?.groupId ? selectedCohort.groupId : null;\n\n const [selectedContentGroup, setSelectedContentGroup] = useState<number | null>(initialContentGroup);\n const [selectedContentGroupOption, setSelectedContentGroupOption] = useState<string>(initialContentGroupOption);\n const [selectedAssignmentType, setSelectedAssignmentType] = useState<string>(initialAssignmentType);\n const [name, setName] = useState<string>(initialCohortName);\n\n const resetToInitialValues = useCallback(() => {\n if (selectedCohort) {\n setName(selectedCohort.name);\n setSelectedAssignmentType(selectedCohort.assignmentType);\n setSelectedContentGroupOption(selectedCohort.groupId ? 'selectContentGroup' : 'noContentGroup');\n setSelectedContentGroup(selectedCohort.groupId ?? null);\n }\n }, [selectedCohort]);\n\n useImperativeHandle(ref, () => ({\n resetForm: resetToInitialValues\n }));\n\n useEffect(() => {\n resetToInitialValues();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedCohort]);\n\n const contentGroups = [{ id: 'null', name: intl.formatMessage(messages.notSelected) }, ...data.groups];\n\n const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n onSubmit({\n name,\n assignmentType: selectedAssignmentType,\n groupId: selectedContentGroup,\n userPartitionId: data.id,\n });\n };\n\n return (\n <Form className=\"my-3.5 mx-4\" onSubmit={handleSubmit}>\n <FormGroup className=\"w-md-50\">\n <FormLabel className=\"text-primary-500\">{intl.formatMessage(messages.cohortName)}</FormLabel>\n <FormControl value={name} onChange={(e) => setName(e.target.value)} placeholder={intl.formatMessage(messages.cohortName)} />\n </FormGroup>\n <FormGroup>\n <FormLabel className=\"text-primary-500\">{intl.formatMessage(messages.cohortAssignmentMethod)}</FormLabel>\n <FormRadioSet name=\"assignmentType\" value={selectedAssignmentType} onChange={(e) => setSelectedAssignmentType(e.target.value)}>\n <Form.Radio className=\"mb-2\" value={assignmentTypes.automatic}>{intl.formatMessage(messages.automatic)}</Form.Radio>\n {disableManualAssignment ? (\n <OverlayTrigger\n placement=\"top\"\n overlay={(\n <Tooltip id=\"manual-assignment-tooltip\" className=\"assignment-tooltip\">\n {intl.formatMessage(messages.manualAssignmentDisabledTooltip)}\n </Tooltip>\n )}\n >\n <span>\n <Form.Radio disabled value={assignmentTypes.manual}>{intl.formatMessage(messages.manual)}</Form.Radio>\n </span>\n </OverlayTrigger>\n )\n : <Form.Radio value={assignmentTypes.manual}>{intl.formatMessage(messages.manual)}</Form.Radio>}\n </FormRadioSet>\n </FormGroup>\n <FormGroup className=\"mb-3.5\">\n <FormLabel className=\"text-primary-500\">{intl.formatMessage(messages.associatedContentGroup)}</FormLabel>\n <FormRadioSet\n name=\"associatedContentGroup\"\n value={selectedContentGroupOption}\n onChange={(e) => setSelectedContentGroupOption(e.target.value)}\n >\n <Form.Radio value=\"noContentGroup\">{intl.formatMessage(messages.noContentGroup)}</Form.Radio>\n <div className=\"d-flex align-items-center\">\n <Form.Radio value=\"selectContentGroup\" disabled={data.groups.length === 0}>{intl.formatMessage(messages.selectAContentGroup)}</Form.Radio>\n { data.groups.length > 0\n ? (\n <FormControl\n as=\"select\"\n className=\"ml-2\"\n size=\"sm\"\n disabled={selectedContentGroupOption !== 'selectContentGroup'}\n name=\"contentGroup\"\n onChange={(e) => setSelectedContentGroup(Number(e.target.value))}\n value={selectedContentGroup}\n >\n {\n contentGroups.map((contentGroup) => (\n <option key={contentGroup.id} value={contentGroup.id}>\n {contentGroup.name}\n </option>\n ))\n }\n </FormControl>\n )\n : (\n <div className=\"d-flex align-items-center small\">\n <Icon className=\"ml-2 text-danger-500\" src={Warning} size=\"sm\" />\n <p className=\"mb-0 ml-1 text-danger-500\">{intl.formatMessage(messages.noContentGroups)}</p>\n <Hyperlink className=\"ml-1\" destination={data.studioContentGroupsLink}>{intl.formatMessage(messages.createContentGroup)}</Hyperlink>\n </div>\n )}\n </div>\n </FormRadioSet>\n </FormGroup>\n <ActionRow>\n <Button variant=\"tertiary\" onClick={onCancel}>{intl.formatMessage(messages.cancelLabel)}</Button>\n <Button type=\"submit\" disabled={name.trim() === ''}>{intl.formatMessage(messages.saveLabel)}</Button>\n </ActionRow>\n </Form>\n );\n});\n\nCohortsForm.displayName = 'CohortsForm';\n\nexport default CohortsForm;\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface DisableCohortsModalProps {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
onConfirmDisable: () => void;
|
|
5
|
+
}
|
|
6
|
+
declare const DisableCohortsModal: ({ isOpen, onClose, onConfirmDisable }: DisableCohortsModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default DisableCohortsModal;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ActionRow, Button, ModalDialog } from '@openedx/paragon';
|
|
3
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
4
|
+
import messages from '../messages';
|
|
5
|
+
const DisableCohortsModal = ({ isOpen, onClose, onConfirmDisable }) => {
|
|
6
|
+
const intl = useIntl();
|
|
7
|
+
return (_jsxs(ModalDialog, { title: intl.formatMessage(messages.disableCohorts), onClose: onClose, isOpen: isOpen, size: "sm", hasCloseButton: false, isOverflowVisible: false, children: [_jsx("div", { className: "mx-4 mt-4 mb-2.5", children: _jsx("p", { children: intl.formatMessage(messages.disableMessage) }) }), _jsx(ModalDialog.Footer, { children: _jsxs(ActionRow, { children: [_jsx(Button, { variant: "tertiary", onClick: onClose, children: intl.formatMessage(messages.cancelLabel) }), _jsx(Button, { variant: "primary", onClick: onConfirmDisable, children: intl.formatMessage(messages.disableLabel) })] }) })] }));
|
|
8
|
+
};
|
|
9
|
+
export default DisableCohortsModal;
|
|
10
|
+
//# sourceMappingURL=DisableCohortsModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisableCohortsModal.js","sourceRoot":"","sources":["../../../src/cohorts/components/DisableCohortsModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAQnC,MAAM,mBAAmB,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAA4B,EAAE,EAAE;IAC9F,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IAEvB,OAAO,CACL,MAAC,WAAW,IAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAC,IAAI,EAAC,cAAc,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,aAC1J,cAAK,SAAS,EAAC,kBAAkB,YAC/B,sBAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAK,GAChD,EACN,KAAC,WAAW,CAAC,MAAM,cACjB,MAAC,SAAS,eACR,KAAC,MAAM,IAAC,OAAO,EAAC,UAAU,EAAC,OAAO,EAAE,OAAO,YAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAU,EAChG,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,gBAAgB,YAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAU,IAC/F,GACO,IACT,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import { ActionRow, Button, ModalDialog } from '@openedx/paragon';\nimport { useIntl } from '@openedx/frontend-base';\nimport messages from '../messages';\n\ninterface DisableCohortsModalProps {\n isOpen: boolean,\n onClose: () => void,\n onConfirmDisable: () => void,\n}\n\nconst DisableCohortsModal = ({ isOpen, onClose, onConfirmDisable }: DisableCohortsModalProps) => {\n const intl = useIntl();\n\n return (\n <ModalDialog title={intl.formatMessage(messages.disableCohorts)} onClose={onClose} isOpen={isOpen} size=\"sm\" hasCloseButton={false} isOverflowVisible={false}>\n <div className=\"mx-4 mt-4 mb-2.5\">\n <p>{intl.formatMessage(messages.disableMessage)}</p>\n </div>\n <ModalDialog.Footer>\n <ActionRow>\n <Button variant=\"tertiary\" onClick={onClose}>{intl.formatMessage(messages.cancelLabel)}</Button>\n <Button variant=\"primary\" onClick={onConfirmDisable}>{intl.formatMessage(messages.disableLabel)}</Button>\n </ActionRow>\n </ModalDialog.Footer>\n </ModalDialog>\n );\n};\n\nexport default DisableCohortsModal;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getExternalLinkUrl, useIntl } from '@openedx/frontend-base';
|
|
3
|
+
import { Button, Hyperlink } from '@openedx/paragon';
|
|
4
|
+
import messages from '../messages';
|
|
5
|
+
const DisabledCohortsView = ({ onEnableCohorts }) => {
|
|
6
|
+
const intl = useIntl();
|
|
7
|
+
return (_jsxs("div", { className: "d-flex bg-light-200 border border-light-400 p-5 mt-4.5 align-items-center", children: [_jsxs("p", { className: "m-0", children: [intl.formatMessage(messages.noCohortsMessage), " ", _jsx(Hyperlink, { destination: getExternalLinkUrl('https://openedx.atlassian.net/wiki/spaces/ENG/pages/123456789/Cohorts+Feature+Documentation'), showLaunchIcon: false, target: "_blank", children: intl.formatMessage(messages.learnMore) })] }), _jsx(Button, { className: "ml-3 flex-shrink-0", onClick: onEnableCohorts, children: intl.formatMessage(messages.enableCohorts) })] }));
|
|
8
|
+
};
|
|
9
|
+
export default DisabledCohortsView;
|
|
10
|
+
//# sourceMappingURL=DisabledCohortsView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisabledCohortsView.js","sourceRoot":"","sources":["../../../src/cohorts/components/DisabledCohortsView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAMnC,MAAM,mBAAmB,GAAG,CAAC,EAAE,eAAe,EAA4B,EAAE,EAAE;IAC5E,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IAEvB,OAAO,CACL,eAAK,SAAS,EAAC,2EAA2E,aACxF,aAAG,SAAS,EAAC,KAAK,aACf,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAE,KAAC,SAAS,IAAC,WAAW,EAAE,kBAAkB,CAAC,6FAA6F,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAC,QAAQ,YAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAa,IACpR,EACJ,KAAC,MAAM,IAAC,SAAS,EAAC,oBAAoB,EAAC,OAAO,EAAE,eAAe,YAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAU,IAClH,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import { getExternalLinkUrl, useIntl } from '@openedx/frontend-base';\nimport { Button, Hyperlink } from '@openedx/paragon';\nimport messages from '../messages';\n\ninterface DisabledCohortsViewProps {\n onEnableCohorts: () => void,\n}\n\nconst DisabledCohortsView = ({ onEnableCohorts }: DisabledCohortsViewProps) => {\n const intl = useIntl();\n\n return (\n <div className=\"d-flex bg-light-200 border border-light-400 p-5 mt-4.5 align-items-center\">\n <p className=\"m-0\">\n {intl.formatMessage(messages.noCohortsMessage)} <Hyperlink destination={getExternalLinkUrl('https://openedx.atlassian.net/wiki/spaces/ENG/pages/123456789/Cohorts+Feature+Documentation')} showLaunchIcon={false} target=\"_blank\">{intl.formatMessage(messages.learnMore)}</Hyperlink>\n </p>\n <Button className=\"ml-3 flex-shrink-0\" onClick={onEnableCohorts}>{intl.formatMessage(messages.enableCohorts)}</Button>\n </div>\n );\n};\n\nexport default DisabledCohortsView;\n"]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useParams } from 'react-router-dom';
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
import { FormControl, Button, Card, Alert } from '@openedx/paragon';
|
|
6
|
+
import { CheckCircle, Error, WarningFilled } from '@openedx/paragon/icons';
|
|
7
|
+
import { useCohortContext } from '../../cohorts/components/CohortContext';
|
|
8
|
+
import CohortsForm from '../../cohorts/components/CohortsForm';
|
|
9
|
+
import SelectedCohortInfo from '../../cohorts/components/SelectedCohortInfo';
|
|
10
|
+
import { useCohorts, useCreateCohort } from '../../cohorts/data/apiHook';
|
|
11
|
+
import { assignmentTypes } from '../../cohorts/constants';
|
|
12
|
+
import messages from '../../cohorts/messages';
|
|
13
|
+
import { useAlert } from '../../providers/AlertProvider';
|
|
14
|
+
const alertIcons = {
|
|
15
|
+
success: CheckCircle,
|
|
16
|
+
error: Error,
|
|
17
|
+
warning: WarningFilled,
|
|
18
|
+
};
|
|
19
|
+
const EnabledCohortsView = () => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const intl = useIntl();
|
|
22
|
+
const { courseId = '' } = useParams();
|
|
23
|
+
const { data = [] } = useCohorts(courseId);
|
|
24
|
+
const { mutate: createCohort } = useCreateCohort(courseId);
|
|
25
|
+
const { clearSelectedCohort, selectedCohort, setSelectedCohort } = useCohortContext();
|
|
26
|
+
const [displayAddForm, setDisplayAddForm] = useState(false);
|
|
27
|
+
const { alerts, addAlert, removeAlert, clearAlerts } = useAlert();
|
|
28
|
+
const cohortsList = [{ id: 'null', name: intl.formatMessage(messages.selectCohortPlaceholder) }, ...data];
|
|
29
|
+
// Sync selectedCohort with updated data when useCohorts refetches
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
if (selectedCohort && data.length > 0) {
|
|
33
|
+
const updatedCohort = data.find(cohort => { var _a, _b; return ((_a = cohort.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_b = selectedCohort.id) === null || _b === void 0 ? void 0 : _b.toString()); });
|
|
34
|
+
if (updatedCohort && (updatedCohort.userCount !== selectedCohort.userCount
|
|
35
|
+
|| updatedCohort.name !== selectedCohort.name
|
|
36
|
+
|| updatedCohort.assignmentType !== selectedCohort.assignmentType)) {
|
|
37
|
+
const updatedCohortData = {
|
|
38
|
+
id: updatedCohort.id,
|
|
39
|
+
name: updatedCohort.name,
|
|
40
|
+
assignmentType: (_a = updatedCohort.assignmentType) !== null && _a !== void 0 ? _a : assignmentTypes.automatic,
|
|
41
|
+
groupId: updatedCohort.groupId,
|
|
42
|
+
userPartitionId: updatedCohort.userPartitionId,
|
|
43
|
+
userCount: (_b = updatedCohort.userCount) !== null && _b !== void 0 ? _b : 0,
|
|
44
|
+
};
|
|
45
|
+
setSelectedCohort(updatedCohortData);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, [data, selectedCohort, setSelectedCohort]);
|
|
49
|
+
const handleAddCohort = () => {
|
|
50
|
+
clearSelectedCohort();
|
|
51
|
+
clearAlerts();
|
|
52
|
+
setDisplayAddForm(true);
|
|
53
|
+
};
|
|
54
|
+
const handleSelectCohort = (event) => {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
clearAlerts();
|
|
57
|
+
const selectedValue = event.target.value;
|
|
58
|
+
const selectedCohortFromApi = cohortsList.find(cohort => { var _a; return ((_a = cohort.id) === null || _a === void 0 ? void 0 : _a.toString()) === selectedValue; });
|
|
59
|
+
setDisplayAddForm(false);
|
|
60
|
+
if (selectedCohortFromApi && selectedCohortFromApi.id !== 'null') {
|
|
61
|
+
const cohortFormData = {
|
|
62
|
+
id: selectedCohortFromApi.id,
|
|
63
|
+
name: selectedCohortFromApi.name,
|
|
64
|
+
assignmentType: (_a = selectedCohortFromApi.assignmentType) !== null && _a !== void 0 ? _a : assignmentTypes.automatic,
|
|
65
|
+
groupId: selectedCohortFromApi.groupId,
|
|
66
|
+
userPartitionId: selectedCohortFromApi.userPartitionId,
|
|
67
|
+
userCount: (_b = selectedCohortFromApi.userCount) !== null && _b !== void 0 ? _b : 0,
|
|
68
|
+
};
|
|
69
|
+
setSelectedCohort(cohortFormData);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
clearSelectedCohort();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const handleNewCohort = (newCohort) => {
|
|
76
|
+
createCohort(newCohort, {
|
|
77
|
+
onSuccess: (newCohort) => {
|
|
78
|
+
addAlert({
|
|
79
|
+
type: 'success',
|
|
80
|
+
message: intl.formatMessage(messages.addCohortSuccessMessage, { cohortName: newCohort.name })
|
|
81
|
+
});
|
|
82
|
+
setSelectedCohort(newCohort);
|
|
83
|
+
hideAddForm();
|
|
84
|
+
},
|
|
85
|
+
onError: (error) => {
|
|
86
|
+
console.error(error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const hideAddForm = () => {
|
|
91
|
+
setDisplayAddForm(false);
|
|
92
|
+
};
|
|
93
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "d-flex mt-4.5", children: [_jsx(FormControl, { as: "select", disabled: displayAddForm || cohortsList.length === 1, name: "cohort", placeholder: intl.formatMessage(messages.selectCohortPlaceholder), value: (_b = (_a = selectedCohort === null || selectedCohort === void 0 ? void 0 : selectedCohort.id) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : 'null', onChange: handleSelectCohort, children: cohortsList.map((cohort) => (_jsx("option", { value: cohort.id, children: cohort.name }, cohort.id))) }), _jsxs(Button, { onClick: handleAddCohort, disabled: displayAddForm, children: ["+ ", intl.formatMessage(messages.addCohort)] })] }), alerts.map(alert => (_jsxs(Alert, { className: "mt-3", icon: alertIcons[alert.type], variant: alert.type === 'error' ? 'danger' : alert.type, dismissible: true, onClose: () => removeAlert(alert.id), children: [_jsx("p", { className: "mb-0", children: alert.message }), alert.extraContent] }, alert.id))), displayAddForm && (_jsx(Card, { className: "mt-3 bg-light-200", children: _jsx(CohortsForm, { disableManualAssignment: data.length === 0, onCancel: hideAddForm, onSubmit: handleNewCohort }) })), selectedCohort && _jsx(SelectedCohortInfo, {})] }));
|
|
94
|
+
};
|
|
95
|
+
export default EnabledCohortsView;
|
|
96
|
+
//# sourceMappingURL=EnabledCohortsView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnabledCohortsView.js","sourceRoot":"","sources":["../../../src/cohorts/components/EnabledCohortsView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,kBAAkB,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,MAAM,UAAU,GAAG;IACjB,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,KAA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,MAAM,EAC/C,QAAQ,EAAE,kBAAkB,YAG1B,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC1B,iBAAwB,KAAK,EAAE,MAAM,CAAC,EAAE,YACrC,MAAM,CAAC,IAAI,IADD,MAAM,CAAC,EAAE,CAEb,CACV,CAAC,GAEQ,EACd,MAAC,MAAM,IAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,mBAAK,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAU,IAC3G,EACL,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CACnB,MAAC,KAAK,IAEJ,SAAS,EAAC,MAAM,EAChB,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAC5B,OAAO,EAAE,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EACvD,WAAW,QACX,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,aAEpC,YAAG,SAAS,EAAC,MAAM,YAAE,KAAK,CAAC,OAAO,GAAK,EACtC,KAAK,CAAC,YAAY,KARd,KAAK,CAAC,EAAE,CASP,CACT,CAAC,EACD,cAAc,IAAI,CACjB,KAAC,IAAI,IAAC,SAAS,EAAC,mBAAmB,YACjC,KAAC,WAAW,IAAC,uBAAuB,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,GAAI,GACxG,CACR,EACA,cAAc,IAAI,KAAC,kBAAkB,KAAG,IACxC,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import { useState, useEffect } from 'react';\nimport { useParams } from 'react-router-dom';\nimport { useIntl } from '@openedx/frontend-base';\nimport { FormControl, Button, Card, Alert } from '@openedx/paragon';\nimport { CheckCircle, Error, WarningFilled } from '@openedx/paragon/icons';\nimport { useCohortContext } from '@src/cohorts/components/CohortContext';\nimport CohortsForm from '@src/cohorts/components/CohortsForm';\nimport SelectedCohortInfo from '@src/cohorts/components/SelectedCohortInfo';\nimport { useCohorts, useCreateCohort } from '@src/cohorts/data/apiHook';\nimport { assignmentTypes } from '@src/cohorts/constants';\nimport messages from '@src/cohorts/messages';\nimport { CohortData, BasicCohortData } from '@src/cohorts/types';\nimport { useAlert } from '@src/providers/AlertProvider';\n\nconst alertIcons = {\n success: CheckCircle,\n error: Error,\n warning: WarningFilled,\n};\n\nconst EnabledCohortsView = () => {\n const intl = useIntl();\n const { courseId = '' } = useParams<{ courseId: string }>();\n const { data = [] } = useCohorts(courseId);\n const { mutate: createCohort } = useCreateCohort(courseId);\n const { clearSelectedCohort, selectedCohort, setSelectedCohort } = useCohortContext();\n const [displayAddForm, setDisplayAddForm] = useState(false);\n const { alerts, addAlert, removeAlert, clearAlerts } = useAlert();\n\n const cohortsList = [{ id: 'null', name: intl.formatMessage(messages.selectCohortPlaceholder) }, ...data];\n\n // Sync selectedCohort with updated data when useCohorts refetches\n useEffect(() => {\n if (selectedCohort && data.length > 0) {\n const updatedCohort = data.find(cohort => cohort.id?.toString() === selectedCohort.id?.toString());\n if (updatedCohort && (\n updatedCohort.userCount !== selectedCohort.userCount\n || updatedCohort.name !== selectedCohort.name\n || updatedCohort.assignmentType !== selectedCohort.assignmentType\n )) {\n const updatedCohortData: CohortData = {\n id: updatedCohort.id,\n name: updatedCohort.name,\n assignmentType: updatedCohort.assignmentType ?? assignmentTypes.automatic,\n groupId: updatedCohort.groupId,\n userPartitionId: updatedCohort.userPartitionId,\n userCount: updatedCohort.userCount ?? 0,\n };\n setSelectedCohort(updatedCohortData);\n }\n }\n }, [data, selectedCohort, setSelectedCohort]);\n\n const handleAddCohort = () => {\n clearSelectedCohort();\n clearAlerts();\n setDisplayAddForm(true);\n };\n\n const handleSelectCohort = (event: React.ChangeEvent<HTMLSelectElement>) => {\n clearAlerts();\n const selectedValue = event.target.value;\n const selectedCohortFromApi = cohortsList.find(cohort => cohort.id?.toString() === selectedValue);\n setDisplayAddForm(false);\n\n if (selectedCohortFromApi && selectedCohortFromApi.id !== 'null') {\n const cohortFormData: CohortData = {\n id: selectedCohortFromApi.id,\n name: selectedCohortFromApi.name,\n assignmentType: selectedCohortFromApi.assignmentType ?? assignmentTypes.automatic,\n groupId: selectedCohortFromApi.groupId,\n userPartitionId: selectedCohortFromApi.userPartitionId,\n userCount: selectedCohortFromApi.userCount ?? 0,\n };\n setSelectedCohort(cohortFormData);\n } else {\n clearSelectedCohort();\n }\n };\n\n const handleNewCohort = (newCohort: BasicCohortData) => {\n createCohort(newCohort, {\n onSuccess: (newCohort: CohortData) => {\n addAlert({\n type: 'success',\n message: intl.formatMessage(messages.addCohortSuccessMessage, { cohortName: newCohort.name })\n });\n setSelectedCohort(newCohort);\n hideAddForm();\n },\n onError: (error) => {\n console.error(error);\n }\n });\n };\n\n const hideAddForm = () => {\n setDisplayAddForm(false);\n };\n\n return (\n <>\n <div className=\"d-flex mt-4.5\">\n <FormControl\n as=\"select\"\n disabled={displayAddForm || cohortsList.length === 1}\n name=\"cohort\"\n placeholder={intl.formatMessage(messages.selectCohortPlaceholder)}\n value={selectedCohort?.id?.toString() ?? 'null'}\n onChange={handleSelectCohort}\n >\n {\n cohortsList.map((cohort) => (\n <option key={cohort.id} value={cohort.id}>\n {cohort.name}\n </option>\n ))\n }\n </FormControl>\n <Button onClick={handleAddCohort} disabled={displayAddForm}>+ {intl.formatMessage(messages.addCohort)}</Button>\n </div>\n {alerts.map(alert => (\n <Alert\n key={alert.id}\n className=\"mt-3\"\n icon={alertIcons[alert.type]}\n variant={alert.type === 'error' ? 'danger' : alert.type}\n dismissible\n onClose={() => removeAlert(alert.id)}\n >\n <p className=\"mb-0\">{alert.message}</p>\n {alert.extraContent}\n </Alert>\n ))}\n {displayAddForm && (\n <Card className=\"mt-3 bg-light-200\">\n <CohortsForm disableManualAssignment={data.length === 0} onCancel={hideAddForm} onSubmit={handleNewCohort} />\n </Card>\n )}\n {selectedCohort && <SelectedCohortInfo />}\n </>\n );\n};\n\nexport default EnabledCohortsView;\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useParams } from 'react-router-dom';
|
|
4
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
import { Button, FormControl } from '@openedx/paragon';
|
|
6
|
+
import { useCohortContext } from '../../cohorts/components/CohortContext';
|
|
7
|
+
import { useAddLearnersToCohort } from '../../cohorts/data/apiHook';
|
|
8
|
+
import messages from '../../cohorts/messages';
|
|
9
|
+
import { useAlert } from '../../providers/AlertProvider';
|
|
10
|
+
const ManageLearners = () => {
|
|
11
|
+
const { courseId = '' } = useParams();
|
|
12
|
+
const intl = useIntl();
|
|
13
|
+
const { selectedCohort } = useCohortContext();
|
|
14
|
+
const { mutate: addLearnersToCohort } = useAddLearnersToCohort(courseId, (selectedCohort === null || selectedCohort === void 0 ? void 0 : selectedCohort.id) ? Number(selectedCohort.id) : 0);
|
|
15
|
+
const [users, setUsers] = useState('');
|
|
16
|
+
const { addAlert, clearAlerts } = useAlert();
|
|
17
|
+
const handleAlertMessages = (response) => {
|
|
18
|
+
const { added, changed, preassigned, present, unknown } = response;
|
|
19
|
+
if (preassigned.length > 0) {
|
|
20
|
+
addAlert({
|
|
21
|
+
type: 'warning',
|
|
22
|
+
message: intl.formatMessage(messages.addLearnersWarningMessage, {
|
|
23
|
+
countLearners: preassigned.length,
|
|
24
|
+
}),
|
|
25
|
+
extraContent: (preassigned.map((learner) => (_jsxs("p", { className: "mb-0", children: ["\u2022 ", learner] }, learner))))
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (present.length > 0 || added.length > 0 || changed.length > 0) {
|
|
29
|
+
addAlert({
|
|
30
|
+
type: 'success',
|
|
31
|
+
message: intl.formatMessage(messages.addLearnersSuccessMessage, {
|
|
32
|
+
countLearners: added.length + changed.length,
|
|
33
|
+
}),
|
|
34
|
+
extraContent: (present.length > 0 && (present.map((learner) => (_jsxs("p", { className: "mb-0", children: ["\u2022 ", intl.formatMessage(messages.existingLearner, { learner })] }, learner)))))
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (unknown.length > 0) {
|
|
38
|
+
addAlert({
|
|
39
|
+
type: 'error',
|
|
40
|
+
message: intl.formatMessage(messages.addLearnersErrorMessage, {
|
|
41
|
+
countLearners: unknown.length,
|
|
42
|
+
}),
|
|
43
|
+
extraContent: (unknown.map((learner) => (_jsxs("p", { className: "mb-0", children: ["\u2022 ", intl.formatMessage(messages.unknownLearner, { learner })] }, learner))))
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const handleAddLearners = () => {
|
|
48
|
+
clearAlerts();
|
|
49
|
+
const usersArray = users.split(/[\n,]+/).map(u => u.trim()).filter(Boolean);
|
|
50
|
+
addLearnersToCohort(usersArray, {
|
|
51
|
+
onSuccess: handleAlertMessages,
|
|
52
|
+
onError: (error) => {
|
|
53
|
+
addAlert({
|
|
54
|
+
type: 'error',
|
|
55
|
+
message: intl.formatMessage(messages.addLearnersErrorMessage)
|
|
56
|
+
});
|
|
57
|
+
console.error(error);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
return (_jsxs("div", { className: "mx-4 my-3.5", children: [_jsx("h3", { className: "text-primary-700", children: intl.formatMessage(messages.addLearnersTitle) }), _jsx("p", { className: "x-small mb-2.5", children: intl.formatMessage(messages.addLearnersSubtitle) }), _jsx("p", { className: "mb-2 text-primary-500", children: intl.formatMessage(messages.addLearnersInstructions) }), _jsx(FormControl, { as: "textarea", className: "mb-2", rows: 4, placeholder: intl.formatMessage(messages.learnersExample), onChange: (e) => setUsers(e.target.value) }), _jsx("p", { className: "x-small mb-2.5", children: intl.formatMessage(messages.addLearnersFootnote) }), _jsxs(Button, { variant: "primary", className: "mt-2", onClick: handleAddLearners, children: ["+ ", intl.formatMessage(messages.addLearnersLabel)] })] }));
|
|
62
|
+
};
|
|
63
|
+
export default ManageLearners;
|
|
64
|
+
//# sourceMappingURL=ManageLearners.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManageLearners.js","sourceRoot":"","sources":["../../../src/cohorts/components/ManageLearners.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAUxD,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,SAAS,EAAE,CAAC;IACtC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,EAAE,cAAc,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAC9C,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,sBAAsB,CAAC,QAAQ,EAAE,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,EAAE,EAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC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C,gBAAgB,YAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC,GAAK,EACpF,YAAG,SAAS,EAAC,uBAAuB,YAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAK,EAC/F,KAAC,WAAW,IACV,EAAE,EAAC,UAAU,EACb,SAAS,EAAC,MAAM,EAChB,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,EACzD,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GACzC,EACF,YAAG,SAAS,EAAC,gBAAgB,YAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC,GAAK,EACpF,MAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,SAAS,EAAC,MAAM,EAAC,OAAO,EAAE,iBAAiB,mBAAK,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAU,IAC7H,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useState } from 'react';\nimport { useParams } from 'react-router-dom';\nimport { useIntl } from '@openedx/frontend-base';\nimport { Button, FormControl } from '@openedx/paragon';\nimport { useCohortContext } from '@src/cohorts/components/CohortContext';\nimport { useAddLearnersToCohort } from '@src/cohorts/data/apiHook';\nimport messages from '@src/cohorts/messages';\nimport { useAlert } from '@src/providers/AlertProvider';\n\ninterface AddLearnersResponse {\n added: string[],\n changed: string[],\n preassigned: string[],\n present: string[],\n unknown: string[],\n}\n\nconst ManageLearners = () => {\n const { courseId = '' } = useParams();\n const intl = useIntl();\n const { selectedCohort } = useCohortContext();\n const { mutate: addLearnersToCohort } = useAddLearnersToCohort(courseId, selectedCohort?.id ? Number(selectedCohort.id) : 0);\n const [users, setUsers] = useState('');\n const { addAlert, clearAlerts } = useAlert();\n\n const handleAlertMessages = (response: AddLearnersResponse) => {\n const { added, changed, preassigned, present, unknown } = response;\n if (preassigned.length > 0) {\n addAlert({\n type: 'warning',\n message: intl.formatMessage(messages.addLearnersWarningMessage, {\n countLearners: preassigned.length,\n }),\n extraContent: (\n preassigned.map((learner: string) => (\n <p key={learner} className=\"mb-0\">• {learner}</p>\n ))\n )\n });\n }\n if (present.length > 0 || added.length > 0 || changed.length > 0) {\n addAlert({\n type: 'success',\n message: intl.formatMessage(messages.addLearnersSuccessMessage, {\n countLearners: added.length + changed.length,\n }),\n extraContent: (\n present.length > 0 && (\n present.map((learner: string) => (\n <p key={learner} className=\"mb-0\">• {intl.formatMessage(messages.existingLearner, { learner })}</p>\n ))\n ))\n });\n }\n if (unknown.length > 0) {\n addAlert({\n type: 'error',\n message: intl.formatMessage(messages.addLearnersErrorMessage, {\n countLearners: unknown.length,\n }),\n extraContent: (\n unknown.map((learner: string) => (\n <p key={learner} className=\"mb-0\">• {intl.formatMessage(messages.unknownLearner, { learner })}</p>\n ))\n )\n });\n }\n };\n\n const handleAddLearners = () => {\n clearAlerts();\n const usersArray = users.split(/[\\n,]+/).map(u => u.trim()).filter(Boolean);\n addLearnersToCohort(usersArray, {\n onSuccess: handleAlertMessages,\n onError: (error) => {\n addAlert({\n type: 'error',\n message: intl.formatMessage(messages.addLearnersErrorMessage)\n });\n console.error(error);\n }\n });\n };\n\n return (\n <div className=\"mx-4 my-3.5\">\n <h3 className=\"text-primary-700\">{intl.formatMessage(messages.addLearnersTitle)}</h3>\n <p className=\"x-small mb-2.5\">{intl.formatMessage(messages.addLearnersSubtitle)}</p>\n <p className=\"mb-2 text-primary-500\">{intl.formatMessage(messages.addLearnersInstructions)}</p>\n <FormControl\n as=\"textarea\"\n className=\"mb-2\"\n rows={4}\n placeholder={intl.formatMessage(messages.learnersExample)}\n onChange={(e) => setUsers(e.target.value)}\n />\n <p className=\"x-small mb-2.5\">{intl.formatMessage(messages.addLearnersFootnote)}</p>\n <Button variant=\"primary\" className=\"mt-2\" onClick={handleAddLearners}>+ {intl.formatMessage(messages.addLearnersLabel)}</Button>\n </div>\n );\n};\n\nexport default ManageLearners;\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { getExternalLinkUrl, useIntl } from '@openedx/frontend-base';
|
|
3
|
+
import { useParams } from 'react-router-dom';
|
|
4
|
+
import { Collapsible, Hyperlink } from '@openedx/paragon';
|
|
5
|
+
import CSVComponent from '../../components/CSVComponent';
|
|
6
|
+
import dataDownloadsMessages from '../../dataDownloads/messages';
|
|
7
|
+
import { useAlert } from '../../providers/AlertProvider';
|
|
8
|
+
import CohortCard from './CohortCard';
|
|
9
|
+
import messages from '../messages';
|
|
10
|
+
import { useAddLearnersToCohortsBulk } from '../data/apiHook';
|
|
11
|
+
const SelectedCohortInfo = () => {
|
|
12
|
+
const intl = useIntl();
|
|
13
|
+
const { courseId = '' } = useParams();
|
|
14
|
+
const { mutate: addLearnersToCohortsBulk } = useAddLearnersToCohortsBulk(courseId);
|
|
15
|
+
const { showToast } = useAlert();
|
|
16
|
+
const handleProcessUpload = ({ fileData, handleError }) => {
|
|
17
|
+
// Create new FormData with the correct field name for cohorts API
|
|
18
|
+
const correctedFormData = new FormData();
|
|
19
|
+
// Get the first file from the original FormData (Dropzone might use 'file', 'files[0]', etc.)
|
|
20
|
+
const file = fileData.get('file') || fileData.get('files[0]') || Array.from(fileData.values()).find(value => value instanceof File);
|
|
21
|
+
if (file instanceof File) {
|
|
22
|
+
correctedFormData.append('uploaded-file', file);
|
|
23
|
+
addLearnersToCohortsBulk(correctedFormData, {
|
|
24
|
+
onSuccess: () => {
|
|
25
|
+
showToast(intl.formatMessage(messages.uploadSuccessMessage, { fileName: file.name }));
|
|
26
|
+
},
|
|
27
|
+
onError: (error) => {
|
|
28
|
+
if (handleError) {
|
|
29
|
+
handleError(error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (handleError) {
|
|
36
|
+
handleError(new Error(intl.formatMessage(messages.noFileFoundMessage)));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return (_jsxs(_Fragment, { children: [_jsx(CohortCard, {}), _jsx(Collapsible, { className: "collapsible-csv mt-3 w-50", styling: "basic", title: _jsx("p", { className: "text-info-500 mb-0", children: intl.formatMessage(messages.downloadCSVCaption) }), children: _jsx(CSVComponent, { templateLink: getExternalLinkUrl('https://docs.openedx.org/en/latest/educators/how-tos/advanced_features/manage_cohorts.html#assign-learners-to-cohorts-by-uploading-a-csv-file'), onProcessUpload: handleProcessUpload }) }), _jsxs("p", { className: "mt-3", children: [intl.formatMessage(messages.cohortDisclaimer), " ", _jsx(Hyperlink, { className: "text-info-500 text-decoration-none", destination: `/instructor/${courseId}/data_downloads`, showLaunchIcon: false, children: intl.formatMessage(dataDownloadsMessages.pageTitle) }), " ", intl.formatMessage(messages.page)] })] }));
|
|
41
|
+
};
|
|
42
|
+
export default SelectedCohortInfo;
|
|
43
|
+
//# sourceMappingURL=SelectedCohortInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectedCohortInfo.js","sourceRoot":"","sources":["../../../src/cohorts/components/SelectedCohortInfo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,YAAY,MAAM,8BAA8B,CAAC;AACxD,OAAO,qBAAqB,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,UAAU,MAAM,cAAc,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BACH,CAAC;aACF,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,WAAW,EAAE,CAAC;gBAChB,WAAW,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,8BACE,KAAC,UAAU,KAAG,EACd,KAAC,WAAW,IAAC,SAAS,EAAC,2BAA2B,EAAC,OAAO,EAAC,OAAO,EAAC,KAAK,EAAE,YAAG,SAAS,EAAC,oBAAoB,YAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,kBAAkB,CAAC,GAAK,YAC/J,KAAC,YAAY,IAAC,YAAY,EAAE,kBAAkB,CAAC,+IAA+I,CAAC,EAAE,eAAe,EAAE,mBAAmB,GAAI,GAC7N,EACd,aAAG,SAAS,EAAC,MAAM,aAChB,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAE,KAAC,SAAS,IAAC,SAAS,EAAC,oCAAoC,EAAC,WAAW,EAAE,eAAe,QAAQ,iBAAiB,EAAE,cAAc,EAAE,KAAK,YAAG,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,SAAS,CAAC,GAAa,OAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,IAC1R,IACH,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import { getExternalLinkUrl, useIntl } from '@openedx/frontend-base';\nimport { useParams } from 'react-router-dom';\nimport { Collapsible, Hyperlink } from '@openedx/paragon';\nimport CSVComponent from '@src/components/CSVComponent';\nimport dataDownloadsMessages from '@src/dataDownloads/messages';\nimport { useAlert } from '@src/providers/AlertProvider';\nimport CohortCard from './CohortCard';\nimport messages from '../messages';\nimport { useAddLearnersToCohortsBulk } from '../data/apiHook';\n\nconst SelectedCohortInfo = () => {\n const intl = useIntl();\n const { courseId = '' } = useParams<{ courseId: string }>();\n const { mutate: addLearnersToCohortsBulk } = useAddLearnersToCohortsBulk(courseId);\n const { showToast } = useAlert();\n\n const handleProcessUpload = ({ fileData, handleError }: { fileData: FormData, requestConfig?: RequestInit, handleError?: (error: Error) => void }) => {\n // Create new FormData with the correct field name for cohorts API\n const correctedFormData = new FormData();\n\n // Get the first file from the original FormData (Dropzone might use 'file', 'files[0]', etc.)\n const file = fileData.get('file') || fileData.get('files[0]') || Array.from(fileData.values()).find(value => value instanceof File);\n\n if (file instanceof File) {\n correctedFormData.append('uploaded-file', file);\n addLearnersToCohortsBulk(correctedFormData, {\n onSuccess: () => {\n showToast(intl.formatMessage(messages.uploadSuccessMessage, { fileName: file.name }));\n },\n onError: (error) => {\n if (handleError) {\n handleError(error);\n }\n }\n });\n } else {\n if (handleError) {\n handleError(new Error(intl.formatMessage(messages.noFileFoundMessage)));\n }\n }\n };\n\n return (\n <>\n <CohortCard />\n <Collapsible className=\"collapsible-csv mt-3 w-50\" styling=\"basic\" title={<p className=\"text-info-500 mb-0\">{intl.formatMessage(messages.downloadCSVCaption)}</p>}>\n <CSVComponent templateLink={getExternalLinkUrl('https://docs.openedx.org/en/latest/educators/how-tos/advanced_features/manage_cohorts.html#assign-learners-to-cohorts-by-uploading-a-csv-file')} onProcessUpload={handleProcessUpload} />\n </Collapsible>\n <p className=\"mt-3\">\n {intl.formatMessage(messages.cohortDisclaimer)} <Hyperlink className=\"text-info-500 text-decoration-none\" destination={`/instructor/${courseId}/data_downloads`} showLaunchIcon={false}>{intl.formatMessage(dataDownloadsMessages.pageTitle)}</Hyperlink> {intl.formatMessage(messages.page)}\n </p>\n </>\n );\n};\n\nexport default SelectedCohortInfo;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/cohorts/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,QAAQ;IACnB,MAAM,EAAE,QAAQ;CACjB,CAAC","sourcesContent":["export const assignmentTypes = {\n automatic: 'random',\n manual: 'manual'\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CohortData, BasicCohortData } from '../../cohorts/types';
|
|
2
|
+
export declare const getCohortStatus: (courseId: string) => Promise<any>;
|
|
3
|
+
export declare const getCohorts: (courseId: string) => Promise<any>;
|
|
4
|
+
export declare const toggleCohorts: (courseId: string, isCohorted: boolean) => Promise<any>;
|
|
5
|
+
export declare const createCohort: (courseId: string, cohortDetails: BasicCohortData) => Promise<any>;
|
|
6
|
+
export declare const getContentGroups: (courseId: string) => Promise<any>;
|
|
7
|
+
export declare const patchCohort: (courseId: string, cohortId: number, cohortDetails: CohortData) => Promise<any>;
|
|
8
|
+
export declare const addLearnersToCohort: (courseId: string, cohortId: number, users: string[]) => Promise<any>;
|
|
9
|
+
export declare const addLearnersToCohortsBulk: (courseId: string, uploadedFile: FormData) => Promise<any>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { camelCaseObject, getAuthenticatedHttpClient, snakeCaseObject } from '@openedx/frontend-base';
|
|
11
|
+
import { getApiBaseUrl } from '../../data/api';
|
|
12
|
+
export const getCohortStatus = (courseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
const url = `${getApiBaseUrl()}/api/cohorts/v1/settings/${courseId}`;
|
|
14
|
+
const { data } = yield getAuthenticatedHttpClient().get(url);
|
|
15
|
+
return camelCaseObject(data);
|
|
16
|
+
});
|
|
17
|
+
export const getCohorts = (courseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/cohorts/`;
|
|
19
|
+
const { data } = yield getAuthenticatedHttpClient().get(url, { params: { page_size: 100 } });
|
|
20
|
+
return camelCaseObject(data);
|
|
21
|
+
});
|
|
22
|
+
export const toggleCohorts = (courseId, isCohorted) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const url = `${getApiBaseUrl()}/api/cohorts/v1/settings/${courseId}`;
|
|
24
|
+
const { data } = yield getAuthenticatedHttpClient().put(url, { is_cohorted: isCohorted });
|
|
25
|
+
return camelCaseObject(data);
|
|
26
|
+
});
|
|
27
|
+
export const createCohort = (courseId, cohortDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/cohorts/`;
|
|
29
|
+
const cohortDetailsSnakeCase = snakeCaseObject(cohortDetails);
|
|
30
|
+
const { data } = yield getAuthenticatedHttpClient().post(url, cohortDetailsSnakeCase);
|
|
31
|
+
return camelCaseObject(data);
|
|
32
|
+
});
|
|
33
|
+
export const getContentGroups = (courseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const url = `${getApiBaseUrl()}/api/cohorts/v2/courses/${courseId}/group_configurations`;
|
|
35
|
+
const { data } = yield getAuthenticatedHttpClient().get(url);
|
|
36
|
+
return camelCaseObject(data);
|
|
37
|
+
});
|
|
38
|
+
export const patchCohort = (courseId, cohortId, cohortDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/cohorts/${cohortId}`;
|
|
40
|
+
const cohortDetailsSnakeCase = snakeCaseObject(cohortDetails);
|
|
41
|
+
const { data } = yield getAuthenticatedHttpClient().patch(url, cohortDetailsSnakeCase);
|
|
42
|
+
return camelCaseObject(data);
|
|
43
|
+
});
|
|
44
|
+
export const addLearnersToCohort = (courseId, cohortId, users) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/cohorts/${cohortId}/users/`;
|
|
46
|
+
const { data } = yield getAuthenticatedHttpClient().post(url, { users });
|
|
47
|
+
return camelCaseObject(data);
|
|
48
|
+
});
|
|
49
|
+
export const addLearnersToCohortsBulk = (courseId, uploadedFile) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/users`;
|
|
51
|
+
const { data } = yield getAuthenticatedHttpClient().post(url, uploadedFile);
|
|
52
|
+
return camelCaseObject(data);
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/cohorts/data/api.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAO,QAAgB,EAAE,EAAE;IACxD,MAAM,GAAG,GAAG,GAAG,aAAa,EAAE,4BAA4B,QAAQ,EAAE,CAAC;IACrE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,0BAA0B,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7D,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAA,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAO,QAAgB,EAAE,EAAE;IACnD,MAAM,GA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'@src/data/api';\nimport { CohortData, BasicCohortData } from '@src/cohorts/types';\n\nexport const getCohortStatus = async (courseId: string) => {\n const url = `${getApiBaseUrl()}/api/cohorts/v1/settings/${courseId}`;\n const { data } = await getAuthenticatedHttpClient().get(url);\n return camelCaseObject(data);\n};\n\nexport const getCohorts = async (courseId: string) => {\n const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/cohorts/`;\n const { data } = await getAuthenticatedHttpClient().get(url, { params: { page_size: 100 } });\n return camelCaseObject(data);\n};\n\nexport const toggleCohorts = async (courseId: string, isCohorted: boolean) => {\n const url = `${getApiBaseUrl()}/api/cohorts/v1/settings/${courseId}`;\n const { data } = await getAuthenticatedHttpClient().put(url, { is_cohorted: isCohorted });\n return camelCaseObject(data);\n};\n\nexport const createCohort = async (courseId: string, cohortDetails: BasicCohortData) => {\n const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/cohorts/`;\n const cohortDetailsSnakeCase = snakeCaseObject(cohortDetails);\n const { data } = await getAuthenticatedHttpClient().post(url, cohortDetailsSnakeCase);\n return camelCaseObject(data);\n};\n\nexport const getContentGroups = async (courseId: string) => {\n const url = `${getApiBaseUrl()}/api/cohorts/v2/courses/${courseId}/group_configurations`;\n const { data } = await getAuthenticatedHttpClient().get(url);\n return camelCaseObject(data);\n};\n\nexport const patchCohort = async (courseId: string, cohortId: number, cohortDetails: CohortData) => {\n const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/cohorts/${cohortId}`;\n const cohortDetailsSnakeCase = snakeCaseObject(cohortDetails);\n const { data } = await getAuthenticatedHttpClient().patch(url, cohortDetailsSnakeCase);\n return camelCaseObject(data);\n};\n\nexport const addLearnersToCohort = async (courseId: string, cohortId: number, users: string[]) => {\n const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/cohorts/${cohortId}/users/`;\n const { data } = await getAuthenticatedHttpClient().post(url, { users });\n return camelCaseObject(data);\n};\n\nexport const addLearnersToCohortsBulk = async (courseId: string, uploadedFile: FormData) => {\n const url = `${getApiBaseUrl()}/api/cohorts/v1/courses/${courseId}/users`;\n const { data } = await getAuthenticatedHttpClient().post(url, uploadedFile);\n return camelCaseObject(data);\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CohortData, BasicCohortData } from '../../cohorts/types';
|
|
2
|
+
export declare const useCohortStatus: (courseId: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
3
|
+
export declare const useCohorts: (courseId: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
4
|
+
export declare const useToggleCohorts: (courseId: string) => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
5
|
+
isCohorted: boolean;
|
|
6
|
+
}, unknown>;
|
|
7
|
+
export declare const useCreateCohort: (courseId: string) => import("@tanstack/react-query").UseMutationResult<any, Error, BasicCohortData, unknown>;
|
|
8
|
+
export declare const useContentGroupsData: (courseId: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
9
|
+
export declare const usePatchCohort: (courseId: string) => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
10
|
+
cohortId: number;
|
|
11
|
+
cohortInfo: CohortData;
|
|
12
|
+
}, unknown>;
|
|
13
|
+
export declare const useAddLearnersToCohort: (courseId: string, cohortId: number) => import("@tanstack/react-query").UseMutationResult<any, Error, string[], unknown>;
|
|
14
|
+
export declare const useAddLearnersToCohortsBulk: (courseId: string) => import("@tanstack/react-query").UseMutationResult<any, Error, FormData, unknown>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { getCohorts, getCohortStatus, getContentGroups, toggleCohorts, createCohort, patchCohort, addLearnersToCohort, addLearnersToCohortsBulk } from '../../cohorts/data/api';
|
|
3
|
+
import { cohortsQueryKeys } from '../../cohorts/data/queryKeys';
|
|
4
|
+
export const useCohortStatus = (courseId) => (useQuery({
|
|
5
|
+
queryKey: cohortsQueryKeys.enabled(courseId),
|
|
6
|
+
queryFn: () => getCohortStatus(courseId),
|
|
7
|
+
enabled: !!courseId,
|
|
8
|
+
}));
|
|
9
|
+
export const useCohorts = (courseId) => (useQuery({
|
|
10
|
+
queryKey: cohortsQueryKeys.list(courseId),
|
|
11
|
+
queryFn: () => getCohorts(courseId),
|
|
12
|
+
enabled: !!courseId,
|
|
13
|
+
}));
|
|
14
|
+
export const useToggleCohorts = (courseId) => {
|
|
15
|
+
const queryClient = useQueryClient();
|
|
16
|
+
return (useMutation({
|
|
17
|
+
mutationFn: ({ isCohorted }) => toggleCohorts(courseId, isCohorted),
|
|
18
|
+
onSuccess: () => {
|
|
19
|
+
queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.enabled(courseId) });
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
export const useCreateCohort = (courseId) => {
|
|
24
|
+
const queryClient = useQueryClient();
|
|
25
|
+
return useMutation({
|
|
26
|
+
mutationFn: (cohortInfo) => createCohort(courseId, cohortInfo),
|
|
27
|
+
onSuccess: () => {
|
|
28
|
+
queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.list(courseId) });
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export const useContentGroupsData = (courseId) => (useQuery({
|
|
33
|
+
queryKey: cohortsQueryKeys.contentGroups(courseId),
|
|
34
|
+
queryFn: () => getContentGroups(courseId),
|
|
35
|
+
enabled: !!courseId,
|
|
36
|
+
}));
|
|
37
|
+
export const usePatchCohort = (courseId) => {
|
|
38
|
+
const queryClient = useQueryClient();
|
|
39
|
+
return useMutation({
|
|
40
|
+
mutationFn: ({ cohortId, cohortInfo }) => patchCohort(courseId, cohortId, cohortInfo),
|
|
41
|
+
onSuccess: () => {
|
|
42
|
+
queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.byCourse(courseId) });
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export const useAddLearnersToCohort = (courseId, cohortId) => {
|
|
47
|
+
const queryClient = useQueryClient();
|
|
48
|
+
return useMutation({
|
|
49
|
+
mutationFn: (users) => addLearnersToCohort(courseId, cohortId, users),
|
|
50
|
+
onSuccess: () => {
|
|
51
|
+
queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.list(courseId) });
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export const useAddLearnersToCohortsBulk = (courseId) => {
|
|
56
|
+
const queryClient = useQueryClient();
|
|
57
|
+
return useMutation({
|
|
58
|
+
mutationFn: (uploadedFile) => addLearnersToCohortsBulk(courseId, uploadedFile),
|
|
59
|
+
onSuccess: () => {
|
|
60
|
+
queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.list(courseId) });
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=apiHook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiHook.js","sourceRoot":"","sources":["../../../src/cohorts/data/apiHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAC/K,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CACnD,QAAQ,CAAC;IACP,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC;IACxC,OAAO,EAAE,CAAC,CAAC,QAAQ;CACpB,CAAC,CACH,CAAC;AAEF,MAAM,CA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,EAAE;YACd,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC/E,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { getCohorts, getCohortStatus, getContentGroups, toggleCohorts, createCohort, patchCohort, addLearnersToCohort, addLearnersToCohortsBulk } from '@src/cohorts/data/api';\nimport { cohortsQueryKeys } from '@src/cohorts/data/queryKeys';\nimport { CohortData, BasicCohortData } from '@src/cohorts/types';\n\nexport const useCohortStatus = (courseId: string) => (\n useQuery({\n queryKey: cohortsQueryKeys.enabled(courseId),\n queryFn: () => getCohortStatus(courseId),\n enabled: !!courseId,\n })\n);\n\nexport const useCohorts = (courseId: string) => (\n useQuery({\n queryKey: cohortsQueryKeys.list(courseId),\n queryFn: () => getCohorts(courseId),\n enabled: !!courseId,\n })\n);\n\nexport const useToggleCohorts = (courseId: string) => {\n const queryClient = useQueryClient();\n return (useMutation({\n mutationFn: ({ isCohorted }: { isCohorted: boolean }) => toggleCohorts(courseId, isCohorted),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.enabled(courseId) });\n },\n }));\n};\n\nexport const useCreateCohort = (courseId: string) => {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: (cohortInfo: BasicCohortData) => createCohort(courseId, cohortInfo),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.list(courseId) });\n },\n });\n};\n\nexport const useContentGroupsData = (courseId: string) => (\n useQuery({\n queryKey: cohortsQueryKeys.contentGroups(courseId),\n queryFn: () => getContentGroups(courseId),\n enabled: !!courseId,\n })\n);\n\nexport const usePatchCohort = (courseId: string) => {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ cohortId, cohortInfo }: { cohortId: number, cohortInfo: CohortData }) =>\n patchCohort(courseId, cohortId, cohortInfo),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.byCourse(courseId) });\n },\n });\n};\n\nexport const useAddLearnersToCohort = (courseId: string, cohortId: number) => {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: (users: string[]) => addLearnersToCohort(courseId, cohortId, users),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.list(courseId) });\n },\n });\n};\n\nexport const useAddLearnersToCohortsBulk = (courseId: string) => {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: (uploadedFile: FormData) => addLearnersToCohortsBulk(courseId, uploadedFile),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: cohortsQueryKeys.list(courseId) });\n },\n });\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const cohortsQueryKeys: {
|
|
2
|
+
all: readonly ["org.openedx.frontend.app.instructor", "cohorts"];
|
|
3
|
+
byCourse: (courseId: string) => readonly ["org.openedx.frontend.app.instructor", "cohorts", "byCourse", string];
|
|
4
|
+
list: (courseId: string) => readonly ["org.openedx.frontend.app.instructor", "cohorts", "byCourse", string, string, "list"];
|
|
5
|
+
enabled: (courseId: string) => readonly ["cohortsEnabled", string];
|
|
6
|
+
contentGroups: (courseId: string) => readonly ["org.openedx.frontend.app.instructor", "cohorts", "byCourse", string, "contentGroups"];
|
|
7
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { appId } from '../../constants';
|
|
2
|
+
export const cohortsQueryKeys = {
|
|
3
|
+
all: [appId, 'cohorts'],
|
|
4
|
+
byCourse: (courseId) => [...cohortsQueryKeys.all, 'byCourse', courseId],
|
|
5
|
+
list: (courseId) => [...cohortsQueryKeys.byCourse(courseId), courseId, 'list'],
|
|
6
|
+
enabled: (courseId) => ['cohortsEnabled', courseId],
|
|
7
|
+
contentGroups: (courseId) => [...cohortsQueryKeys.byCourse(courseId), 'contentGroups'],
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=queryKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryKeys.js","sourceRoot":"","sources":["../../../src/cohorts/data/queryKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,GAAG,EAAE,CAAC,KAAK,EAAE,SAAS,CAAU;IAChC,QAAQ,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAU;IACxF,IAAI,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC,GAAG,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAU;IAC/F,OAAO,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC,gBAAgB,EAAE,QAAQ,CAAU;IACpE,aAAa,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC,GAAG,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAU;CACxG,CAAC","sourcesContent":["import { appId } from '@src/constants';\n\nexport const cohortsQueryKeys = {\n all: [appId, 'cohorts'] as const,\n byCourse: (courseId: string) => [...cohortsQueryKeys.all, 'byCourse', courseId] as const,\n list: (courseId: string) => [...cohortsQueryKeys.byCourse(courseId), courseId, 'list'] as const,\n enabled: (courseId: string) => ['cohortsEnabled', courseId] as const,\n contentGroups: (courseId: string) => [...cohortsQueryKeys.byCourse(courseId), 'contentGroups'] as const,\n};\n"]}
|