fix: make theme logic safe and add better e2e tests (#16959)

* fix: improve theme logic

* remove null from ThemeLabelProps value

* add better e2e tests
This commit is contained in:
Benny Joo authored and GitHub committed 2024-10-07 11:23:30 +01:00
1 parent b0bfec7247
commit 21dd44733f
6 files changed
+127 -23

No files matched your search

@@ -78,9 +78,15 @@ const OrgAppearanceView = ({
<div>
<Form
form={themeForm}
handleSubmit={(value) => {
handleSubmit={({ theme }) => {
if (theme === "light" || theme === "dark") {
mutation.mutate({
theme,
});
return;
}
mutation.mutate({
theme: value.theme === "" ? null : value.theme,
theme: null,
});
}}>
<div className="border-subtle mt-6 flex items-center rounded-t-xl border p-6 text-sm">
@@ -92,7 +98,7 @@ const OrgAppearanceView = ({
<div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
<ThemeLabel
variant="system"
value={undefined}
value="system"
label={t("theme_system")}
defaultChecked={currentOrg.theme === null}
register={themeForm.register}
@@ -90,10 +90,10 @@ const ProfileView = ({ team, isAppDir }: ProfileViewProps) => {
<>
<Form
form={themeForm}
handleSubmit={(values) => {
handleSubmit={({ theme }) => {
mutation.mutate({
id: team.id,
theme: values.theme === "" ? null : values.theme,
theme: theme === "light" || theme === "dark" ? theme : null,
});
}}>
<div className="border-subtle mt-6 flex items-center rounded-t-xl border p-6 text-sm">
@@ -105,7 +105,7 @@ const ProfileView = ({ team, isAppDir }: ProfileViewProps) => {
<div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
<ThemeLabel
variant="system"
value={null}
value="system"
label={t("theme_system")}
defaultChecked={team.theme === null}
register={themeForm.register}