chore: Improved loading

This commit is contained in:
Aron Malcher 2024-03-27 14:12:19 +01:00
parent 04fb5709a1
commit ede764b6f3
Signed by: aronmal
GPG key ID: 816B7707426FC612

View file

@ -148,7 +148,7 @@ const saveConfig = async (
return { success: true }; return { success: true };
}; };
function config() { function MyConfig() {
const params = useParams(); const params = useParams();
const navigator = useNavigate(); const navigator = useNavigate();
const location = useLocation(); const location = useLocation();
@ -285,7 +285,6 @@ function config() {
}); });
return ( return (
<Layout site="config">
<div class="group"> <div class="group">
<h3>Configure li&apos;l Judd in</h3> <h3>Configure li&apos;l Judd in</h3>
<div> <div>
@ -316,6 +315,7 @@ function config() {
list="timezones" list="timezones"
id="timezone" id="timezone"
ref={(e) => setTimezoneRef(e)} ref={(e) => setTimezoneRef(e)}
value={payload()?.guild.timezone}
onInput={(e) => onInput={(e) =>
setConfig( setConfig(
"features", "features",
@ -351,9 +351,7 @@ function config() {
<p>Time Planning </p> <p>Time Planning </p>
<FontAwesomeIcon <FontAwesomeIcon
icon={ icon={
config.features.timePlanning.enabled config.features.timePlanning.enabled ? faToggleOn : faToggleOff
? faToggleOn
: faToggleOff
} }
size="xl" size="xl"
/> />
@ -363,13 +361,9 @@ function config() {
type="checkbox" type="checkbox"
id="timePlanning" id="timePlanning"
ref={(e) => setTpEnabledRef(e)} ref={(e) => setTpEnabledRef(e)}
checked={!!payload()?.guild.tpChannelId}
onInput={(e) => onInput={(e) =>
setConfig( setConfig("features", "timePlanning", "enabled", e.target.checked)
"features",
"timePlanning",
"enabled",
e.target.checked,
)
} }
/> />
<div <div
@ -380,6 +374,7 @@ function config() {
<label>Target channel:</label> <label>Target channel:</label>
<select <select
ref={(e) => setChannelRef(e)} ref={(e) => setChannelRef(e)}
value={payload()?.guild.tpChannelId}
onInput={(e) => onInput={(e) =>
setConfig( setConfig(
"features", "features",
@ -411,6 +406,9 @@ function config() {
<label>Target Interval:</label> <label>Target Interval:</label>
<select <select
ref={(e) => setTargetDayRef(e)} ref={(e) => setTargetDayRef(e)}
value={
splitInterval(payload()?.guild.tpInterval ?? 0).targetDay
}
onInput={(e) => onInput={(e) =>
setConfig( setConfig(
"features", "features",
@ -440,6 +438,9 @@ function config() {
at at
<select <select
ref={(e) => setTargetHourRef(e)} ref={(e) => setTargetHourRef(e)}
value={
splitInterval(payload()?.guild.tpInterval ?? 0).targetHour
}
onInput={(e) => onInput={(e) =>
setConfig( setConfig(
"features", "features",
@ -450,14 +451,15 @@ function config() {
} }
> >
<Index each={Array.from(Array(24)).map((_e, i) => i)}> <Index each={Array.from(Array(24)).map((_e, i) => i)}>
{(id) => ( {(id) => <option value={String(id())}>{String(id())}</option>}
<option value={String(id())}>{String(id())}</option>
)}
</Index> </Index>
</select> </select>
: :
<select <select
ref={(e) => setTargetMinuteRef(e)} ref={(e) => setTargetMinuteRef(e)}
value={
splitInterval(payload()?.guild.tpInterval ?? 0).targetMinute
}
onInput={(e) => onInput={(e) =>
setConfig( setConfig(
"features", "features",
@ -493,6 +495,7 @@ function config() {
type="checkbox" type="checkbox"
id="pingableRoles" id="pingableRoles"
ref={(e) => setPingableRolesRef(e)} ref={(e) => setPingableRolesRef(e)}
checked={payload()?.guild.pingableRoles}
onInput={(e) => onInput={(e) =>
setConfig( setConfig(
"features", "features",
@ -518,10 +521,18 @@ function config() {
Apply Apply
</button> </button>
<button onClick={() => navigator("/config")}>Back</button> <button onClick={() => navigator("/config")}>Back</button>
<button onClick={() => refetch()}>Reset</button>
<Show when={willUpdateValues()}>UNSAVED CHANGES</Show> <Show when={willUpdateValues()}>UNSAVED CHANGES</Show>
</section> </section>
</div> </div>
</div> </div>
);
}
function config() {
return (
<Layout site="config">
<MyConfig />
</Layout> </Layout>
); );
} }