Skip to content
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

added qr code to user profile when user is confirmed #184

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/assets/scss/components/_user-profile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@
text-align: left;
font-family: $header-font-family;
font-size: 1.2rem;
display: inline-block;

@include media-breakpoint-up(md) {
text-align: right;
}
}

&__status {
margin-right: 1rem;

&--confirmed {
color: $default-green;
}
Expand Down
38 changes: 30 additions & 8 deletions src/client/pages/UserPage/components/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import React from 'react';
import { Field, reduxForm, InjectedFormProps, WrappedFieldProps } from 'redux-form';
import { CustomFieldProps } from '~/components/Fields';
import FileField from '~/components/FileField';
import { generateQRCodeURL } from '@Shared/QRCodes';
import FA from 'react-fontawesome';

export interface UserProfileFormData {
gender: string;
Expand Down Expand Up @@ -111,6 +113,24 @@ class UserProfile extends React.Component<Props> {
);
}

/**
* Renders the QR code for the user if their status is "Confirmed".
* @param {Object} user The user to render for.
* @returns {Component}
*/
renderUserQRCode = (user: TESCUser) => {
if (user.status !== UserStatus.Confirmed) {
return <span />;
}

return <a className={`btn px-2 mx-1 w-auto rounded-button rounded-button--small`}
href={generateQRCodeURL(user)}
target="_blank" >
<FA name="qrcode" className="mr-2" />
QR Code
</a>;
}

/**
* Renders the bussing status for the current user.
* @param {Object} user The current user to render for.
Expand Down Expand Up @@ -349,15 +369,8 @@ class UserProfile extends React.Component<Props> {
<form className="user-profile" onSubmit={handleSubmit}>
<div className="user-profile__header">
<div className="user-profile__hello row">
<div
className={`order-1 order-md-2 col-md-12 col-lg-4
user-profile__status-box`}
>
{this.renderUserBussing(user)}
{this.renderUserStatus(user.status)}
</div>

<div className="order-2 order-md-1 col-md-12 col-lg-8">
<div className="order-1 order-md-1 col-md-12 col-lg-6">
<h1>Your {' '}
<a
href={user.event.homepage}
Expand All @@ -370,6 +383,15 @@ class UserProfile extends React.Component<Props> {
{' '} Application</h1>
<h5 className={`pt-3 ${tPT ? 'd-block' : 'd-none'}`}>{tPT}</h5>
</div>

<div
className={`order-2 order-md-2 col-md-12 col-lg-6
user-profile__status-box`}
>
{this.renderUserBussing(user)}
{this.renderUserStatus(user.status)}
{this.renderUserQRCode(user)}
</div>
</div>
</div>
<div
Expand Down