Skip to content

Commit

Permalink
Prettify /frontend/src
Browse files Browse the repository at this point in the history
  • Loading branch information
HelNershingThapa committed Jul 25, 2022
1 parent dd40191 commit 6ad37a8
Show file tree
Hide file tree
Showing 41 changed files with 504 additions and 487 deletions.
39 changes: 22 additions & 17 deletions frontend/src/components/banner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export function Banner() {
if (!localStorage.getItem('optout-closed')) {
form.style.display = 'grid';
}
document.getElementById('optout-agree').onclick = function() {
document.getElementById('optout-agree').onclick = function () {
setAgree();
};
document.getElementById('optout-disagree').onclick = function() {
document.getElementById('optout-disagree').onclick = function () {
setDisagree();
};
}
Expand Down Expand Up @@ -83,7 +83,7 @@ export function DonationBanner() {
if (!localStorage.getItem('donation-closed')) {
form.style.display = 'grid';
}
document.getElementById('donation-close').onclick = function() {
document.getElementById('donation-close').onclick = function () {
closeForm();
};
}
Expand All @@ -107,12 +107,10 @@ export function DonationBanner() {
target="_blank"
rel="noopener noreferrer"
>
2021 HOT Summit
2021 HOT Summit
</a>
</p>
<p>
Join the virtual HOT Summit 2021 on November 22! All are invited; RSVP for free.
</p>
<p>Join the virtual HOT Summit 2021 on November 22! All are invited; RSVP for free.</p>
<div id="donation-buttons">
<div className="white bg-red pv2 ph3 mh1 br1 dib fw6 pointer" id="donation-close">
Close
Expand All @@ -130,10 +128,12 @@ export function ArchivalNotificationBanner() {
if (!localStorage.getItem('archival-notification-closed')) {
form.style.display = 'grid';
}
document.getElementById('archival-notification-learnmore').onclick = function() {
openWikiLink('/Humanitarian_OSM_Team/Working_groups/Data_Quality_Control_and_Assurance/Tasking_Manager_Project_Gardening');
document.getElementById('archival-notification-learnmore').onclick = function () {
openWikiLink(
'/Humanitarian_OSM_Team/Working_groups/Data_Quality_Control_and_Assurance/Tasking_Manager_Project_Gardening',
);
};
document.getElementById('archival-notification-close').onclick = function() {
document.getElementById('archival-notification-close').onclick = function () {
closeForm();
};
}
Expand All @@ -143,10 +143,7 @@ export function ArchivalNotificationBanner() {
localStorage.setItem('archival-notification-closed', 'true');
}
function openWikiLink(path) {
window.open(
'https://wiki.openstreetmap.org/wiki' + path,
'_blank',
);
window.open('https://wiki.openstreetmap.org/wiki' + path, '_blank');
closeForm();
}

Expand All @@ -160,7 +157,9 @@ export function ArchivalNotificationBanner() {
<a
id="privlink"
className="red link f4 fw6"
href={'https://wiki.openstreetmap.org/wiki/Humanitarian_OSM_Team/Working_groups/Data_Quality_Control_and_Assurance/Tasking_Manager_Project_Gardening'}
href={
'https://wiki.openstreetmap.org/wiki/Humanitarian_OSM_Team/Working_groups/Data_Quality_Control_and_Assurance/Tasking_Manager_Project_Gardening'
}
target="_blank"
rel="noopener noreferrer"
>
Expand All @@ -171,10 +170,16 @@ export function ArchivalNotificationBanner() {
<FormattedMessage {...messages.archivalNotificationText} />
</p>
<div id="archival-notification-buttons">
<div className="white bg-red pv2 ph3 mh1 br1 dib fw6 pointer" id="archival-notification-learnmore">
<div
className="white bg-red pv2 ph3 mh1 br1 dib fw6 pointer"
id="archival-notification-learnmore"
>
<FormattedMessage {...messages.learnMore} />
</div>
<div className="white bg-red pv2 ph3 mh1 br1 dib fw6 pointer" id="archival-notification-close">
<div
className="white bg-red pv2 ph3 mh1 br1 dib fw6 pointer"
id="archival-notification-close"
>
<FormattedMessage {...messages.close} />
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/components/banner/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ export default defineMessages({
defaultMessage: 'Learn More',
},
importantNotification: {
id: 'banner.title.notification',
defaultMessage: 'Important notification for users',
id: 'banner.title.notification',
defaultMessage: 'Important notification for users',
},
archivalNotificationText: {
id: 'banner.text.archivalNotification',
defaultMessage: 'Attention: as part of the ongoing maintenance of the Tasking Manager, projects created before 2020 will be archived.',
}
defaultMessage:
'Attention: as part of the ongoing maintenance of the Tasking Manager, projects created before 2020 will be archived.',
},
});
5 changes: 3 additions & 2 deletions frontend/src/components/code.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const Code = ({ className, children }) =>
<code className={`f6 i ph1 bg-white o-80 ${className ? className : ''}`}>{ children }</code>;
export const Code = ({ className, children }) => (
<code className={`f6 i ph1 bg-white o-80 ${className ? className : ''}`}>{children}</code>
);
7 changes: 6 additions & 1 deletion frontend/src/components/deleteModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ export function DeleteModal({ id, name, type, className }: Object) {
</h3>
)}
{deleteStatus === 'failure' && (
<p>{(error && messages[`${error}Error`] && <FormattedMessage {...messages[`${error}Error`]} />) || error}</p>
<p>
{(error && messages[`${error}Error`] && (
<FormattedMessage {...messages[`${error}Error`]} />
)) ||
error}
</p>
)}
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/deleteModal/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ export default defineMessages({
},
InternalServerErrorError: {
id: 'deleteModal.status.failure.InternalServerErrorError',
defaultMessage: "Something has gone wrong on the server, but the server could not be more specific on what the exact problem is.",
defaultMessage:
'Something has gone wrong on the server, but the server could not be more specific on what the exact problem is.',
},
HasMappedTasksError: {
id: 'deleteModal.status.failure.HasMappedTasksError',
defaultMessage: "Project has mapped tasks, cannot be deleted.",
defaultMessage: 'Project has mapped tasks, cannot be deleted.',
},
cancel: {
id: 'deleteModal.button.cancel',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/header/NavLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const NavLink = ({ partial = true, ...props }) => (
/>
);

export const TopNavLink = props => {
export const TopNavLink = (props) => {
const { isActive, ...otherProps } = props;
return (
<Link getProps={isActive} {...otherProps}>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ function getMenuItensForUser(userDetails, organisations) {
{ label: messages.about, link: 'about', showAlways: true },
];
if (SERVICE_DESK) {
menuItems.push({ label: messages.support, link: SERVICE_DESK, showAlways: true, serviceDesk: true });
menuItems.push({
label: messages.support,
link: SERVICE_DESK,
showAlways: true,
serviceDesk: true,
});
}

let filteredMenuItems;
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/header/signUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ const SignupForm = ({ data, setData, step, setStep }) => {
}

/* eslint-disable-next-line */
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const re =
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (re.test(data.email) === false) {
setStep({ ...step, errMessage: <FormattedMessage {...messages.invalidEmail} /> });
return;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/homepage/testimonials/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineMessages({
ifrcCitation: {
id: 'home.testimonials.ifrc.citation',
defaultMessage:
"In the early days of the Cyclone Idai response, IFRC was looking for detailed maps to get a sense of the scale of the flooding, which were also used for search and rescue operations. Later on, we had requests to identify where certain buildings, such as health centres or hospitals, were located so our health team could assess the damage and medical needs of patients.",
'In the early days of the Cyclone Idai response, IFRC was looking for detailed maps to get a sense of the scale of the flooding, which were also used for search and rescue operations. Later on, we had requests to identify where certain buildings, such as health centres or hospitals, were located so our health team could assess the damage and medical needs of patients.',
},
ifrcBio: {
id: 'home.testimonials.ifrc.bio',
Expand Down
55 changes: 29 additions & 26 deletions frontend/src/components/projectCard/nCardPlaceholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,36 @@ import React from 'react';

import { TextBlock, MediaBlock, RectShape } from 'react-placeholder/lib/placeholders';

export const projectCardPlaceholderTemplate = (cardWidthClass = 'w-25-l') => (n, i) => (
<div className={`fl ${cardWidthClass} base-font w-50-m w-100 mb3 ph2 blue-dark mw5`} key={i}>
<div className="pv3 ph3 ba br1 b--grey-light shadow-hover bg-white">
<div className="w-50 red dib">
{' '}
<MediaBlock
rows={1}
className="show-loading-animation"
color="#DDD"
style={{ width: 60, height: 30 }}
/>{' '}
export const projectCardPlaceholderTemplate =
(cardWidthClass = 'w-25-l') =>
(n, i) =>
(
<div className={`fl ${cardWidthClass} base-font w-50-m w-100 mb3 ph2 blue-dark mw5`} key={i}>
<div className="pv3 ph3 ba br1 b--grey-light shadow-hover bg-white">
<div className="w-50 red dib">
{' '}
<MediaBlock
rows={1}
className="show-loading-animation"
color="#DDD"
style={{ width: 60, height: 30 }}
/>{' '}
</div>
<div className={`fr w-33 tc pr4 f7 ttu`}>
{' '}
<RectShape
className="show-loading-animation"
color="#DDD"
style={{ width: 60, height: 30 }}
/>{' '}
</div>
<h3 className="pb2 f5 fw6 h3 lh-title overflow-y-hidden">
<TextBlock rows={3} className="show-loading-animation" color="#CCC" />
</h3>
<TextBlock rows={4} className="show-loading-animation" color="#CCC" />
</div>
</div>
<div className={`fr w-33 tc pr4 f7 ttu`}>
{' '}
<RectShape
className="show-loading-animation"
color="#DDD"
style={{ width: 60, height: 30 }}
/>{' '}
</div>
<h3 className="pb2 f5 fw6 h3 lh-title overflow-y-hidden">
<TextBlock rows={3} className="show-loading-animation" color="#CCC" />
</h3>
<TextBlock rows={4} className="show-loading-animation" color="#CCC" />
</div>
</div>
);
);

export const nCardPlaceholders = (N, cardWidthClass = 'w-25-l') => {
return [...Array(N).keys()].map(projectCardPlaceholderTemplate(cardWidthClass));
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/projectDetail/favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { navigate } from '@reach/router';
import { useSelector } from 'react-redux';
import messages from './messages';

export const AddToFavorites = props => {
const userToken = useSelector(state => state.auth.get('token'));
export const AddToFavorites = (props) => {
const userToken = useSelector((state) => state.auth.get('token'));
const [state, dispatchToggle] = useFavProjectAPI(false, props.projectId, userToken);
const isFav = state.isFav;
const isLoading = state.isLoading;
Expand Down
29 changes: 14 additions & 15 deletions frontend/src/components/projectDetail/questionsAndComments.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const PostProjectComment = ({ projectId, updateComments }) => {
return (
<div className="w-90-ns w-100 cf pv4 bg-white center ph3">
<div className="cf w-100 flex mb3">
<CurrentUserAvatar className="w3 h3 fr ph2 br-100" />
<CurrentUserAvatar className="w3 h3 fr ph2 br-100" />
<div className="cf pt3-ns ph3 ph3-m bg-grey-light dib">
<span
role="button"
Expand All @@ -52,7 +52,7 @@ export const PostProjectComment = ({ projectId, updateComments }) => {
<FormattedMessage {...messages.preview} />
</span>
</div>
</div>
</div>
<div className={`w-100 h-100`} style={{ position: 'relative', display: 'block' }}>
<CommentInputField
comment={comment}
Expand All @@ -61,17 +61,17 @@ export const PostProjectComment = ({ projectId, updateComments }) => {
isShowPreview={isShowPreview}
isProjectDetailCommentSection={true}
/>
</div>
</div>

<div className="fl w-100 tr pt1 pr0-ns pr1 ml-auto">
<Button
onClick={() => saveCommentAsync.execute()}
className="bg-red white f5"
disabled={comment === '' || saveCommentAsync.status === 'pending'}
loading={saveCommentAsync.status === 'pending'}
>
<FormattedMessage {...messages.post} />
</Button>
<Button
onClick={() => saveCommentAsync.execute()}
className="bg-red white f5"
disabled={comment === '' || saveCommentAsync.status === 'pending'}
loading={saveCommentAsync.status === 'pending'}
>
<FormattedMessage {...messages.post} />
</Button>
</div>
<div className="cf w-100 fr tr pr2">
<MessageStatus status={saveCommentAsync.status} comment={comment} />
Expand All @@ -91,10 +91,9 @@ export const QuestionsAndComments = ({ projectId }) => {

useEffect(() => {
if (projectId && page) {
fetchLocalJSONAPI(
`projects/${projectId}/comments/?perPage=5&page=${page}`,
token,
).then((res) => setComments(res));
fetchLocalJSONAPI(`projects/${projectId}/comments/?perPage=5&page=${page}`, token).then(
(res) => setComments(res),
);
}
}, [page, projectId, token]);

Expand Down
Loading

0 comments on commit 6ad37a8

Please sign in to comment.