-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03763a7
commit 2f5733d
Showing
21 changed files
with
158 additions
and
140 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/common/icons/DefaultCheckBoxOutlineBlank/DefaultCheckBoxOutlineBlank.tsx
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,3 @@ | ||
import DefaultCheckBoxOutlineBlank from '@mui/icons-material/CheckBoxOutlineBlank' | ||
|
||
export { DefaultCheckBoxOutlineBlank as CheckBoxOutlineBlank } |
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
68 changes: 68 additions & 0 deletions
68
src/components/CreateTopic/Table/CreateRemoteTopicsTable.tsx
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,68 @@ | ||
import { ReactNode, memo, useCallback } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { Checkbox, FormControlLabel, FormGroup, Grid, Paper, Typography } from '@common/components' | ||
import { SkeletonList } from '@components' | ||
import { RemoteTopic } from '@core' | ||
|
||
type TableTopicProps = { | ||
onTopicChange: (selectedTopics: RemoteTopic[]) => void | ||
selectedTopicsModal: RemoteTopic[] | ||
remoteTopics: RemoteTopic[] | ||
children?: ReactNode | ||
} | ||
|
||
const CreateRemoteTopicsTable = memo( | ||
({ onTopicChange, selectedTopicsModal, remoteTopics, children }: TableTopicProps) => { | ||
const { t } = useTranslation() | ||
const handleTopicChange = useCallback( | ||
(topic: RemoteTopic, checked: boolean) => { | ||
const updatedTopics = checked | ||
? [...selectedTopicsModal, topic] | ||
: selectedTopicsModal.filter((t) => t.topic_lms_id !== topic.topic_lms_id) | ||
onTopicChange(updatedTopics) | ||
}, | ||
[onTopicChange, selectedTopicsModal] | ||
) | ||
|
||
return ( | ||
<Grid container direction="column" alignItems="center" spacing={3}> | ||
<Grid item> | ||
<Typography variant="h6" sx={{ mt: '1rem' }}> | ||
{t('components.TableRemoteTopics')} | ||
</Typography> | ||
</Grid> | ||
<Grid item container alignItems="stretch" direction="row"> | ||
{remoteTopics.length === 0 ? ( | ||
<Grid container direction="column" alignItems="center"> | ||
<SkeletonList /> | ||
</Grid> | ||
) : ( | ||
<Grid item container direction="column" alignItems="center"> | ||
<Paper sx={{ padding: '1rem', width: '95%' }}> | ||
<FormGroup> | ||
{remoteTopics.map((LmsTopic) => ( | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={selectedTopicsModal.some((topic) => topic.topic_lms_id === LmsTopic.topic_lms_id)} | ||
onChange={(event) => handleTopicChange(LmsTopic, event.target.checked)} | ||
id={'topic-modal-available-topics-checkbox-' + LmsTopic.topic_lms_name} | ||
/> | ||
} | ||
label={LmsTopic.topic_lms_name} | ||
key={LmsTopic.topic_lms_id} | ||
/> | ||
))} | ||
</FormGroup> | ||
</Paper> | ||
{children} | ||
</Grid> | ||
)} | ||
</Grid> | ||
</Grid> | ||
) | ||
} | ||
) | ||
// eslint-disable-next-line immutable/no-mutation | ||
CreateRemoteTopicsTable.displayName = 'TableRemoteTopics' | ||
export default CreateRemoteTopicsTable |
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.