Throw confetti from verify button location.
This commit is contained in:
parent
54a1033eeb
commit
ea9bbc81a6
@ -1,63 +1,75 @@
|
|||||||
import React, { Fragment } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
import { VerifyIcon } from '../../components/icons';
|
import { VerifyIcon } from '../../components/icons';
|
||||||
|
|
||||||
import './verification.css';
|
import './verification.css';
|
||||||
|
|
||||||
interface VerificationProps {
|
interface VerificationProps {
|
||||||
slug: string;
|
slug: string;
|
||||||
onVerify: (slug: string, verify: boolean) => void;
|
onVerify: (slug: string, verify: boolean, x: number, y: number) => void;
|
||||||
user_verified: boolean;
|
user_verified: boolean;
|
||||||
user_verified_as: string;
|
user_verified_as: string;
|
||||||
verified_count: number;
|
verified_count: number;
|
||||||
allow_verify: boolean;
|
allow_verify: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Verification: React.FunctionComponent<VerificationProps> = (props) => {
|
|
||||||
let user_verified_as = props.user_verified_as;
|
class Verification extends Component<VerificationProps, any> {
|
||||||
if (typeof user_verified_as === 'boolean') {
|
constructor(props) {
|
||||||
user_verified_as = user_verified_as? 'Yes': 'No';
|
super(props);
|
||||||
|
this.handleClick = this.handleClick.bind(this)
|
||||||
}
|
}
|
||||||
return (
|
|
||||||
<div className="verification-container">
|
handleClick(verify) {
|
||||||
<span
|
return (e) => {
|
||||||
className="verification-status"
|
e.preventDefault();
|
||||||
title={`Verified by ${props.verified_count} ${(props.verified_count == 1)? "person": "people"}`}
|
const x = e.clientX / document.body.clientWidth;
|
||||||
>
|
const y = e.clientY / document.body.clientHeight;
|
||||||
<VerifyIcon />
|
this.props.onVerify(this.props.slug, verify, x, y);
|
||||||
{props.verified_count || 0}
|
|
||||||
</span>
|
|
||||||
{
|
|
||||||
props.user_verified?
|
|
||||||
<Fragment>
|
|
||||||
Verified as
|
|
||||||
"<span>{user_verified_as}</span>"
|
|
||||||
<button
|
|
||||||
className="btn btn-danger"
|
|
||||||
title="Remove my verification"
|
|
||||||
disabled={!props.allow_verify}
|
|
||||||
onClick={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
props.onVerify(props.slug, false)
|
|
||||||
}}>
|
|
||||||
Remove
|
|
||||||
</button>
|
|
||||||
</Fragment>
|
|
||||||
:
|
|
||||||
<Fragment>
|
|
||||||
<button
|
|
||||||
className="btn btn-success"
|
|
||||||
title="Confirm that the current value is correct"
|
|
||||||
disabled={!props.allow_verify}
|
|
||||||
onClick={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
props.onVerify(props.slug, true)
|
|
||||||
}}>
|
|
||||||
Verify
|
|
||||||
</button>
|
|
||||||
</Fragment>
|
|
||||||
}
|
}
|
||||||
</div>
|
}
|
||||||
);
|
|
||||||
|
render() {
|
||||||
|
const props = this.props;
|
||||||
|
let user_verified_as = props.user_verified_as;
|
||||||
|
if (typeof user_verified_as === 'boolean') {
|
||||||
|
user_verified_as = user_verified_as? 'Yes': 'No';
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className="verification-container">
|
||||||
|
<span
|
||||||
|
className="verification-status"
|
||||||
|
title={`Verified by ${props.verified_count} ${(props.verified_count == 1)? "person": "people"}`}
|
||||||
|
>
|
||||||
|
<VerifyIcon />
|
||||||
|
{props.verified_count || 0}
|
||||||
|
</span>
|
||||||
|
{
|
||||||
|
props.user_verified?
|
||||||
|
<Fragment>
|
||||||
|
Verified as
|
||||||
|
"<span>{user_verified_as}</span>"
|
||||||
|
<button
|
||||||
|
className="btn btn-danger"
|
||||||
|
title="Remove my verification"
|
||||||
|
disabled={!props.allow_verify}
|
||||||
|
onClick={this.handleClick(false)}>
|
||||||
|
Remove
|
||||||
|
</button>
|
||||||
|
</Fragment>
|
||||||
|
:
|
||||||
|
<Fragment>
|
||||||
|
<button
|
||||||
|
className="btn btn-success"
|
||||||
|
title="Confirm that the current value is correct"
|
||||||
|
disabled={!props.allow_verify}
|
||||||
|
onClick={this.handleClick(true)}>
|
||||||
|
Verify
|
||||||
|
</button>
|
||||||
|
</Fragment>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Verification;
|
export default Verification;
|
@ -14,7 +14,7 @@ interface YearDataEntryProps {
|
|||||||
mode?: 'view' | 'edit' | 'multi-edit';
|
mode?: 'view' | 'edit' | 'multi-edit';
|
||||||
onChange?: (key: string, value: any) => void;
|
onChange?: (key: string, value: any) => void;
|
||||||
|
|
||||||
onVerify: (slug: string, verify: boolean) => void;
|
onVerify: (slug: string, verify: boolean, x: number, y: number) => void;
|
||||||
user_verified: boolean;
|
user_verified: boolean;
|
||||||
user_verified_as: string;
|
user_verified_as: string;
|
||||||
verified_count: number;
|
verified_count: number;
|
||||||
|
@ -202,7 +202,7 @@ const withCopyEdit = (WrappedComponent: React.ComponentType<CategoryViewProps>)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleVerify(slug: string, verify: boolean) {
|
async handleVerify(slug: string, verify: boolean, x: number, y: number) {
|
||||||
const verifyPatch = {};
|
const verifyPatch = {};
|
||||||
if (verify) {
|
if (verify) {
|
||||||
verifyPatch[slug] = this.props.building[slug];
|
verifyPatch[slug] = this.props.building[slug];
|
||||||
@ -220,7 +220,12 @@ const withCopyEdit = (WrappedComponent: React.ComponentType<CategoryViewProps>)
|
|||||||
this.setState({error: data.error});
|
this.setState({error: data.error});
|
||||||
} else {
|
} else {
|
||||||
if (verify) {
|
if (verify) {
|
||||||
Confetti({zIndex: 2000});
|
Confetti({
|
||||||
|
angle: 60,
|
||||||
|
disableForReducedMotion: true,
|
||||||
|
origin: {x, y},
|
||||||
|
zIndex: 2000
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.props.selectBuilding(this.props.building);
|
this.props.selectBuilding(this.props.building);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ interface CategoryViewProps {
|
|||||||
copy: CopyProps;
|
copy: CopyProps;
|
||||||
onChange: (key: string, value: any) => void;
|
onChange: (key: string, value: any) => void;
|
||||||
onLike: (like: boolean) => void;
|
onLike: (like: boolean) => void;
|
||||||
onVerify: (slug: string, verify: boolean) => void;
|
onVerify: (slug: string, verify: boolean, x: number, y: number) => void;
|
||||||
user_verified: any;
|
user_verified: any;
|
||||||
user?: any;
|
user?: any;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user