generated from EasyWebApp/WebCell-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 1
[add] Session & Agenda management pages #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
383d074
Initial plan
Copilot 46f842f
Implement complete session submission system with UI components and n…
Copilot ddf6e1f
Fix Session List and remove unnecessary components and pages
Copilot 1dd43b0
Complete agenda form configuration and simplify session submission wo…
Copilot a928068
Update pages/activity/[id]/agenda/index.tsx
TechQuery 8e7170c
Fix boolean prop shorthand and remove empty middleware in agenda pages
Copilot 12d567a
Add userId prop to AgendaList for user-specific agenda filtering
Copilot 9d2f8b0
Fix filtering approach and revert AgendaModel constructor changes
Copilot 000f36f
Update pages/user/agenda.tsx
TechQuery 71450db
Update components/Activity/AgendaList.tsx
TechQuery 73a9798
[optimize] simplify several details & update Upstream packages
TechQuery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,101 @@ | ||
| import { Agenda } from '@open-source-bazaar/activityhub-service'; | ||
| import { computed } from 'mobx'; | ||
| import { observer } from 'mobx-react'; | ||
| import { ObservedComponent } from 'mobx-react-helper'; | ||
| import { Column, RestTable } from 'mobx-restful-table'; | ||
| import { Badge } from 'react-bootstrap'; | ||
|
|
||
| import { AgendaModel } from '../../models/Agenda'; | ||
| import placeStore from '../../models/Place'; | ||
| import { i18n, I18nContext } from '../../models/Translation'; | ||
| import userStore from '../../models/User'; | ||
| import { renderTagInput } from '../Tag'; | ||
|
|
||
| export interface AgendaListProps { | ||
| activityId: number; | ||
| isOrganizer?: boolean; | ||
| userId?: number; | ||
| } | ||
|
|
||
| @observer | ||
| export class AgendaList extends ObservedComponent<AgendaListProps, typeof i18n> { | ||
| static contextType = I18nContext; | ||
|
|
||
| agendaStore = new AgendaModel(this.props.activityId); | ||
|
|
||
| @computed | ||
| get columns(): Column<Agenda>[] { | ||
| const { t } = this.observedContext; | ||
| const { isOrganizer = false } = this.observedProps; | ||
|
|
||
| return [ | ||
| { | ||
| renderHead: t('title'), | ||
| renderBody: ({ forum }) => forum?.title || t('unknown'), | ||
| required: true, | ||
| invalidMessage: t('field_required'), | ||
| }, | ||
| { | ||
| renderHead: t('summary'), | ||
| renderBody: ({ forum }) => forum?.summary || '-', | ||
| type: 'textarea', | ||
| rows: 3, | ||
| }, | ||
| { | ||
| renderHead: t('start_time'), | ||
| renderBody: ({ forum }) => forum?.startTime ? new Date(forum.startTime).toLocaleString() : '-', | ||
| type: 'datetime-local', | ||
| }, | ||
| { | ||
| renderHead: t('end_time'), | ||
| renderBody: ({ forum }) => forum?.endTime ? new Date(forum.endTime).toLocaleString() : '-', | ||
| type: 'datetime-local', | ||
| }, | ||
| { | ||
| renderHead: t('place'), | ||
| renderBody: ({ forum }) => forum?.place?.name || t('unknown'), | ||
| renderInput: renderTagInput(placeStore), | ||
| required: true, | ||
| invalidMessage: t('field_required'), | ||
| }, | ||
| { | ||
| key: 'mentors', | ||
| renderHead: t('mentors'), | ||
| renderBody: ({ mentors }) => | ||
| mentors?.map(mentor => mentor.name).join(', ') || '-', | ||
| renderInput: renderTagInput(userStore), | ||
TechQuery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| required: true, | ||
| invalidMessage: t('field_required'), | ||
| }, | ||
| { | ||
| key: 'adopted', | ||
| renderHead: t('status'), | ||
| renderBody: ({ adopted }) => ( | ||
| <Badge bg={adopted ? 'success' : 'warning'}> | ||
| {adopted ? t('approved') : t('pending_review')} | ||
| </Badge> | ||
| ), | ||
| type: 'checkbox', | ||
TechQuery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| readOnly: !isOrganizer, | ||
| }, | ||
| ]; | ||
| } | ||
|
|
||
| render() { | ||
| const { activityId, userId } = this.props; | ||
|
|
||
| return ( | ||
| <RestTable | ||
| className="h-100 text-center" | ||
| striped | ||
| hover | ||
| editable | ||
| deletable | ||
| columns={this.columns} | ||
| store={this.agendaStore} | ||
TechQuery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {...({ filter: { activity: activityId, createdBy: userId } } as any)} | ||
| translator={this.observedContext} | ||
| /> | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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,87 @@ | ||
| import { Session } from '@open-source-bazaar/activityhub-service'; | ||
| import { computed } from 'mobx'; | ||
| import { observer } from 'mobx-react'; | ||
| import { ObservedComponent } from 'mobx-react-helper'; | ||
| import { Column, RestTable } from 'mobx-restful-table'; | ||
| import { Button } from 'react-bootstrap'; | ||
|
|
||
| import sessionStore from '../../models/Session'; | ||
| import { i18n, I18nContext } from '../../models/Translation'; | ||
|
|
||
| export interface SessionListProps { | ||
| showActions?: boolean; | ||
| } | ||
|
|
||
| @observer | ||
| export class SessionList extends ObservedComponent<SessionListProps, typeof i18n> { | ||
| static contextType = I18nContext; | ||
|
|
||
| @computed | ||
| get columns(): Column<Session>[] { | ||
| const { t } = this.observedContext; | ||
| const { showActions = true } = this.observedProps; | ||
|
|
||
| const baseColumns: Column<Session>[] = [ | ||
| { | ||
| key: 'title', | ||
| renderHead: t('title'), | ||
| renderBody: ({ title }) => title || t('unknown'), | ||
| required: true, | ||
| invalidMessage: t('field_required'), | ||
| }, | ||
| { | ||
| key: 'summary', | ||
| renderHead: t('summary'), | ||
| renderBody: ({ summary }) => summary || '-', | ||
| type: 'textarea', | ||
| rows: 3, | ||
| }, | ||
| { | ||
| key: 'durationMinute', | ||
| renderHead: t('duration_minutes'), | ||
| renderBody: ({ durationMinute }) => `${durationMinute || 0} ${t('minutes')}`, | ||
| type: 'number', | ||
| min: 1, | ||
| required: true, | ||
| invalidMessage: t('field_required'), | ||
| }, | ||
| { | ||
| key: 'peopleCapacity', | ||
| renderHead: t('people_capacity'), | ||
| renderBody: ({ peopleCapacity }) => peopleCapacity || '-', | ||
| type: 'number', | ||
| min: 1, | ||
| }, | ||
| ]; | ||
|
|
||
| if (showActions) { | ||
| baseColumns.push({ | ||
| renderHead: t('actions'), | ||
| renderBody: () => ( | ||
| <Button variant="outline-success" size="sm" href="/user/agenda"> | ||
| {t('submit_to_activity')} | ||
| </Button> | ||
| ), | ||
| }); | ||
| } | ||
|
|
||
| return baseColumns; | ||
| } | ||
|
|
||
| render() { | ||
| const { showActions = true } = this.observedProps; | ||
|
|
||
| return ( | ||
| <RestTable | ||
| className="h-100 text-center" | ||
| striped | ||
| hover | ||
| editable={showActions} | ||
| deletable={showActions} | ||
| columns={this.columns} | ||
| store={sessionStore} | ||
| translator={this.observedContext} | ||
| /> | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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,14 @@ | ||
| import { Agenda } from '@open-source-bazaar/activityhub-service'; | ||
|
|
||
| import { TableModel } from './Base'; | ||
| import userStore from './User'; | ||
|
|
||
| export class AgendaModel extends TableModel<Agenda> { | ||
| baseURI = ''; | ||
| client = userStore.client; | ||
|
|
||
| constructor(activityId: number) { | ||
| super(); | ||
| this.baseURI = `activity/${activityId}/agenda`; | ||
| } | ||
| } |
This file contains hidden or 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,11 @@ | ||
| import { Session } from '@open-source-bazaar/activityhub-service'; | ||
|
|
||
| import { TableModel } from './Base'; | ||
| import userStore from './User'; | ||
|
|
||
| export class SessionModel extends TableModel<Session> { | ||
| baseURI = 'session'; | ||
| client = userStore.client; | ||
| } | ||
|
|
||
| export default new SessionModel(); |
This file contains hidden or 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,32 @@ | ||
| import { User } from '@open-source-bazaar/activityhub-service'; | ||
| import { observer } from 'mobx-react'; | ||
| import { useRouter } from 'next/router'; | ||
| import { compose, JWTProps, jwtVerifier } from 'next-ssr-middleware'; | ||
| import { FC, useContext } from 'react'; | ||
|
|
||
| import { AgendaList } from '../../../../components/Activity/AgendaList'; | ||
| import { organizerMenu } from '../../../../components/Activity/menu'; | ||
| import { SessionBox } from '../../../../components/User/SessionBox'; | ||
| import { I18nContext } from '../../../../models/Translation'; | ||
|
|
||
| interface AgendaListPageProps extends JWTProps<User> {} | ||
|
|
||
| export const getServerSideProps = compose<{ id: string }, AgendaListPageProps>( | ||
| jwtVerifier(), | ||
| ); | ||
|
|
||
| const AgendaListPage: FC<AgendaListPageProps> = observer(({ jwtPayload }) => { | ||
| const { asPath, query } = useRouter(), | ||
| i18n = useContext(I18nContext); | ||
|
|
||
| const activityId = +(query.id as string); | ||
| const title = i18n.t('agenda_management'); | ||
|
|
||
| return ( | ||
| <SessionBox {...{ title, jwtPayload }} path={asPath} menu={organizerMenu(i18n, activityId)}> | ||
| <AgendaList activityId={activityId} isOrganizer /> | ||
| </SessionBox> | ||
| ); | ||
| }); | ||
|
|
||
| export default AgendaListPage; |
This file contains hidden or 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,29 @@ | ||
| import { User } from '@open-source-bazaar/activityhub-service'; | ||
| import { observer } from 'mobx-react'; | ||
| import { useRouter } from 'next/router'; | ||
| import { JWTProps, jwtVerifier } from 'next-ssr-middleware'; | ||
| import { FC, useContext } from 'react'; | ||
|
|
||
| import { AgendaList } from '../../components/Activity/AgendaList'; | ||
| import { userMenu } from '../../components/Activity/menu'; | ||
| import { SessionBox } from '../../components/User/SessionBox'; | ||
| import { I18nContext } from '../../models/Translation'; | ||
|
|
||
| interface UserAgendaPageProps extends JWTProps<User> {} | ||
|
|
||
| export const getServerSideProps = jwtVerifier<UserAgendaPageProps>(); | ||
|
|
||
| const UserAgendaPage: FC<UserAgendaPageProps> = observer(({ jwtPayload }) => { | ||
| const { asPath } = useRouter(), | ||
| i18n = useContext(I18nContext); | ||
|
|
||
| const title = i18n.t('agenda_management'); | ||
|
|
||
| return ( | ||
| <SessionBox {...{ title, jwtPayload }} path={asPath} menu={userMenu(i18n)}> | ||
| <AgendaList userId={jwtPayload?.id} /> | ||
| </SessionBox> | ||
| ); | ||
| }); | ||
|
|
||
| export default UserAgendaPage; |
This file contains hidden or 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,36 @@ | ||
| import { User } from '@open-source-bazaar/activityhub-service'; | ||
| import { observer } from 'mobx-react'; | ||
| import { useRouter } from 'next/router'; | ||
| import { compose, JWTProps, jwtVerifier } from 'next-ssr-middleware'; | ||
| import { FC, useContext } from 'react'; | ||
|
|
||
| import { userMenu } from '../../../components/Activity/menu'; | ||
| import { SessionList } from '../../../components/Session/List'; | ||
| import { SessionBox } from '../../../components/User/SessionBox'; | ||
| import { I18nContext } from '../../../models/Translation'; | ||
|
|
||
| interface SessionListPageProps extends JWTProps<User> {} | ||
|
|
||
| export const getServerSideProps = compose<{}, SessionListPageProps>( | ||
| jwtVerifier(), | ||
| async () => ({ props: {} }), | ||
TechQuery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
|
|
||
| const SessionListPage: FC<SessionListPageProps> = observer(({ jwtPayload }) => { | ||
| const { asPath } = useRouter(), | ||
| i18n = useContext(I18nContext); | ||
|
|
||
| const title = i18n.t('session_list'); | ||
|
|
||
| return ( | ||
| <SessionBox | ||
| {...{ title, jwtPayload }} | ||
| path={asPath} | ||
| menu={userMenu(i18n)} | ||
| > | ||
| <SessionList /> | ||
| </SessionBox> | ||
| ); | ||
| }); | ||
|
|
||
| export default SessionListPage; | ||
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.