-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨(frontend) add mocked organization to
...TeacherDashboardProfileSidebar Part of teacher dashboard development, the sidebar contains links to user's organizations.
- Loading branch information
1 parent
56fa25c
commit 6ab4b4a
Showing
24 changed files
with
411 additions
and
60 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,47 @@ | ||
import { rest } from 'msw'; | ||
import { getAPIEndpoint } from 'api/joanie'; | ||
|
||
export interface OrganizationMock { | ||
id: string; | ||
code: string; | ||
title: string; | ||
logo: { | ||
filename: string; | ||
url: string; | ||
height: number; | ||
width: number; | ||
}; | ||
} | ||
|
||
export const listOrganizations = rest.get<OrganizationMock[]>( | ||
`${getAPIEndpoint()}/organizations`, | ||
(_req, res, ctx) => { | ||
const cover001 = require('./assets/organization_cover_001.jpg'); | ||
const cover002 = require('./assets/organization_cover_002.jpg'); | ||
const organisations: OrganizationMock[] = [ | ||
{ | ||
id: 'AAA', | ||
code: 'code__AAA', | ||
title: 'Univesité de Rennes', | ||
logo: { | ||
filename: 'organization_cover_001.jpg', | ||
url: cover001.default, | ||
height: 113, | ||
width: 113, | ||
}, | ||
}, | ||
{ | ||
id: 'BBB', | ||
code: 'code__BBB', | ||
title: 'Univesité de Paris', | ||
logo: { | ||
filename: 'organization_cover_002.jpg', | ||
url: cover002.default, | ||
height: 113, | ||
width: 113, | ||
}, | ||
}, | ||
]; | ||
return res(ctx.status(200), ctx.json(organisations)); | ||
}, | ||
); |
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,31 @@ | ||
import { defineMessages } from 'react-intl'; | ||
|
||
import { OrganizationMock } from 'api/mocks/joanie/organizations'; | ||
import { useJoanieApi } from 'contexts/JoanieApiContext'; | ||
import { useResource, useResources, UseResourcesProps } from '../useResources'; | ||
|
||
const messages = defineMessages({ | ||
errorGet: { | ||
id: 'hooks.useOrganizations.errorSelect', | ||
description: 'Error message shown to the user when organizations fetch request fails.', | ||
defaultMessage: 'An error occurred while fetching organizations. Please retry later.', | ||
}, | ||
errorNotFound: { | ||
id: 'hooks.useOrganizations.errorNotFound', | ||
description: 'Error message shown to the user when no organizations matches.', | ||
defaultMessage: 'Cannot find the organization', | ||
}, | ||
}); | ||
|
||
/** | ||
* Joanie Api hook to retrieve organizations | ||
* owned by the authenticated user. | ||
*/ | ||
const props: UseResourcesProps<OrganizationMock> = { | ||
queryKey: ['organizations'], | ||
apiInterface: () => useJoanieApi().user.organizations, | ||
session: true, | ||
messages, | ||
}; | ||
export const useOrganizations = useResources<OrganizationMock>(props); | ||
export const useOrganization = useResource<OrganizationMock>(props); |
16 changes: 16 additions & 0 deletions
16
src/frontend/js/pages/TeacherCoursesDashboardLoader/index.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,16 @@ | ||
import { useIntl } from 'react-intl'; | ||
import { DashboardLayout } from 'widgets/Dashboard/components/DashboardLayout'; | ||
import { TeacherProfileDashboardSidebar } from 'widgets/Dashboard/components/TeacherProfileDashboardSidebar'; | ||
import RouteInfo from 'widgets/Dashboard/components/RouteInfo'; | ||
import { getDashboardRouteLabel } from 'widgets/Dashboard/utils/dashboardRoutes'; | ||
import { TeacherDashboardPaths } from 'widgets/Dashboard/utils/teacherRouteMessages'; | ||
|
||
export const TeacherCoursesDashboardLoader = () => { | ||
const intl = useIntl(); | ||
const getRouteLabel = getDashboardRouteLabel(intl); | ||
return ( | ||
<DashboardLayout sidebar={<TeacherProfileDashboardSidebar />}> | ||
<RouteInfo title={getRouteLabel(TeacherDashboardPaths.TEACHER_NOTIFICATIONS)} />, | ||
</DashboardLayout> | ||
); | ||
}; |
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
28 changes: 0 additions & 28 deletions
28
src/frontend/js/widgets/Dashboard/components/TeacherProfileDashboardLoader/index.tsx
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
...board/components/TeacherProfileDashboardSidebar/components/OrganizationLinks/_styles.scss
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,42 @@ | ||
.dashboard-sidebar { | ||
&__organization-section { | ||
// padding: rem-calc(5px) rem-calc(8px) rem-calc(40px); | ||
padding: rem-calc(20px) rem-calc(8px) rem-calc(40px); | ||
|
||
&__title { | ||
font-size: rem-calc(16px); | ||
font-weight: normal; | ||
color: r-theme-val(dashboard-sidebar-organization-link-title, base-color); | ||
} | ||
|
||
&__link_list { | ||
display: flex; | ||
flex-wrap: wrap; | ||
flex-direction: row; | ||
gap: rem-calc(5px); | ||
margin-top: rem-calc(10px); | ||
} | ||
|
||
&__link { | ||
flex: 0 0 32%; | ||
display: flex; | ||
border: thin solid r-theme-val(organization-thumb, border-color); | ||
border-radius: rem-calc(8px); | ||
overflow: hidden; | ||
justify-content: center; | ||
align-items: center; | ||
padding: rem-calc(2px); | ||
&:hover, | ||
&:focus, | ||
&:active { | ||
border-color: r-theme-val(organization-thumb, border-color-hover); | ||
box-shadow: 0 0 rem-calc(3px) r-theme-val(organization-thumb, border-color); | ||
} | ||
&__img { | ||
object-fit: cover; | ||
object-position: center center; | ||
aspect-ratio: 2/1; | ||
} | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...ashboard/components/TeacherProfileDashboardSidebar/components/OrganizationLinks/index.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,55 @@ | ||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; | ||
import { Link } from 'react-router-dom'; | ||
import { OrganizationMock } from 'api/mocks/joanie/organizations'; | ||
import { getDashboardRoutePath } from 'widgets/Dashboard/utils/dashboardRoutes'; | ||
import { TeacherDashboardPaths } from 'widgets/Dashboard/utils/teacherRouteMessages'; | ||
|
||
export const messages = defineMessages({ | ||
organizationsTitle: { | ||
id: 'components.TeacherProfileDashboardSidebar.OrganizationLinks.organizationsTitle', | ||
description: 'Title of the organizations section', | ||
defaultMessage: 'My universities', | ||
}, | ||
organizationLinkTitle: { | ||
id: 'components.TeacherProfileDashboardSidebar.OrganizationLinks.organizationLinkTitle', | ||
description: 'Organization link title', | ||
defaultMessage: 'Link to organization "{organizationTitle}"', | ||
}, | ||
}); | ||
|
||
interface OrganizationLinksProps { | ||
organizations: OrganizationMock[]; | ||
} | ||
|
||
const OrganizationLinks = ({ organizations }: OrganizationLinksProps) => { | ||
const intl = useIntl(); | ||
return ( | ||
<div className="dashboard-sidebar__organization-section" data-testid="organization-links"> | ||
<span className="dashboard-sidebar__organization-section__title"> | ||
<FormattedMessage {...messages.organizationsTitle} /> | ||
</span> | ||
<div className="dashboard-sidebar__organization-section__link_list"> | ||
{organizations.map((organization) => ( | ||
<Link | ||
key={organization.id} | ||
to={getDashboardRoutePath(intl)(TeacherDashboardPaths.ORGANIZATION_COURSES, { | ||
organizationId: organization.id, | ||
})} | ||
className="dashboard-sidebar__organization-section__link" | ||
title={intl.formatMessage(messages.organizationLinkTitle, { | ||
organizationTitle: organization.title, | ||
})} | ||
> | ||
<img | ||
className="dashboard-sidebar__organization-section__link__img" | ||
alt={organization.title} | ||
src={organization.logo.url} | ||
/> | ||
</Link> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default OrganizationLinks; |
Oops, something went wrong.