-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
284 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,87 @@ | ||
import * as React from 'react'; | ||
import * as React from "react"; | ||
|
||
import {TicketCheckinResult, checkin} from './CheckinClient'; | ||
import { TicketCheckinResult, checkin } from "./CheckinClient"; | ||
|
||
interface Props { | ||
endpoint: string, | ||
endpoint: string; | ||
} | ||
|
||
interface State { | ||
response: TicketCheckinResult | null, | ||
requested: boolean, | ||
requestError: string | null, | ||
response: TicketCheckinResult | null; | ||
requested: boolean; | ||
requestError: string | null; | ||
} | ||
|
||
export default class ReceptionCheckinButton extends React.Component<Props, State> { | ||
|
||
export default class ReceptionCheckinButton extends React.Component< | ||
Props, | ||
State | ||
> { | ||
constructor(props: Props) { | ||
super(props); | ||
this.state = { | ||
response: null, | ||
requested: false, | ||
requestError: null, | ||
} | ||
}; | ||
} | ||
|
||
public render() { | ||
let alertElem = null; | ||
if (this.state.response) { | ||
if (this.state.response.ok) { | ||
alertElem = <div className="alert alert-success"><b>Checked in</b></div>; | ||
alertElem = ( | ||
<div className="alert alert-success"> | ||
<b>Checked in</b> | ||
</div> | ||
); | ||
} else { | ||
const errors = this.state.response.errors || []; | ||
alertElem = <div className="alert alert-danger"> | ||
<p><b>Errors:</b></p> | ||
alertElem = ( | ||
<div className="alert alert-danger"> | ||
<p> | ||
<b>Errors:</b> | ||
</p> | ||
<ul> | ||
{errors.map((err, index) => <li key={index}>{err}</li>)} | ||
{errors.map((err, index) => ( | ||
<li key={index}>{err}</li> | ||
))} | ||
</ul> | ||
</div>; | ||
</div> | ||
); | ||
} | ||
} | ||
const errorAlert = this.state.requestError ? <div className='alert alert-danger'>Something went wrong: {this.state.requestError}</div> : null; | ||
const button = <button className='btn btn-primary btn-lg mb-2' onClick={this.onClick.bind(this)} disabled={this.state.requested}>Check In</button> | ||
return <div> | ||
{(this.state.response && this.state.response.ok) ? null: button} | ||
{errorAlert} | ||
{alertElem} | ||
</div>; | ||
const errorAlert = this.state.requestError ? ( | ||
<div className="alert alert-danger"> | ||
Something went wrong: {this.state.requestError} | ||
</div> | ||
) : null; | ||
const button = ( | ||
<button | ||
className="btn btn-primary btn-lg mb-2" | ||
onClick={this.onClick.bind(this)} | ||
disabled={this.state.requested} | ||
> | ||
Check In | ||
</button> | ||
); | ||
return ( | ||
<div> | ||
{this.state.response && this.state.response.ok ? null : button} | ||
{errorAlert} | ||
{alertElem} | ||
</div> | ||
); | ||
} | ||
|
||
private onClick(e: React.MouseEvent<HTMLButtonElement>) { | ||
this.setState({requested: true, requestError: null}); | ||
checkin(this.props.endpoint).then((resp) => { | ||
this.setState({response: resp, requested: false}); | ||
}).catch((e) => { | ||
this.setState({requestError: e.toString(), requested: false}); | ||
throw e; | ||
}); | ||
this.setState({ requested: true, requestError: null }); | ||
checkin(this.props.endpoint) | ||
.then((resp) => { | ||
this.setState({ response: resp, requested: false }); | ||
}) | ||
.catch((e) => { | ||
this.setState({ requestError: e.toString(), requested: false }); | ||
throw e; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,137 @@ | ||
import * as React from 'react'; | ||
import * as React from "react"; | ||
|
||
import {TicketCheckinResult, checkin} from './CheckinClient'; | ||
import { TicketCheckinResult, checkin } from "./CheckinClient"; | ||
|
||
interface Props { | ||
endpoint: string, | ||
endpoint: string; | ||
} | ||
|
||
interface State { | ||
response: TicketCheckinResult | null, | ||
requested: boolean, | ||
requestError: string | null, | ||
code: string, | ||
response: TicketCheckinResult | null; | ||
requested: boolean; | ||
requestError: string | null; | ||
code: string; | ||
} | ||
|
||
export default class ReceptionCheckinForm extends React.Component<Props, State> { | ||
export default class ReceptionCheckinForm extends React.Component< | ||
Props, | ||
State | ||
> { | ||
private inputRef: React.RefObject<HTMLInputElement>; | ||
constructor(props: Props) { | ||
super(props); | ||
this.state = { | ||
response: null, | ||
requested: false, | ||
requestError: null, | ||
code: '', | ||
code: "", | ||
}; | ||
this.inputRef = React.createRef(); | ||
} | ||
|
||
public render() { | ||
return <div> | ||
{this.renderForm()} | ||
{this.renderTicket()} | ||
{this.renderResult()} | ||
</div>; | ||
return ( | ||
<div> | ||
{this.renderForm()} | ||
{this.renderTicket()} | ||
{this.renderResult()} | ||
</div> | ||
); | ||
} | ||
|
||
public renderForm() { | ||
return <div className='mb-3'> | ||
<form action="#" onSubmit={this.onSubmit.bind(this)} className='form-inline'> | ||
<fieldset disabled={this.state.requested} > | ||
<input value={this.state.code} onChange={this.onChange.bind(this)} ref={this.inputRef} className='form-control' placeholder='Code, or URL' /> | ||
<button className='btn btn-primary'>Check In</button> | ||
</fieldset> | ||
</form> | ||
</div>; | ||
return ( | ||
<div className="mb-3"> | ||
<form | ||
action="#" | ||
onSubmit={this.onSubmit.bind(this)} | ||
className="form-inline" | ||
> | ||
<fieldset disabled={this.state.requested}> | ||
<input | ||
value={this.state.code} | ||
onChange={this.onChange.bind(this)} | ||
ref={this.inputRef} | ||
className="form-control" | ||
placeholder="Code, or URL" | ||
/> | ||
<button className="btn btn-primary">Check In</button> | ||
</fieldset> | ||
</form> | ||
</div> | ||
); | ||
} | ||
|
||
public renderTicket() { | ||
if (!(this.state.response && this.state.response.ticket)) return null; | ||
const ticket = this.state.response.ticket; | ||
return <div className='card mt-2'> | ||
<div className='card-body'> | ||
<div className='d-flex justify-content-between'> | ||
<div> | ||
<code>{ticket.code}</code>-<code>{ticket.id}</code> | ||
return ( | ||
<div className="card mt-2"> | ||
<div className="card-body"> | ||
<div className="d-flex justify-content-between"> | ||
<div> | ||
<code>{ticket.code}</code>-<code>{ticket.id}</code> | ||
</div> | ||
<div>{ticket.conference}</div> | ||
</div> | ||
<div className="text-center my-2"> | ||
<p style={{ fontSize: "26pt" }}> | ||
<strong>{ticket.name}</strong> | ||
</p> | ||
<small style={{ fontSize: "18pt" }}>{ticket.sponsor}</small> | ||
<p style={{ fontSize: "14pt" }}> | ||
<span className="badge badge-info">{ticket.kind}</span> | ||
</p> | ||
</div> | ||
<div>{ticket.conference}</div> | ||
</div> | ||
<div className='text-center my-2'> | ||
<p style={{fontSize: '26pt'}}><strong>{ticket.name}</strong></p> | ||
<small style={{fontSize: '18pt'}}>{ticket.sponsor}</small> | ||
<p style={{fontSize: '14pt'}}><span className='badge badge-info'>{ticket.kind}</span></p> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
public renderResult() { | ||
if (this.state.response) { | ||
if (this.state.response.ok) { | ||
return <div className="alert alert-success"><b>Checked in</b></div>; | ||
return ( | ||
<div className="alert alert-success"> | ||
<b>Checked in</b> | ||
</div> | ||
); | ||
} else { | ||
const errors = this.state.response.errors || []; | ||
return <div className="alert alert-danger"> | ||
<p><b>Errors:</b></p> | ||
return ( | ||
<div className="alert alert-danger"> | ||
<p> | ||
<b>Errors:</b> | ||
</p> | ||
<ul> | ||
{errors.map((err, index) => <li key={index}>{err}</li>)} | ||
{errors.map((err, index) => ( | ||
<li key={index}>{err}</li> | ||
))} | ||
</ul> | ||
</div>; | ||
</div> | ||
); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
private onSubmit(e: React.FormEvent<HTMLFormElement>) { | ||
e.preventDefault(); | ||
this.setState({requested: true, requestError: null}); | ||
const code = this.state.code.replace(/^.+\//, ''); | ||
checkin(`${this.props.endpoint}/${code}`).then((resp) => { | ||
this.setState({response: resp, requested: false, code: ''}); | ||
if (this.inputRef.current) this.inputRef.current.focus(); | ||
}).catch((e) => { | ||
this.setState({requestError: e.toString(), requested: false}); | ||
if (this.inputRef.current) this.inputRef.current.focus(); | ||
throw e; | ||
}); | ||
this.setState({ requested: true, requestError: null }); | ||
const code = this.state.code.replace(/^.+\//, ""); | ||
checkin(`${this.props.endpoint}/${code}`) | ||
.then((resp) => { | ||
this.setState({ response: resp, requested: false, code: "" }); | ||
if (this.inputRef.current) this.inputRef.current.focus(); | ||
}) | ||
.catch((e) => { | ||
this.setState({ requestError: e.toString(), requested: false }); | ||
if (this.inputRef.current) this.inputRef.current.focus(); | ||
throw e; | ||
}); | ||
} | ||
|
||
private onChange(e: React.ChangeEvent<HTMLInputElement>) { | ||
this.setState({code: e.target.value}); | ||
this.setState({ code: e.target.value }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
document.querySelectorAll('.booth_assignment_form').forEach((topElem) => { | ||
const checkBoxes = topElem.querySelectorAll('input[type=checkbox]') as NodeListOf<HTMLInputElement>; | ||
topElem.querySelectorAll('button.booth_assignment_select_all_button').forEach((button) => { | ||
button.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
checkBoxes.forEach((checkbox) => checkbox.checked = true); | ||
document.addEventListener("DOMContentLoaded", () => { | ||
document.querySelectorAll(".booth_assignment_form").forEach((topElem) => { | ||
const checkBoxes = topElem.querySelectorAll( | ||
"input[type=checkbox]", | ||
) as NodeListOf<HTMLInputElement>; | ||
topElem | ||
.querySelectorAll("button.booth_assignment_select_all_button") | ||
.forEach((button) => { | ||
button.addEventListener("click", (e) => { | ||
e.preventDefault(); | ||
checkBoxes.forEach((checkbox) => (checkbox.checked = true)); | ||
}); | ||
}); | ||
}); | ||
topElem.querySelectorAll('button.booth_assignment_select_none_button').forEach((button) => { | ||
button.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
checkBoxes.forEach((checkbox) => checkbox.checked = false); | ||
topElem | ||
.querySelectorAll("button.booth_assignment_select_none_button") | ||
.forEach((button) => { | ||
button.addEventListener("click", (e) => { | ||
e.preventDefault(); | ||
checkBoxes.forEach((checkbox) => (checkbox.checked = false)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
document.querySelectorAll('.broadcast_new_recipient_fields').forEach((formElem) => { | ||
formElem.querySelectorAll('.broadcast_new_recipient_fields_selector').forEach((elem) => { | ||
const select = elem as HTMLSelectElement; | ||
document.addEventListener("DOMContentLoaded", () => { | ||
document | ||
.querySelectorAll(".broadcast_new_recipient_fields") | ||
.forEach((formElem) => { | ||
formElem | ||
.querySelectorAll(".broadcast_new_recipient_fields_selector") | ||
.forEach((elem) => { | ||
const select = elem as HTMLSelectElement; | ||
|
||
const handleChange = (e?: Event) => { | ||
const fieldsets = formElem.querySelectorAll(`fieldset`); | ||
const fieldset = formElem.querySelector(`.broadcast_new_recipient_fields_kind__${select.value}`) as HTMLFieldSetElement; | ||
if (fieldset) { | ||
fieldsets.forEach((fs) => { | ||
fs.classList.add('d-none'); | ||
fs.disabled = true; | ||
}); | ||
fieldset.classList.remove('d-none'); | ||
fieldset.disabled = false; | ||
} | ||
} | ||
select.addEventListener('change', handleChange); | ||
handleChange(); | ||
const handleChange = (e?: Event) => { | ||
const fieldsets = formElem.querySelectorAll(`fieldset`); | ||
const fieldset = formElem.querySelector( | ||
`.broadcast_new_recipient_fields_kind__${select.value}`, | ||
) as HTMLFieldSetElement; | ||
if (fieldset) { | ||
fieldsets.forEach((fs) => { | ||
fs.classList.add("d-none"); | ||
fs.disabled = true; | ||
}); | ||
fieldset.classList.remove("d-none"); | ||
fieldset.disabled = false; | ||
} | ||
}; | ||
select.addEventListener("change", handleChange); | ||
handleChange(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const SENTRY_DSN = document.querySelector<HTMLMetaElement>( | ||
'meta[name="rkto:sentry-dsn"]' | ||
'meta[name="rkto:sentry-dsn"]', | ||
)?.content; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
import * as Sentry from "@sentry/browser"; | ||
|
||
if (window.SENTRY_DSN) { | ||
Sentry.init({dsn: window.SENTRY_DSN}); | ||
Sentry.init({ dsn: window.SENTRY_DSN }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
|
||
import ReceptionCheckinButton from './ReceptionCheckinButton'; | ||
import ReceptionCheckinButton from "./ReceptionCheckinButton"; | ||
|
||
document.addEventListener("DOMContentLoaded", () => { | ||
document.querySelectorAll('.checkin_button').forEach((target) => { | ||
document.querySelectorAll(".checkin_button").forEach((target) => { | ||
const elem = target as HTMLDivElement; | ||
const endpoint = elem.dataset.ticketUrl; | ||
if (!endpoint) return; | ||
const component = ReactDOM.render( | ||
<ReceptionCheckinButton | ||
endpoint={endpoint} | ||
/>, | ||
target) as unknown as ReceptionCheckinButton; | ||
<ReceptionCheckinButton endpoint={endpoint} />, | ||
target, | ||
) as unknown as ReceptionCheckinButton; | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
|
||
import ReceptionCheckinForm from './ReceptionCheckinForm'; | ||
import ReceptionCheckinForm from "./ReceptionCheckinForm"; | ||
|
||
document.addEventListener("DOMContentLoaded", () => { | ||
document.querySelectorAll('.checkin_form').forEach((target) => { | ||
document.querySelectorAll(".checkin_form").forEach((target) => { | ||
const elem = target as HTMLDivElement; | ||
const endpoint = elem.dataset.endpoint; | ||
if (!endpoint) return; | ||
const component = ReactDOM.render( | ||
<ReceptionCheckinForm | ||
endpoint={endpoint} | ||
/>, | ||
target) as unknown as ReceptionCheckinForm; | ||
<ReceptionCheckinForm endpoint={endpoint} />, | ||
target, | ||
) as unknown as ReceptionCheckinForm; | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters