Skip to content

Commit

Permalink
Experimenting with auth and permissions to get to V3 for schools
Browse files Browse the repository at this point in the history
  • Loading branch information
nzvorn committed Jul 21, 2021
1 parent 17e883d commit ecf25e5
Show file tree
Hide file tree
Showing 19 changed files with 97 additions and 180 deletions.
3 changes: 2 additions & 1 deletion components/Act/ActAboutPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ export function ActAboutPanel ({ act }) {
const isAnon = me.role.includes(Role.ANON)
const vp = me.role.includes(Role.VOLUNTEER) || isAnon
const bp = me.role.includes(Role.BASIC) || isAnon
const op = me.role.includes(Role.OPPORTUNITY_PROVIDER) || isAnon
return (
<ProfilePanel>
<ActAboutSection act={act} />
<Divider />
{bp && <ActOpsPanel act={act} type={OFFER} limit={6} />}
{op && <ActOpsPanel act={act} type={OFFER} limit={6} />}
{vp && <ActOpsPanel act={act} type={ASK} limit={6} />}

<ActActivityGuideSection act={act} />
Expand Down
3 changes: 1 addition & 2 deletions components/Act/ActCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ const ActCard = ({ act, onPress, ...props }) => {
</h1>
<p>{act.subtitle}</p>
<ul>
<li><OpTypeCount counts={act.opCounts} type={ASK} /></li>
<li><OpTypeCount counts={act.opCounts} type={OFFER} /></li>

<li><OpCommitment duration={act.duration} /></li>
</ul>
</figcaption>
Expand Down
17 changes: 5 additions & 12 deletions components/Act/ActListSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export const ActListSection = () => {
const getActivities = async () => {
const q = { status: 'active' }
const query = { }
if (me.topicGroups && me.topicGroups.length) {
q.tags = { $in: me.topicGroups }
}
//if (me.topicGroups && me.topicGroups.length) {
// q.tags = { $in: me.topicGroups }
//}
if (selectedOrg) {
q.offerOrg = selectedOrg
}
Expand All @@ -57,6 +57,7 @@ export const ActListSection = () => {
query.search = search
}
await dispatch(reduxApi.actions.activities.get(query))

}
getActivities()
}, [search, selectedOrg])
Expand Down Expand Up @@ -106,15 +107,7 @@ export const ActListSection = () => {
</List.Item>
)}
/>
<Card>Cant find what you want?
<a
target='_blank'
rel='noopener noreferrer'
href='https://voluntarily.atlassian.net/servicedesk/customer/portal/2/group/3/create/17'
>
Suggest an activity here
</a>
</Card>

</div>
</SidebarGrid>
</>
Expand Down
9 changes: 0 additions & 9 deletions components/Footer/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,6 @@ const Footer = () => (
<MenuWrapper>

<MenuItem><a href='https://blog.voluntarily.nz/get-involved' target='_blank' rel='noopener noreferrer'>Join the build</a></MenuItem>
<MenuItem><a href='https://support.voluntarily.nz/hc/en-nz/requests/new?ticket_form_id=360003338774' target='_blank' rel='noreferrer noopener'>Suggest a Topic</a></MenuItem>
<MenuItem>
<a
href='https://voluntarily.statuspage.io'
target='_blank'
rel='noopener noreferrer'
>System Status
</a>
</MenuItem>
<MenuItem>
<a
href='/terms'
Expand Down
5 changes: 3 additions & 2 deletions components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ const Header = () => {
}

let state = isAuthenticated ? MenuShowState.AUTH : MenuShowState.ANON
if (me.role.includes(Role.BASIC)) state = MenuShowState.BASIC
if (me.role.includes(Role.AUTH)) state = MenuShowState.AUTH
if (me.role.includes(Role.VOLUNTEER)) state = MenuShowState.VOLUNTEER
if (me.role.includes(Role.VOLUNTEER) && me.role.includes(Role.BASIC)) state = MenuShowState.BOTH
if (me.role.includes(Role.ORG_ADMIN)) state = MenuShowState.ORG_ADMIN
if (me.role.includes(Role.ACTIVITY_PROVIDER)) state = MenuShowState.ACTIVITY_PROVIDER
if (me.role.includes(Role.ADMIN) || me.role.includes(Role.SUPPORT)) state = MenuShowState.ADMIN
return (
<Layout.Header style={headerStyle}>
Expand Down
63 changes: 27 additions & 36 deletions components/Header/HeaderMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,77 +6,68 @@ export const MenuShowState = {
AUTH: 'auth',
BASIC: 'basic', // option shows for signed in people
VOLUNTEER: 'volunteer', // option shows for signed in volunteer
BOTH: 'both', // option shows for both ask and offer
OPPORTUNITY_PROVIDER: 'opportunityProvider',
ORG_ADMIN: 'orgAdmin',
ADMIN: 'admin' // option shows for signed in admin
}
const { ANON, AUTH, BASIC, VOLUNTEER, BOTH, ADMIN } = MenuShowState
const { ANON, AUTH, BASIC, VOLUNTEER, OPPORTUNITY_PROVIDER, ACTIVITY_PROVIDER, RESOURCE_PROVIDER, ORG_ADMIN, ADMIN } = MenuShowState

const menuItems = [

{
key: 'home',
show: [AUTH, BASIC, VOLUNTEER, BOTH, ADMIN],
href: '/home',
key: 'dashboard',
show: [AUTH, BASIC, VOLUNTEER, OPPORTUNITY_PROVIDER, ACTIVITY_PROVIDER, RESOURCE_PROVIDER, ORG_ADMIN, ADMIN],
href: '/',
text:
<FormattedMessage
id='HeaderMenu.home'
defaultMessage='Home'
id='HeaderMenu.dashboard'
defaultMessage='Dashboard'
/>
},
{
key: 'acts_ask',
show: [BASIC, BOTH, ADMIN],
href: '/a/ask',
key: 'org',
show: [VOLUNTEER, BASIC, OPPORTUNITY_PROVIDER, ACTIVITY_PROVIDER, RESOURCE_PROVIDER, ORG_ADMIN, ADMIN],
href: '/org',
text:
<FormattedMessage
id='HeaderMenu.acts_ask'
defaultMessage='Ask for help'
id='HeaderMenu.org'
defaultMessage='Organisations'
/>
},
{
key: 'acts_offer',
show: [VOLUNTEER, BOTH, ADMIN],
href: '/a/offer',
key: 'acts_ask',
show: [OPPORTUNITY_PROVIDER, ACTIVITY_PROVIDER, ORG_ADMIN, ADMIN],
href: '/a/ask',
text:
<FormattedMessage
id='HeaderMenu.acts_offer'
defaultMessage='Offer to help'
id='HeaderMenu.acts_ask'
defaultMessage='Find volunteers'
/>
},

{
key: 'habout',
show: [AUTH, ANON],
href: 'https://blog.voluntarily.nz',
key: 'acts_offer',
show: [VOLUNTEER, BASIC, AUTH, ADMIN],
href: '/search',
text:
<FormattedMessage
id='HeaderMenu.about'
defaultMessage='About'
id='HeaderMenu.acts_offer'
defaultMessage='Volunteer to help'
/>
},

{
key: 'admin',
text: 'Admin',
href: '/admin',
show: [ADMIN]
},
{
key: 'orgs',
text: 'Groups',
href: '/orgs',
show: [ADMIN]

},
{
key: 'people',
text: 'People',
href: '/people',
show: [ADMIN]
},
{
key: 'help',
show: [ANON, AUTH, BASIC, VOLUNTEER, BOTH, ADMIN],
text: 'Support 🙋🏽‍♀️',
href: 'https://support.voluntarily.nz/hc/en-nz'
},
{
key: 'hsignin',
show: [ANON],
Expand All @@ -89,7 +80,7 @@ const menuItems = [
},
{
key: 'hsignoff',
show: [AUTH, BASIC, VOLUNTEER, BOTH, ADMIN],
show: [AUTH, VOLUNTEER, BASIC, OPPORTUNITY_PROVIDER, ACTIVITY_PROVIDER, RESOURCE_PROVIDER, ORG_ADMIN, ADMIN],
href: '/auth/sign-off',
text:
<FormattedMessage
Expand Down
10 changes: 5 additions & 5 deletions components/Op/OpOrderby.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ import { FormattedMessage } from 'react-intl'

const OpOrderby = ({ onChange }) => {
const style = {
width: 150,
width: 250,
float: 'right',
position: 'relative',
marginTop: -60
}
return (
<Select placeholder='Sort By' defaultValue='Date' style={style} onChange={onChange}>
<Select placeholder='Sort By' defaultValue='Sort by date' lable='Sort by' style={style} onChange={onChange}>
<Select.Option name='date' value='date'>
<FormattedMessage
id='sortDate'
defaultMessage='Date'
defaultMessage='Sort by date'
description='Sort order by Date'
/>
</Select.Option>
<Select.Option value='name'>
<FormattedMessage
id='sortName'
defaultMessage='Name'
defaultMessage='Sort by name'
description='Sort order by Name'
/>
</Select.Option>
<Select.Option value='commitment'>
<FormattedMessage
id='sortCommitment'
defaultMessage='commitment'
defaultMessage='Sort by time commitment'
description='Sort order by commitment'
/>
</Select.Option>
Expand Down
83 changes: 1 addition & 82 deletions components/Op/OpQuestionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,88 +201,7 @@ export function OpQuestionPanel ({ op }) {
</QuestionDetail>
</ContentCard>
</Response>
<Question>
<DateBlock>
<p>
29 Jan 2019
<br />
11:59PM
</p>
</DateBlock>
<ContentCard>
<h3>Can I get free parking at the school? </h3>
<QuestionDetail>
<img />
<p>Legitimate Name</p>

<Button shape='round' size='large' type='secondary' block>
Reply
</Button>
</QuestionDetail>
</ContentCard>
</Question>
<Response>
<DateBlock>
<p>
29 Jan 2019
<br />
11:59PM
</p>
</DateBlock>
<ContentCard>
<h4>
Yeah, text me at 027 123 4567 when you get close to the school
</h4>
<QuestionDetail>
<img />
<p>Legitimate teacher</p>
<Button shape='round' size='large' type='secondary' block>
Reply
</Button>
</QuestionDetail>
</ContentCard>
</Response>
<Question>
<DateBlock>
<p>
29 Jan 2019
<br />
11:59PM
</p>
</DateBlock>
<ContentCard>
<h3>Can I get free parking at the school? </h3>
<QuestionDetail>
<img />
<p>Legitimate Name</p>

<Button shape='round' size='large' type='secondary' block>
Reply
</Button>
</QuestionDetail>
</ContentCard>
</Question>
<Response>
<DateBlock>
<p>
29 Jan 2019
<br />
11:59PM
</p>
</DateBlock>
<ContentCard>
<h4>
Yeah, text me at 027 123 4567 when you get close to the school
</h4>
<QuestionDetail>
<img />
<p>Legitimate teacher</p>
<Button shape='round' size='large' type='secondary' block>
Reply
</Button>
</QuestionDetail>
</ContentCard>
</Response>


</QuestionSection>
</>
Expand Down
11 changes: 6 additions & 5 deletions components/Person/PersonRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const PersonRole = ({ role }) => {
const roleOptions = {
admin: <FormattedMessage id='admin' defaultMessage='Admin' />,
orgAdmin: <FormattedMessage id='orgAdmin' defaultMessage='Organisation-Admin' />,
// opportunityProvider: <FormattedMessage id='opportunityProvider' defaultMessage='Make Requests' />,
basic: <FormattedMessage id='basic' defaultMessage='Asker' />,
opportunityProvider: <FormattedMessage id='opportunityProvider' defaultMessage='Make Requests' />,
basic: <FormattedMessage id='basic' defaultMessage='Volunteer' />,
volunteer: <FormattedMessage id='volunteer' defaultMessage='Volunteer' />,
activityProvider: <FormattedMessage id='activityProvider' defaultMessage='Activity Provider' />,
resourceProvider: <FormattedMessage id='resourceProvider' defaultMessage='Resource Provider' />,
Expand All @@ -22,11 +22,12 @@ const roleIcons = {
admin: '🌟',
orgAdmin: '⭐',
support: '💁',
opportunityProvider: '🤝',
activityProvider: '🧑‍💻',
resourceProvider: '🧑‍💻',
volunteer: '🤙', // 🤝,
basic: '🙋'
// opportunityProvider: '🤝'
volunteer: '🤙',
basic: '🤙'

}

export const PersonRoleIcon = ({ role }) => {
Expand Down
2 changes: 1 addition & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"ActiveOpsSection.empty.title": "Let’s find cool ways to volunteer",
"ActiveOpsSection.title": "Upcoming Activities",
"activityProvider": "Activity Provider",
"ActListPage.Ask.Title": "Volunteers are offering to help with",
"ActListPage.Ask.Title": "Ideas for asking for volunteers",
"ActListPage.Offer.Title": "People are asking for help with",
"actLock": "Lock Editable Fields",
"ActOpsPanel.button.showAll": "See all",
Expand Down
4 changes: 2 additions & 2 deletions pages/act/actlistpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { ASK, OFFER } = OpportunityType
const ActListTitleMessages = defineMessages({
[ASK]: {
id: 'ActListPage.Ask.Title',
defaultMessage: 'Volunteers are offering to help with',
defaultMessage: 'Ideas for attracting volunteers',
description: 'Title of ask for help page'
},
[OFFER]: {
Expand All @@ -26,7 +26,7 @@ const ActListTitleMessages = defineMessages({
const ActListSubTitleMessages = defineMessages({
[ASK]: {
id: 'act.list.ask.subtitle',
defaultMessage: 'Find activities volunteers are offering to help you with',
defaultMessage: 'Find activities volunteers can help you with',
description: 'Sub Title of page listing activities people are asking help with'
},
[OFFER]: {
Expand Down
Loading

0 comments on commit ecf25e5

Please sign in to comment.