-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kiram15/ENT-9529' of github.com:openedx/frontend-app-ad…
…min-portal into kiram15/ENT-9529
- Loading branch information
Showing
11 changed files
with
302 additions
and
42 deletions.
There are no files selected for viewing
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,59 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { CardGrid, Collapsible } from '@openedx/paragon'; | ||
|
||
import GroupDetailCard from './GroupDetailCard'; | ||
|
||
const GroupCardGrid = ({ groups }) => { | ||
const [previewGroups, setPreviewGroups] = useState(); | ||
const [overflowGroups, setOverflowGroups] = useState(); | ||
useEffect(() => { | ||
if (groups.length > 3) { | ||
setPreviewGroups(groups.slice(0, 3)); | ||
setOverflowGroups(groups.slice(3)); | ||
} else { | ||
setPreviewGroups(groups); | ||
} | ||
}, [groups]); | ||
return ( | ||
<> | ||
<CardGrid | ||
columnSizes={{ | ||
xs: 6, | ||
lg: 6, | ||
xl: 4, | ||
}} | ||
hasEqualColumnHeights="true" | ||
> | ||
{previewGroups?.map((group) => ( | ||
<GroupDetailCard group={group} /> | ||
))} | ||
</CardGrid> | ||
{overflowGroups && ( | ||
<Collapsible | ||
styling="basic" | ||
title={`Show all ${groups.length} groups`} | ||
> | ||
<CardGrid | ||
columnSizes={{ | ||
xs: 6, | ||
lg: 6, | ||
xl: 4, | ||
}} | ||
hasEqualColumnHeights="true" | ||
> | ||
{overflowGroups.map((group) => ( | ||
<GroupDetailCard group={group} /> | ||
))} | ||
</CardGrid> | ||
</Collapsible> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
GroupCardGrid.propTypes = { | ||
groups: PropTypes.shape.isRequired, | ||
}; | ||
|
||
export default GroupCardGrid; |
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,34 @@ | ||
import PropTypes from 'prop-types'; | ||
import { useParams } from 'react-router'; | ||
import { Card, Hyperlink } from '@openedx/paragon'; | ||
import { ROUTE_NAMES } from '../EnterpriseApp/data/constants'; | ||
|
||
const GroupDetailCard = ({ group }) => { | ||
const { enterpriseSlug } = useParams(); | ||
return ( | ||
<Card className="group-detail-card"> | ||
<Card.Header title={group.name} /> | ||
<Card.Section> | ||
{group.acceptedMembersCount} members | ||
</Card.Section> | ||
<Card.Footer className="card-button"> | ||
<Hyperlink | ||
className="btn btn-outline-primary" | ||
destination={`/${enterpriseSlug}/admin/${ROUTE_NAMES.peopleManagement}/${group.uuid}`} | ||
> | ||
View group | ||
</Hyperlink> | ||
</Card.Footer> | ||
</Card> | ||
); | ||
}; | ||
|
||
GroupDetailCard.propTypes = { | ||
group: PropTypes.shape({ | ||
acceptedMembersCount: PropTypes.number.isRequired, | ||
name: PropTypes.string.isRequired, | ||
uuid: PropTypes.string.isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
export default GroupDetailCard; |
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,54 @@ | ||
import React, { useContext } from 'react'; | ||
import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
import { Card } from '@openedx/paragon'; | ||
|
||
import cardImage from './images/ZeroStateImage.svg'; | ||
import { SUBSIDY_TYPES } from '../../data/constants/subsidyTypes'; | ||
import { EnterpriseSubsidiesContext } from '../EnterpriseSubsidiesContext'; | ||
|
||
const ZeroState = () => { | ||
const { enterpriseSubsidyTypes } = useContext(EnterpriseSubsidiesContext); | ||
|
||
const hasLearnerCredit = enterpriseSubsidyTypes.includes( | ||
SUBSIDY_TYPES.budget, | ||
); | ||
const hasOtherSubsidyTypes = enterpriseSubsidyTypes.includes(SUBSIDY_TYPES.license) | ||
|| enterpriseSubsidyTypes.includes(SUBSIDY_TYPES.coupon); | ||
|
||
return ( | ||
<Card> | ||
<Card.ImageCap | ||
className="mh-100" | ||
src={cardImage} | ||
srcAlt="Two people carrying a cartoon arrow" | ||
/> | ||
<span className="text-center align-self-center"> | ||
<h2 className="h3 mb-3 mt-3"> | ||
<FormattedMessage | ||
id="adminPortal.peopleManagement.zeroState.card.header" | ||
defaultMessage="You don't have any groups yet." | ||
description="Header message shown to admin there's no groups created yet." | ||
/> | ||
</h2> | ||
<p className="mx-2"> | ||
{hasLearnerCredit && ( | ||
<FormattedMessage | ||
id="adminPortal.peopleManagement.zeroState.card.subtitle.lc" | ||
defaultMessage="Once a group is created, you can track members' progress, assign extra courses, and invite them to additional budgets." | ||
description="Detail message shown to admin benefits of creating a group with learner credit." | ||
/> | ||
)} | ||
{!hasLearnerCredit && hasOtherSubsidyTypes && ( | ||
<FormattedMessage | ||
id="admin.portal.people.management.page.zerostate.card.subtitle.noLc" | ||
defaultMessage="Once a group is created, you can track members' progress." | ||
description="Detail message shown to admin benefits of creating a group without learner credit." | ||
/> | ||
)} | ||
</p> | ||
</span> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default ZeroState; |
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,13 @@ | ||
.group-detail-card { | ||
background-color: $light-200; | ||
.card-button { | ||
justify-content: flex-start !important; | ||
} | ||
.pgn__card-section { | ||
padding: .25rem 1.25rem 1.25rem 1.25rem; | ||
} | ||
} | ||
|
||
.collapsible-basic .collapsible-trigger { | ||
justify-content: right; | ||
} |
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
Oops, something went wrong.