Create components for TTS and attachment settings
This commit is contained in:
parent
4aa5b285ac
commit
5ee1fa60db
19
src/components/Reminder/Attachment.tsx
Normal file
19
src/components/Reminder/Attachment.tsx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { useReminder } from "./ReminderContext";
|
||||||
|
|
||||||
|
export const Attachment = () => {
|
||||||
|
const [{ attachment, attachment_name }, setReminder] = useReminder();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="file is-small is-boxed">
|
||||||
|
<label class="file-label">
|
||||||
|
<input class="file-input" type="file" name="attachment"></input>
|
||||||
|
<span class="file-cta">
|
||||||
|
<span class="file-label">{attachment_name || "Add Attachment"}</span>
|
||||||
|
<span class="file-icon">
|
||||||
|
<i class="fas fa-upload"></i>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -4,11 +4,15 @@ import { IntervalSelector } from "./IntervalSelector";
|
|||||||
import { useQuery } from "react-query";
|
import { useQuery } from "react-query";
|
||||||
import { fetchUserInfo } from "../../api";
|
import { fetchUserInfo } from "../../api";
|
||||||
import { useReminder } from "./ReminderContext";
|
import { useReminder } from "./ReminderContext";
|
||||||
|
import { Attachment } from "./Attachment";
|
||||||
|
import { TTS } from "./TTS";
|
||||||
|
import { useTimezone } from "../App/TimezoneProvider";
|
||||||
|
|
||||||
export const Settings = () => {
|
export const Settings = () => {
|
||||||
const { isSuccess: userFetched, data: userInfo } = useQuery(fetchUserInfo());
|
const { isSuccess: userFetched, data: userInfo } = useQuery(fetchUserInfo());
|
||||||
|
|
||||||
const [reminder, setReminder] = useReminder();
|
const [reminder, setReminder] = useReminder();
|
||||||
|
const [timezone] = useTimezone();
|
||||||
|
|
||||||
if (!userFetched) {
|
if (!userFetched) {
|
||||||
return <></>;
|
return <></>;
|
||||||
@ -42,7 +46,9 @@ export const Settings = () => {
|
|||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
step="1"
|
step="1"
|
||||||
name="time"
|
name="time"
|
||||||
value={reminder.utc_time.toLocal().toFormat("yyyy-LL-dd'T'HH:mm:ss")}
|
value={reminder.utc_time
|
||||||
|
.setZone(timezone)
|
||||||
|
.toFormat("yyyy-LL-dd'T'HH:mm:ss")}
|
||||||
onInput={(ev) => {
|
onInput={(ev) => {
|
||||||
setReminder((reminder) => ({
|
setReminder((reminder) => ({
|
||||||
...reminder,
|
...reminder,
|
||||||
@ -103,8 +109,20 @@ export const Settings = () => {
|
|||||||
name="expiration"
|
name="expiration"
|
||||||
value={
|
value={
|
||||||
reminder.expires !== null &&
|
reminder.expires !== null &&
|
||||||
reminder.expires.toFormat("yyyy-LL-dd'T'HH:mm:ss")
|
reminder.expires
|
||||||
|
.setZone(timezone)
|
||||||
|
.toFormat("yyyy-LL-dd'T'HH:mm:ss")
|
||||||
}
|
}
|
||||||
|
onInput={(ev) => {
|
||||||
|
setReminder((reminder) => ({
|
||||||
|
...reminder,
|
||||||
|
expires: ev.currentTarget.value
|
||||||
|
? DateTime.fromISO(
|
||||||
|
ev.currentTarget.value,
|
||||||
|
).toUTC()
|
||||||
|
: null,
|
||||||
|
}));
|
||||||
|
}}
|
||||||
></input>
|
></input>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@ -113,24 +131,10 @@ export const Settings = () => {
|
|||||||
|
|
||||||
<div class="columns is-mobile tts-row">
|
<div class="columns is-mobile tts-row">
|
||||||
<div class="column has-text-centered">
|
<div class="column has-text-centered">
|
||||||
<div class="is-boxed">
|
<TTS />
|
||||||
<label class="label">
|
|
||||||
Enable TTS <input type="checkbox" name="tts"></input>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="column has-text-centered">
|
<div class="column has-text-centered">
|
||||||
<div class="file is-small is-boxed">
|
<Attachment />
|
||||||
<label class="file-label">
|
|
||||||
<input class="file-input" type="file" name="attachment"></input>
|
|
||||||
<span class="file-cta">
|
|
||||||
<span class="file-label">Add Attachment</span>
|
|
||||||
<span class="file-icon">
|
|
||||||
<i class="fas fa-upload"></i>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
24
src/components/Reminder/TTS.tsx
Normal file
24
src/components/Reminder/TTS.tsx
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { useReminder } from "./ReminderContext";
|
||||||
|
|
||||||
|
export const TTS = () => {
|
||||||
|
const [{ tts }, setReminder] = useReminder();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="is-boxed">
|
||||||
|
<label class="label">
|
||||||
|
Enable TTS{" "}
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="tts"
|
||||||
|
checked={tts}
|
||||||
|
onInput={(ev) => {
|
||||||
|
setReminder((reminder) => ({
|
||||||
|
...reminder,
|
||||||
|
tts: ev.currentTarget.checked,
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
></input>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user