Skip to content

Commit

Permalink
Prepare renew cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
ericof committed Sep 7, 2023
1 parent 6902292 commit 0e519dc
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 84 deletions.
4 changes: 2 additions & 2 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ create-site: instance/etc/zope.ini ## Create a new site from scratch

.PHONY: start
start: ## Start a Plone instance on localhost:8080
PYTHONWARNINGS=ignore ./bin/runwsgi instance/etc/zope.ini
ENABLE_PRINTING_MAILHOST=True PYTHONWARNINGS=ignore ./bin/runwsgi instance/etc/zope.ini

.PHONY: debug
debug: instance/etc/zope.ini ## Run debug console
Expand All @@ -178,4 +178,4 @@ create-tag: # Create a new tag using git
commit-and-release: # Commit new version change and create tag
@echo "Commiting changes"
@git commit -am "Tag release as $(PROJECT_VERSION) to deploy"
make create-tag
make create-tag
1 change: 1 addition & 0 deletions backend/src/ploneorg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"plone.app.testing[robot]>=7.0.0a3",
"plone.restapi[test]",
"collective.MockMailHost",
"Products.PrintingMailHost",
"pytest",
],
},
Expand Down
2 changes: 1 addition & 1 deletion backend/src/ploneorg/src/ploneorg/interpolators/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class RenewURLSubstitution(BaseSubstitution):

def safe_call(self):
url = self.context.absolute_url()
return f"{url}/renew_membership>"
return f"{url}?mtm_campaign=PFM&mtm_kwd=Renew"
213 changes: 137 additions & 76 deletions frontend/src/components/Views/FoundationMember.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,96 +3,157 @@
* @module components/View/FoundationMemberView
*/

import React from 'react';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { Container, Table } from 'semantic-ui-react';
import { flattenHTMLToAppURL } from '@plone/volto/helpers';
import { Container, Table, Button } from 'semantic-ui-react';
import { flattenHTMLToAppURL, flattenToAppURL } from '@plone/volto/helpers';
import { useSelector, useDispatch } from 'react-redux';
import { getWorkflow, transitionWorkflow } from '@plone/volto/actions';

import './member.less';

/**
* FoundationMemberView view component class.
* @function FoundationMemberView
* @params {object} content Content object.
* @returns {string} Markup of the component.
*/
const FoundationMemberView = ({ content }) => (
<Container className="view-wrapper">
{content.title && <h1 className="documentFirstHeading">{content.title}</h1>}
<p className="documentDescription">
{content.organization && (
const FoundationMemberView = (props) => {
const pathname = props.location.pathname;
const { content } = props;
const dispatch = useDispatch();
const transitionLoading = useSelector(
(state) => state.workflow?.transition?.loading || false,
);
const transitions = useSelector((state) => state.workflow?.transitions);
const currentState = useSelector((state) => state.workflow?.currentState);
const [transition, setTransition] = useState('');
const allowedTransitions = ['Renew'];

useEffect(() => {
if (transitionLoading === false) {
dispatch(getWorkflow(pathname));
}
}, [dispatch, pathname, transitionLoading]);

useEffect(() => {
if (transition) {
dispatch(transitionWorkflow(transition));
setTransition('');
}
}, [dispatch, transition]);

const handleTransition = (action) => {
setTransition(flattenToAppURL(action));
};

const displayActions = currentState && transitions && transitions.length > 0;

return (
<Container className="view-wrapper">
{content.title && (
<h1 className="documentFirstHeading">{content.title}</h1>
)}
<p className="documentDescription">
{content.organization && (
<>
<span className="organization">{content.organization}</span>{' '}
</>
)}
{content.city && (
<>
<span className="city">{content.city}</span> (
<span className="country">{content.country.title}</span>)
</>
)}
</p>

{displayActions && (
<>
<h2>Actions</h2>
<Container className="memberActions">
<Container className="actions">
{transitions.map(function (transition, i) {
return (
allowedTransitions.includes(transition.title) && (
<Button
key={i}
className={`transition transition-${transition.title}`}
onClick={() => handleTransition(transition['@id'])}
>
{transition.title}
</Button>
)
);
})}
</Container>
</Container>
</>
)}
{content.email && (
<>
<span className="organization">{content.organization}</span>{' '}
<h2>Contact Information</h2>
<Container>
<Table celled padded>
<Table.Body>
<Table.Row>
<Table.Cell>E-mail</Table.Cell>
<Table.Cell singleLine>
{content.email ? (
<a href={`mailto: ${content.email}`}>{content.email}</a>
) : (
''
)}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Address</Table.Cell>
<Table.Cell singleLine>
{content.address ? content.address : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>City</Table.Cell>
<Table.Cell singleLine>
{content.city ? content.city : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>State</Table.Cell>
<Table.Cell singleLine>
{content.state ? content.state : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Postal Code</Table.Cell>
<Table.Cell singleLine>
{content.postal_code ? content.postal_code : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Country</Table.Cell>
<Table.Cell singleLine>
{content.country ? content.country.title : '-'}
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
</Container>
</>
)}
{content.city && (
{content.merit && (
<>
<span className="city">{content.city}</span> (
<span className="country">{content.country.title}</span>)
<h2>Contributions</h2>
<div
dangerouslySetInnerHTML={{
__html: flattenHTMLToAppURL(content.merit.data),
}}
/>
</>
)}
</p>
{content.email && (
<>
<h2>Contact Information</h2>
<Container>
<Table celled padded>
<Table.Body>
<Table.Row>
<Table.Cell>E-mail</Table.Cell>
<Table.Cell singleLine>
{content.email ? (
<a href={`mailto: ${content.email}`}>{content.email}</a>
) : (
''
)}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Address</Table.Cell>
<Table.Cell singleLine>
{content.address ? content.address : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>City</Table.Cell>
<Table.Cell singleLine>
{content.city ? content.city : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>State</Table.Cell>
<Table.Cell singleLine>
{content.state ? content.state : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Postal Code</Table.Cell>
<Table.Cell singleLine>
{content.postal_code ? content.postal_code : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Country</Table.Cell>
<Table.Cell singleLine>
{content.country ? content.country.title : '-'}
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
</Container>
</>
)}
{content.merit && (
<>
<h2>Contributions</h2>
<div
dangerouslySetInnerHTML={{
__html: flattenHTMLToAppURL(content.merit.data),
}}
/>
</>
)}
</Container>
);
</Container>
);
};

/**
* Property types.
Expand Down
31 changes: 31 additions & 0 deletions frontend/src/components/Views/member.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@blue: #007db9;
@yellow: #efbd0b;
@green: #5eb618;
@lightGrey: #cdcdcd;

div.ui.container.memberActions {
display: flex;
align-items: center;
justify-content: center;

> .actions {
text-align: center;
}
}

button.ui.button.transition {
padding: 2rem 4rem;
font-size: 14px;
font-weight: 700;

&.transition-Renew {
background-color: @green;
color: white;
}

&.transition-Retire {
margin-left: 3rem;
background-color: @lightGrey;
color: black;
}
}
6 changes: 1 addition & 5 deletions frontend/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ const routes = [
{
path: '/',
component: App, // Change this if you want a different component
routes: [
// Add your routes here
...(config.addonRoutes || []),
...defaultRoutes,
],
routes: [...(config.addonRoutes || []), ...defaultRoutes],
},
];

Expand Down

0 comments on commit 0e519dc

Please sign in to comment.