components#CardContent JavaScript Examples
The following examples show how to use
components#CardContent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: wizard.jsx From apps with GNU Affero General Public License v3.0 | 6 votes |
Hi = withSettings(({ settings }) => (
<React.Fragment>
<CardContent>
<p>
<T
t={t}
k="wizard.hi"
link={
<A
key="letUsKnow"
external
href={settings.get('supportEmail')}
>
<T t={t} k="wizard.letUsKnow" key="letUsKnow" />
</A>
}
/>
</p>
</CardContent>
<CardFooter>
<Button type="success" href={`/provider/setup/enter-provider-data`}>
<T t={t} k="wizard.continue" />
</Button>
</CardFooter>
</React.Fragment>
))
Example #2
Source File: wizard.jsx From apps with GNU Affero General Public License v3.0 | 6 votes |
Hi = withSettings(({ settings }) => (
<React.Fragment>
<CardContent>
<p>
<T
t={t}
k="wizard.hi"
link={
<A
key="letUsKnow"
external
href={settings.get('supportEmail')}
>
<T t={t} k="wizard.letUsKnow" key="letUsKnow" />
</A>
}
/>
</p>
</CardContent>
<CardFooter>
<Button type="success" href={`/user/setup/enter-contact-data`}>
<T t={t} k="wizard.continue" />
</Button>
</CardFooter>
</React.Fragment>
))
Example #3
Source File: summary-box.jsx From apps with GNU Affero General Public License v3.0 | 6 votes |
SummaryBox = ({ open, booked, active }) => (
<Card className="kip-is-fullheight kip-is-fullwidth kip-summary-box" flex>
<CardHeader>
<h2>
<T t={t} k="summary" />
</h2>
</CardHeader>
<CardContent>
<p className="kip-summary-box-number">
<span>{formatNumbers(open)}</span>
<T t={t} k="open" />
</p>
<p className="kip-summary-box-number">
<span>{formatNumbers(booked)}</span>
<T t={t} k="booked" />
</p>
<p className="kip-summary-box-number">
<span>{formatNumbers(active)}</span>
<T t={t} k="active" />
</p>
</CardContent>
</Card>
)
Example #4
Source File: appointments.jsx From apps with GNU Affero General Public License v3.0 | 5 votes |
NoInvitations = ({ tokenData }) => {
let createdAt;
if (tokenData.createdAt !== undefined)
createdAt = new Date(tokenData.createdAt);
let content;
// in the first 10 minutes since the creation of the token we show a 'please wait'
// message, as it can take some time for appointments to show up...
if (
createdAt !== undefined &&
new Date(createdAt.getTime() + 1000 * 60 * 10) > new Date()
) {
content = (
<F>
<Message type="success">
<T t={t} k="no-invitations.please-wait" />
</Message>
</F>
);
} else {
content = (
<F>
<Message type="warning">
<T t={t} k="no-invitations.notice" />
</Message>
</F>
);
}
return (
<F>
<CardContent>
<div className="kip-no-invitations">{content}</div>
</CardContent>
<Message type="info">
<ButtonIcon icon="circle-notch fa-spin" />
<T t={t} k="no-invitations.update-notice" />
</Message>
</F>
);
}
Example #5
Source File: verify.jsx From apps with GNU Affero General Public License v3.0 | 5 votes |
Verify = withSettings(
withActions(({ settings, contactData, contactDataAction }) => {
const [initialized, setInitialized] = useState(false);
useEffect(() => {
if (initialized) return;
contactDataAction();
setInitialized(true);
});
const render = () => (
<React.Fragment>
<CardContent>
<p className="kip-verify-notice">
<T
t={t}
k="verify.text"
link={
<A
key="letUsKnow"
external
href={settings.get('supportEmail')}
>
<T
t={t}
k="wizard.letUsKnow"
key="letUsKnow"
/>
</A>
}
/>
</p>
<div className="kip-contact-data-box">
<ul>
<li>
<span>
<T t={t} k="contact-data.email.label" />
</span>{' '}
{contactData.data.email || (
<T t={t} k="contact-data.not-given" />
)}
</li>
</ul>
</div>
<div className="kip-contact-data-links">
<A
className="bulma-button bulma-is-small"
href="/user/setup/enter-contact-data"
>
<T t={t} k="contact-data.change" />
</A>
</div>
</CardContent>
<CardFooter>
<Button type="success" href={`/user/setup/finalize`}>
<T t={t} k="wizard.continue" />
</Button>
</CardFooter>
</React.Fragment>
);
return <WithLoader resources={[contactData]} renderLoaded={render} />;
}, [])
)
Example #6
Source File: stats.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
Stats = () => {
const mediator = useMediator();
useEffectOnce(() => {
const params = {
filter: { zipCode: null },
id: 'queues',
type: 'hour',
from: todayPlusN(-1).toISOString(),
to: todayPlusN(1).toISOString(),
};
mediator.stats().get(params);
});
const renderLoaded = () => {
const stats = mediator.stats().result();
const summary = prepareOverallStats(stats);
let content;
if (summary.show === 0) {
content = (
<div className="bulma-column bulma-is-fullwidth-desktop">
<Card size="fullwidth">
<Message type="warning">
<T t={t} k="noData" />
</Message>
</Card>
</div>
);
} else {
content = (
<React.Fragment>
<div className="bulma-column bulma-is-full-desktop">
<Card size="fullwidth" flex>
<CardContent>
<T
key="span"
t={t}
k="dateSpan"
from={
<strong key="s1">
{new Date(
summary.from
).toLocaleString('en-US', opts)}
</strong>
}
to={
<strong key="s2">
{new Date(
summary.to
).toLocaleString('en-US', opts)}
</strong>
}
/>
</CardContent>
</Card>
</div>
<div className="bulma-column bulma-is-one-quarter-desktop">
<SummaryBox
open={summary.open}
booked={summary.booked}
active={summary.active}
/>
</div>
<div className="bulma-column bulma-is-three-quarters-desktop bulma-is-flex">
<Card size="fullwidth" flex>
<CardHeader>
<h2>
<T t={t} k="bookingRate" />
</h2>
</CardHeader>
<CardContent className="kip-cm-overview">
<BarChart
hash={stats.hash}
data={prepareHourlyStats(stats)}
/>
</CardContent>
</Card>
</div>
</React.Fragment>
);
}
return (
<CardContent>
<div className="bulma-columns bulma-is-multiline bulma-is-desktop">
{content}
</div>
</CardContent>
);
};
return (
<WithLoader
resources={[mediator.stats().result()]}
renderLoaded={renderLoaded}
/>
);
}
Example #7
Source File: schedule.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
Schedule = ({ action, secondaryAction, id, route }) => {
const [view, setView] = useState('calendar');
const [lastUpdated, setLastUpdated] = useState(new Date().toLocaleString());
const provider = useProvider();
let startDate;
if (action !== undefined) {
const result = /^(\d{4})-(\d{2})-(\d{2})$/.exec(action);
if (result) {
const [, year, month, day] = result;
startDate = getMonday(
new Date(Number(year), Number(month) - 1, Number(day))
);
}
}
if (startDate === undefined)
startDate = getMonday(new Date().setHours(0, 0, 0, 0));
useEffectOnce(async () => {
const endDate = new Date(startDate);
endDate.setUTCDate(endDate.getUTCDate() + 7);
// we load all the necessary data
const response = await provider
.appointments()
.get({ from: startDate.toISOString(), to: endDate.toISOString() });
console.log(response);
});
if (action === undefined) {
action = formatDate(startDate);
}
const dateString = formatDate(startDate);
const render = () => {
let newAppointmentModal;
let content;
const appointments = provider.appointments().result().data;
switch (view) {
case 'calendar':
content = (
<WeekCalendar
startDate={startDate}
action={action}
secondaryAction={secondaryAction}
id={id}
appointments={appointments}
/>
);
break;
case 'booking-list':
content = (
<AppointmentsList
startDate={startDate}
id={id}
action={action}
secondaryAction={secondaryAction}
appointments={appointments}
/>
);
break;
}
if (secondaryAction === 'new' || secondaryAction === 'edit')
newAppointmentModal = (
<NewAppointment
route={route}
appointments={appointments}
action={action}
id={id}
/>
);
return (
<div className="kip-schedule">
<CardContent>
<div className="kip-non-printable">
{newAppointmentModal}
<Button href={`/provider/schedule/${dateString}/new`}>
<T t={t} k="schedule.appointment.add" />
</Button>
<DropdownMenu
title={
<>
<Icon icon="calendar" />{' '}
<T t={t} k={`schedule.${view}`} />
</>
}
>
<DropdownMenuItem
icon="calendar"
onClick={() => setView('calendar')}
>
<T t={t} k={`schedule.calendar`} />
</DropdownMenuItem>
<DropdownMenuItem
icon="list"
onClick={() => setView('booking-list')}
>
<T t={t} k={`schedule.booking-list`} />
</DropdownMenuItem>
</DropdownMenu>
<hr />
</div>
{content}
</CardContent>
<Message type="info" waiting>
<T t={t} k="schedule.updating" lastUpdated={lastUpdated} />
</Message>
</div>
);
};
// we wait until all resources have been loaded before we display the form
return (
<WithLoader
resources={[provider.appointments().result()]}
renderLoaded={render}
/>
);
}
Example #8
Source File: settings.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
Settings = withActions(
withRouter(
withSettings(
({
action,
type,
settings,
keys,
keysAction,
keyPairs,
keyPairsAction,
providerSecret,
providerSecretAction,
backupData,
backupDataAction,
providerData,
providerDataAction,
verifiedProviderData,
verifiedProviderDataAction,
router,
}) => {
const [deleting, setDeleting] = useState(false);
const [loggingOut, setLoggingOut] = useState(false);
const [initialized, setInitialized] = useState(false);
const [view, setView] = useState('verified');
// we load all the resources we need
useEffect(() => {
if (initialized) return;
keysAction();
verifiedProviderDataAction();
providerDataAction();
setInitialized(true);
});
let modal;
const title = settings.get('title').toLowerCase();
const cancel = () => {
router.navigateToUrl('/provider/settings');
};
const deleteData = () => {
setDeleting(true);
const backend = settings.get('backend');
backend.local.deleteAll('provider::');
setDeleting(false);
router.navigateToUrl('/provider/deleted');
};
const logOut = () => {
setLoggingOut(true);
const kpa = keyPairsAction('logoutKeyPairs');
kpa.then((kp) => {
const psa = providerSecretAction(
undefined,
'logoutProviderSecret'
);
psa.then((ps) => {
// we give the backup data action a different name to avoid it being rejected
// in case there's already a backup in progress... It will still be queued
// up to ensure no conflicts can occur.
const ba = backupDataAction(
kp.data,
ps.data,
'logout'
);
ba.then(() => {
const backend = settings.get('backend');
backend.local.deleteAll('provider::');
router.navigateToUrl('/provider/logged-out');
});
ba.catch(() => setLoggingOut(false));
});
psa.catch(() => setLoggingOut(false));
});
kpa.catch(() => setLoggingOut(false));
};
if (action === 'backup') {
modal = (
<Modal
onClose={cancel}
save="Sicherungsdatei herunterladen"
title={<T t={t} k="backup-modal.title" />}
onCancel={cancel}
cancel={<T t={t} k="backup-modal.close" />}
saveType="success"
>
<p>
<T t={t} k="backup-modal.text" />
</p>
<hr />
<DataSecret
secret={providerSecret.data}
embedded={true}
hideNotice={true}
/>
<Button
style={{ marginRight: '1em' }}
type="success"
onClick={() =>
copyToClipboard(providerSecret.data)
}
>
Datenschlüssel kopieren
</Button>
<BackupDataLink
downloadText={
<T t={t} k="backup-modal.download-backup" />
}
onSuccess={cancel}
/>
</Modal>
);
} else if (action === 'delete') {
modal = (
<Modal
onClose={cancel}
save={<T t={t} k="delete" />}
disabled={deleting}
waiting={deleting}
title={<T t={t} k="delete-modal.title" />}
onCancel={cancel}
onSave={deleteData}
saveType="danger"
>
<p>
<T
t={t}
k={
deleting
? 'delete-modal.deleting-text'
: 'delete-modal.text'
}
/>
</p>
</Modal>
);
} else if (action === 'logout') {
modal = (
<Modal
onClose={cancel}
save={<T t={t} k="log-out" />}
disabled={loggingOut}
waiting={loggingOut}
title={<T t={t} k="log-out-modal.title" />}
onCancel={cancel}
onSave={logOut}
saveType="warning"
>
<p>
<T
t={t}
k={
loggingOut
? 'log-out-modal.logging-out'
: 'log-out-modal.text'
}
/>
</p>
<hr />
<DataSecret
secret={providerSecret.data}
embedded={true}
hideNotice={true}
/>
<Button
style={{ marginRight: '1em' }}
type="success"
onClick={() =>
copyToClipboard(providerSecret.data)
}
>
Datenschlüssel kopieren
</Button>
<BackupDataLink
downloadText={
<T t={t} k="backup-modal.download-backup" />
}
/>
</Modal>
);
}
const render = () => {
return (
<div className="kip-provider-settings">
{modal}
<CardContent>
<h2>
<T t={t} k="provider-data.title" />
</h2>
<p style={{ marginBottom: '1em' }}>
<T
t={t}
k="provider-data.verified-vs-unverifired-desc"
/>
</p>
<DropdownMenu
title={
<F>
<Icon icon="calendar" />{' '}
<T t={t} k={`settings.${view}`} />
</F>
}
>
<DropdownMenuItem
icon="calendar"
onClick={() => setView('verified')}
>
<T t={t} k={`settings.verified`} />
</DropdownMenuItem>
<DropdownMenuItem
icon="list"
onClick={() => setView('local')}
>
<T t={t} k={`settings.local`} />
</DropdownMenuItem>
</DropdownMenu>
<ProviderData
providerData={
view === 'verified'
? verifiedProviderData
: providerData
}
verified={view === 'verified'}
/>
</CardContent>
<CardFooter>
<div className="kip-buttons">
<Button
type="success"
href="/provider/settings/backup"
>
<T t={t} k="backup" />
</Button>
<Button
type="warning"
href="/provider/settings/logout"
>
<T t={t} k="log-out" />
</Button>
{false && (
<Button
type="danger"
href="/provider/settings/delete"
>
<T t={t} k="delete" />
</Button>
)}
</div>
</CardFooter>
</div>
);
};
// we wait until all resources have been loaded before we display the form
return (
<WithLoader
resources={[
keyPairs,
providerData,
verifiedProviderData,
]}
renderLoaded={render}
/>
);
}
)
),
[]
)
Example #9
Source File: provider-data.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
BaseProviderData = ({
embedded,
form: { set, data, error, valid, reset },
}) => {
const [modified, setModified] = useState(false);
const router = useRouter();
const provider = useProvider();
const onSubmit = () => {
if (!valid) return;
provider.data = data;
// we redirect to the 'verify' step
router.navigateToUrl(`/provider/setup/verify`);
};
useEffectOnce(() => {
reset(provider.data || {});
setModified(false);
});
const setAndMarkModified = (key, value) => {
setModified(true);
set(key, value);
};
const controls = (
<React.Fragment>
<ErrorFor error={error} field="name" />
<RetractingLabelInput
value={data.name || ''}
onChange={(value) => setAndMarkModified('name', value)}
label={<T t={t} k="provider-data.name" />}
/>
<ErrorFor error={error} field="street" />
<RetractingLabelInput
value={data.street || ''}
onChange={(value) => setAndMarkModified('street', value)}
label={<T t={t} k="provider-data.street" />}
/>
<ErrorFor error={error} field="zipCode" />
<RetractingLabelInput
value={data.zipCode || ''}
onChange={(value) => setAndMarkModified('zipCode', value)}
label={<T t={t} k="provider-data.zip-code" />}
/>
<ErrorFor error={error} field="city" />
<RetractingLabelInput
value={data.city || ''}
onChange={(value) => setAndMarkModified('city', value)}
label={<T t={t} k="provider-data.city" />}
/>
<ErrorFor error={error} field="website" />
<RetractingLabelInput
value={data.website || ''}
onChange={(value) => setAndMarkModified('website', value)}
label={<T t={t} k="provider-data.website" />}
/>
<ErrorFor error={error} field="description" />
<label htmlFor="description">
<T t={t} k="provider-data.description" />
</label>
<textarea
id="description"
className="bulma-textarea"
value={data.description || ''}
onChange={(e) =>
setAndMarkModified('description', e.target.value)
}
/>
<h3>
<T t={t} k="provider-data.for-mediator" />
</h3>
<ErrorFor error={error} field="phone" />
<RetractingLabelInput
value={data.phone || ''}
onChange={(value) => setAndMarkModified('phone', value)}
label={<T t={t} k="provider-data.phone" />}
/>
<ErrorFor error={error} field="email" />
<RetractingLabelInput
value={data.email || ''}
onChange={(value) => setAndMarkModified('email', value)}
label={<T t={t} k="provider-data.email" />}
/>
<hr />
<ErrorFor error={error} field="code" />
<RetractingLabelInput
value={data.code || ''}
onChange={(value) => setAndMarkModified('code', value)}
description={
<T t={t} k="provider-data.access-code.description" />
}
label={<T t={t} k="provider-data.access-code.label" />}
/>
<hr />
<ul className="kip-properties">
<li className="kip-property">
<Switch
id="accessible"
checked={
data.accessible !== undefined
? data.accessible
: false
}
onChange={(value) =>
setAndMarkModified('accessible', value)
}
>
</Switch>
<label htmlFor="accessible">
<T t={t} k="provider-data.accessible" />
</label>
</li>
</ul>
</React.Fragment>
);
return (
<React.Fragment>
<div className="kip-provider-data">
<FormComponent onSubmit={onSubmit}>
<FieldSet>
<CardContent>{controls}</CardContent>
<CardFooter>
<SubmitField
disabled={!valid || embedded & !modified}
type={'success'}
onClick={onSubmit}
title={
<T
t={t}
k="provider-data.save-and-continue"
/>
}
/>
</CardFooter>
</FieldSet>
</FormComponent>
</div>
</React.Fragment>
);
}
Example #10
Source File: verify.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
Verify = () => {
const router = useRouter();
const settings = useSettings();
const provider = useProvider();
const [submitting, setSubmitting] = useState(false);
const [response, setResponse] = useState(null);
const submit = async () => {
if (submitting) return;
setSubmitting(true);
const response = await provider.storeData();
setSubmitting(false);
setResponse(response);
if (response.status === Status.Succeeded)
router.navigateToUrl('/provider/setup/store-secrets');
};
let failedMessage;
let failed;
if (response && response.status === Status.Failed) {
console.log(response);
failed = true;
if (
response.error.error !== undefined &&
response.error.error.code === 401
) {
failedMessage = (
<Message type="danger">
<T t={t} k="wizard.failed.invalid-code" />
</Message>
);
}
}
if (failed && !failedMessage)
failedMessage = (
<Message type="danger">
<T t={t} k="wizard.failed.notice" />
</Message>
);
return (
<>
<CardContent>
{failedMessage}
<p className="kip-verify-notice">
<T
t={t}
k="verify.text"
link={
<A
key="letUsKnow"
external
href={settings.get('supportEmail')}
>
<T t={t} k="wizard.letUsKnow" key="letUsKnow" />
</A>
}
/>
</p>
<ProviderData />
</CardContent>
<CardFooter>
<Button
type={failed ? 'danger' : 'success'}
disabled={submitting}
onClick={submit}
>
<T
t={t}
k={
failed
? 'wizard.failed.title'
: submitting
? 'wizard.please-wait'
: 'wizard.continue'
}
/>
</Button>
</CardFooter>
</>
);
}
Example #11
Source File: providers.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
Providers = ({ action, id }) => {
const router = useRouter();
const mediator = useMediator();
const [view, setView] = useState('pending');
useInterval(async () => {
await mediator.pendingProviders().get();
await mediator.verifiedProviders().get();
}, 10000);
const render = () => {
const providers =
view === 'pending'
? mediator.pendingProviders().result()
: mediator.verifiedProviders().result();
const showProvider = (i) => {
const id = buf2hex(b642buf(i));
router.navigateToUrl(`/mediator/providers/show/${id}`);
};
let modal;
const closeModal = () => router.navigateToUrl('/mediator/providers');
if (action === 'show' && id !== undefined) {
const base64Id = buf2b64(hex2buf(id));
const provider = providers.data.find(
(provider) => provider.data.publicKeys.signing === base64Id
);
const doConfirmProvider = async () => {
const result = await mediator.confirmProvider(provider);
console.log(result);
};
if (provider !== undefined)
modal = (
<Modal
title={<T t={t} k="providers.edit" />}
save={<T t={t} k="providers.confirm" />}
onSave={doConfirmProvider}
saveType="success"
onClose={closeModal}
onCancel={closeModal}
>
<div className="kip-provider-data">
<T t={t} k="providers.confirmText" />
<table className="bulma-table bulma-is-fullwidth bulma-is-striped">
<thead>
<tr>
<th>
<T t={t} k="provider-data.field" />
</th>
<th>
<T t={t} k="provider-data.value" />
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<T t={t} k="provider-data.name" />
</td>
<td>{provider.data.name}</td>
</tr>
<tr>
<td>
<T t={t} k="provider-data.street" />
</td>
<td>{provider.data.street}</td>
</tr>
<tr>
<td>
<T t={t} k="provider-data.city" />
</td>
<td>{provider.data.city}</td>
</tr>
<tr>
<td>
<T
t={t}
k="provider-data.zipCode"
/>
</td>
<td>{provider.data.zipCode}</td>
</tr>
<tr>
<td>
<T t={t} k="provider-data.email" />
</td>
<td>{provider.data.email}</td>
</tr>
<tr>
<td>
<T t={t} k="provider-data.phone" />
</td>
<td>{provider.data.phone}</td>
</tr>
<tr>
<td>
<T
t={t}
k="provider-data.description"
/>
</td>
<td>{provider.data.description}</td>
</tr>
</tbody>
</table>
</div>
</Modal>
);
}
const providerItems = providers.data
.sort(sortProviderByDate)
.map((provider) => (
<ListItem
onClick={() =>
showProvider(provider.data.publicKeys.signing)
}
key={provider.data.publicKeys.signing}
isCard
>
<ListColumn size="md">{provider.data.name}</ListColumn>
<ListColumn size="md">
{provider.data.street} · {provider.data.city}
</ListColumn>
</ListItem>
));
return (
<CardContent>
<div className="kip-providers">
{modal}
<DropdownMenu
title={
<F>
<Icon icon="check-circle" />
<T t={t} k={`providers.${view}`} />
</F>
}
>
<DropdownMenuItem
icon="check-circle"
onClick={() => setView('verified')}
>
<T t={t} k="providers.verified" />
</DropdownMenuItem>
<DropdownMenuItem
icon="exclamation-circle"
onClick={() => setView('pending')}
>
<T t={t} k="providers.pending" />
</DropdownMenuItem>
</DropdownMenu>
<List>
<ListHeader>
<ListColumn size="md">
<T t={t} k="providers.name" />
</ListColumn>
<ListColumn size="md">
<T t={t} k="providers.address" />
</ListColumn>
</ListHeader>
{providerItems}
</List>
</div>
</CardContent>
);
};
return (
<WithLoader
resources={[
mediator.pendingProviders().result(),
mediator.verifiedProviders().result(),
]}
renderLoaded={render}
/>
);
}
Example #12
Source File: accepted-appointment.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
AcceptedInvitation = () => {
const [showDelete, setShowDelete] = useState(false);
const doDelete = () => {
setShowDelete(false);
cancelInvitationAction(acceptedInvitation.data, tokenData.data).then(
() => {
// we reload the appointments
invitationAction();
acceptedInvitationAction();
}
);
};
const {
offer,
invitation: invitationData,
slotData,
} = acceptedInvitation.data;
const currentOffer = offers.find((of) => of.id == offer.id);
let currentSlotData;
if (currentOffer !== undefined)
currentSlotData = currentOffer.slotData.find(
(sl) => sl.id === slotData.id
);
let notice;
let changed = false;
for (const [k, v] of Object.entries(currentOffer)) {
if (
k === 'open' ||
k === 'slotData' ||
k === 'properties' ||
k === 'slots'
)
continue;
if (offer[k] !== v) {
changed = true;
break;
}
}
if (changed)
notice = (
<F>
<Message type="danger">
<T t={t} k="invitation-accepted.changed" />
</Message>
</F>
);
const d = new Date(currentOffer.timestamp);
let modal;
if (showDelete)
return (
<Modal
onSave={doDelete}
onClose={() => setShowDelete(false)}
onCancel={() => setShowDelete(false)}
saveType="danger"
save={<T t={t} k="invitation-accepted.delete.confirm" />}
cancel={<T t={t} k="invitation-accepted.delete.cancel" />}
title={<T t={t} k="invitation-accepted.delete.title" />}
className="kip-appointment-overview"
>
<p>
<T t={t} k="invitation-accepted.delete.notice" />
</p>
</Modal>
);
return (
<F>
<CardContent>
{notice}
<div className="kip-accepted-invitation">
<h2>
<T t={t} k="invitation-accepted.title" />
</h2>
<ProviderDetails data={invitationData.provider} />
<OfferDetails offer={currentOffer} />
<p className="kip-appointment-date">
{d.toLocaleDateString()} ·{' '}
<u>{d.toLocaleTimeString()}</u>
</p>
<p className="kip-booking-code">
<span>
<T t={t} k={'invitation-accepted.booking-code'} />
</span>
{userSecret.data.slice(0, 4)}
</p>
</div>
</CardContent>
<CardFooter>
<Button type="warning" onClick={() => setShowDelete(true)}>
<T t={t} k="cancel-appointment" />
</Button>
</CardFooter>
</F>
);
}
Example #13
Source File: appointments.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
InvitationDetails = ({}) => {
const settings = useSettings();
const [confirming, setConfirming] = useState(false);
const [initialized, setInitialized] = useState(false);
useEffect(() => {
if (initialized) return;
setInitialized(true);
toggleOffersAction(null);
});
const toggle = (offer) => {
toggleOffersAction(offer, data.offers);
};
const doConfirmOffers = () => {
const selectedOffers = [];
// we add the selected offers in the order the user chose
for (const offerID of toggleOffers.data) {
const offer = data.offers.find((offer) => offer.id === offerID);
selectedOffers.push(offer);
}
setConfirming(true);
const p = confirmOffersAction(selectedOffers, data, tokenData.data);
p.then(() => {
acceptedInvitationAction();
});
p.finally(() => {
setConfirming(false);
toggleOffersAction(null);
});
};
let content;
const properties = settings.get('appointmentProperties');
// to do: use something better than the index i for the key?
const offers = data.offers
.filter((offer) => offer.slotData.some((sl) => sl.open))
.filter((a) => new Date(a.timestamp) > new Date())
.sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp))
.map((offer, i) => {
const d = new Date(offer.timestamp);
const selected = toggleOffers.data.includes(offer.id);
let pref;
if (selected) pref = toggleOffers.data.indexOf(offer.id) + 1;
return (
<tr
key={offer.id}
className={classNames(`kip-pref-${pref}`, {
'kip-selected': selected,
'kip-failed': false,
})}
onClick={() => toggle(offer)}
>
<td>{selected ? pref : '-'}</td>
<td>
{d.toLocaleString('de-DE', {
month: '2-digit',
day: '2-digit',
year: '2-digit',
hour: '2-digit',
minute: '2-digit',
})}
</td>
<td>{formatDuration(offer.duration, settings, t)}</td>
<td>
<PropertyTags appointment={offer} />
</td>
</tr>
);
});
let offerDetails;
if (offers.length === 0)
offerDetails = (
<Message type="warning">
<T t={t} k="no-offers-anymore" />
</Message>
);
else
offerDetails = (
<table className="bulma-table bulma-is-striped bulma-is-fullwidth">
<thead>
<tr>
<th>
<T t={t} k="appointment-preference" />
</th>
<th>
<T t={t} k="appointment-date" />
</th>
<th>
<T t={t} k="appointment-duration" />
</th>
<th>
<T t={t} k="appointment-vaccine" />
</th>
</tr>
</thead>
<tbody>{offers}</tbody>
</table>
);
return (
<F>
<CardContent>
<div className="kip-invitation-details">
<ProviderDetails data={data.provider} />
<p>
<T t={t} k="appointments-notice" />
</p>
{offerDetails}
</div>
</CardContent>
<CardFooter>
<Button
waiting={confirming}
onClick={doConfirmOffers}
disabled={
confirming ||
Object.keys(
toggleOffers.data.filter((id) =>
data.offers.find((of) => of.id === id)
)
).length === 0
}
type="success"
>
<T t={t} k="confirm-appointment" />
</Button>
</CardFooter>
</F>
);
}
Example #14
Source File: settings.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
Settings = withActions(
withSettings(
withRouter(
({ settings, action, router, userSecret, backupDataAction }) => {
const [loggingOut, setLoggingOut] = useState(false);
let logOutModal;
const cancel = () => {
router.navigateToUrl('/user/settings');
};
const logOut = () => {
setLoggingOut(true);
const backend = settings.get('backend');
// we perform a backup before logging the user out...
backupDataAction(userSecret.data, 'logout').then(() => {
backend.local.deleteAll('user::');
setLoggingOut(false);
router.navigateToUrl('/user/logged-out');
});
};
if (action === 'logout') {
logOutModal = (
<Modal
onClose={cancel}
save={<T t={t} k="log-out" />}
disabled={loggingOut}
waiting={loggingOut}
title={<T t={t} k="log-out-modal.title" />}
onCancel={cancel}
onSave={logOut}
saveType="warning"
>
<p>
<T
t={t}
k={
loggingOut
? 'log-out-modal.logging-out'
: 'log-out-modal.text'
}
/>
</p>
<hr />
{userSecret !== undefined && (
<StoreOnline
secret={userSecret.data}
embedded={true}
hideNotice={true}
/>
)}
</Modal>
);
}
return (
<F>
<CardContent>
<div className="kip-user-settings">
{logOutModal}
<h2>
<T t={t} k="user-data.title" />
</h2>
<p>
<T t={t} k="user-data.notice" />
</p>
</div>
</CardContent>
<CardFooter>
<div className="kip-buttons">
<Button
type="warning"
href="/user/settings/logout"
>
<T t={t} k="log-out" />
</Button>
</div>
</CardFooter>
</F>
);
}
)
),
[]
)
Example #15
Source File: contact-data.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
BaseContactData = ({
form: { set, data, error, valid, reset },
router,
}) => {
const [modified, setModified] = useState(false);
const [initialized, setInitialized] = useState(false);
const user = useUser();
const onSubmit = () => {
if (!valid) return;
user.contactData = data;
// we redirect to the 'verify' step
router.navigateToUrl(`/user/setup/finalize`);
};
useEffect(() => {
if (initialized) return;
setInitialized(true);
setModified(false);
reset(user.contactData || {});
});
const submitting = false;
const setAndMarkModified = (key, value) => {
setModified(true);
set(key, value);
};
const controls = (
<React.Fragment>
<ErrorFor error={error} field="code" />
<RetractingLabelInput
value={data.code || ''}
onChange={(value) => setAndMarkModified('code', value)}
description={
<T t={t} k="contact-data.access-code.description" />
}
label={<T t={t} k="contact-data.access-code.label" />}
/>
</React.Fragment>
);
const redirecting = false;
return (
<React.Fragment>
<div className="kip-cm-contact-data">
<FormComponent onSubmit={onSubmit}>
<FieldSet disabled={submitting}>
{
<React.Fragment>
<CardContent>{controls}</CardContent>
<CardFooter>
<SubmitField
disabled={!valid}
type={'success'}
onClick={onSubmit}
waiting={submitting || redirecting}
title={
redirecting ? (
<T
t={t}
k="contact-data.success"
/>
) : submitting ? (
<T
t={t}
k="contact-data.saving"
/>
) : (
<T
t={t}
k={
'contact-data.save-and-continue'
}
/>
)
}
/>
</CardFooter>
</React.Fragment>
}
</FieldSet>
</FormComponent>
</div>
</React.Fragment>
);
}
Example #16
Source File: finalize.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
Finalize = withForm(
withSettings(
withRouter(
({
settings,
router,
form: { set, data, error, valid, reset },
}) => {
const [initialized, setInitialized] = useState(false);
const [modified, setModified] = useState(false);
const [submitting, setSubmitting] = useState(false);
const [tv, setTV] = useState(0);
const user = useUser();
useEffect(async () => {
if (initialized) return;
setInitialized(true);
await user.initialize();
const initialData = {
distance: 5,
};
for (const [k, v] of Object.entries(
t['contact-data'].properties
)) {
for (const [kv, vv] of Object.entries(v.values)) {
initialData[kv] = vv._default;
}
}
reset(user.queueData || initialData);
});
const submit = async () => {
setSubmitting(true);
// we store the queue data
user.queueData = data;
const result = await user.getToken({});
setSubmitting(false);
if (result.status === Status.Failed) return;
await user.backupData();
router.navigateToUrl('/user/setup/store-secrets');
};
const setAndMarkModified = (key, value) => {
setModified(true);
set(key, value);
};
const properties = Object.entries(
t['contact-data'].properties
).map(([k, v]) => {
const items = Object.entries(v.values).map(([kv, vv]) => (
<li key={kv}>
<Switch
id={kv}
checked={data[kv] || false}
onChange={(value) =>
setAndMarkModified(kv, value)
}
>
</Switch>
<label htmlFor={kv}>
<T
t={t}
k={`contact-data.properties.${k}.values.${kv}`}
/>
</label>
</li>
));
return (
<F key={k}>
<h2>
<T
t={t}
k={`contact-data.properties.${k}.title`}
/>
</h2>
<ul className="kip-properties">{items}</ul>
</F>
);
});
const render = () => {
let failedMessage;
let failed;
if (
getToken !== undefined &&
getToken.status === 'failed'
) {
failed = true;
if (getToken.error.error.code === 401) {
failedMessage = (
<Message type="danger">
<T t={t} k="wizard.failed.invalid-code" />
</Message>
);
}
}
if (failed && !failedMessage)
failedMessage = (
<Message type="danger">
<T t={t} k="wizard.failed.notice" />
</Message>
);
return (
<React.Fragment>
<CardContent>
{failedMessage}
<div className="kip-finalize-fields">
<ErrorFor error={error} field="zipCode" />
<RetractingLabelInput
value={data.zipCode || ''}
onChange={(value) =>
setAndMarkModified('zipCode', value)
}
label={
<T
t={t}
k="contact-data.zip-code"
/>
}
/>
<label
className="kip-control-label"
htmlFor="distance"
>
<T
t={t}
k="contact-data.distance.label"
/>
<span className="kip-control-notice">
<T
t={t}
k="contact-data.distance.notice"
/>
</span>
</label>
<ErrorFor error={error} field="distance" />
<RichSelect
id="distance"
value={data.distance || 5}
onChange={(value) =>
setAndMarkModified(
'distance',
value.value
)
}
options={[
{
value: 5,
description: (
<T
t={t}
k="contact-data.distance.option"
distance={5}
/>
),
},
{
value: 10,
description: (
<T
t={t}
k="contact-data.distance.option"
distance={10}
/>
),
},
{
value: 20,
description: (
<T
t={t}
k="contact-data.distance.option"
distance={20}
/>
),
},
{
value: 30,
description: (
<T
t={t}
k="contact-data.distance.option"
distance={30}
/>
),
},
{
value: 40,
description: (
<T
t={t}
k="contact-data.distance.option"
distance={40}
/>
),
},
{
value: 50,
description: (
<T
t={t}
k="contact-data.distance.option"
distance={50}
/>
),
},
]}
/>
{properties}
</div>
</CardContent>
<CardFooter>
<Button
waiting={submitting}
type={failed ? 'danger' : 'success'}
onClick={submit}
disabled={submitting || !valid}
>
<T
t={t}
k={
failed
? 'wizard.failed.title'
: submitting
? 'wizard.please-wait'
: 'wizard.continue'
}
/>
</Button>
</CardFooter>
</React.Fragment>
);
};
return <WithLoader resources={[]} renderLoaded={render} />;
}
)
),
FinalizeForm,
'form'
)
Example #17
Source File: settings.jsx From apps with GNU Affero General Public License v3.0 | 4 votes |
BaseSettings = ({
type,
settings,
keyPairs,
keyPairsAction,
action,
secondaryAction,
id,
router,
}) => {
let modal;
const [initialized, setInitialized] = useState(false);
const [loggingOut, setLoggingOut] = useState(false);
useEffect(() => {
if (initialized) return;
setInitialized(true);
keyPairsAction();
});
const cancel = () => {
router.navigateToUrl('/mediator/settings');
};
const logOut = () => {
setLoggingOut(true);
const backend = settings.get('backend');
backend.local.deleteAll('mediator::');
router.navigateToUrl('/mediator/logged-out');
};
if (action === 'test-queues') {
modal = <TestQueuesModal keyPairs={keyPairs} />;
} else if (action === 'logout') {
modal = (
<Modal
onClose={cancel}
save={<T t={t} k="log-out" />}
disabled={loggingOut}
waiting={loggingOut}
title={<T t={t} k="log-out-modal.title" />}
onCancel={cancel}
onSave={logOut}
saveType="warning"
>
<p>
<T
t={t}
k={
loggingOut
? 'log-out-modal.logging-out'
: 'log-out-modal.text'
}
/>
</p>
</Modal>
);
}
return (
<F>
{modal}
<CardContent>
<div className="kip-mediator-settings">
<h2>
<T t={t} k="test-queues.title" />
</h2>
<p>
<T t={t} k="test-queues.text" />
</p>
<div className="kip-buttons">
<Button
type="success"
href="/mediator/settings/test-queues"
>
<T t={t} k="test-queues.button" />
</Button>
</div>
</div>
</CardContent>
<CardFooter>
<div className="kip-buttons">
<Button type="warning" href="/mediator/settings/logout">
<T t={t} k="log-out" />
</Button>
</div>
</CardFooter>
</F>
);
}