diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx index 18bb82ce5f..4acac1929e 100644 --- a/web/apps/photos/src/components/Sidebar.tsx +++ b/web/apps/photos/src/components/Sidebar.tsx @@ -17,6 +17,7 @@ import { Skeleton, Stack, styled, + TextField, Tooltip, useColorScheme, } from "@mui/material"; @@ -35,10 +36,10 @@ import { RowButtonGroupHint, RowSwitch, } from "ente-base/components/RowButton"; -import { SingleInputForm } from "ente-base/components/SingleInputForm"; import { SpacedRow } from "ente-base/components/containers"; import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconButton"; import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton"; +import { LoadingButton } from "ente-base/components/mui/LoadingButton"; import { SidebarDrawer, TitledNestedSidebarDrawer, @@ -113,6 +114,7 @@ import { import { usePhotosAppContext } from "ente-new/photos/types/context"; import { initiateEmail, openURL } from "ente-new/photos/utils/web"; import { wait } from "ente-utils/promise"; +import { useFormik } from "formik"; import { t } from "i18next"; import { useRouter } from "next/router"; import React, { @@ -1007,6 +1009,22 @@ const DomainSettings: React.FC = ({ }) => { const { customDomain, customDomainCNAME } = useSettingsSnapshot(); + const formik = useFormik({ + initialValues: { domain: customDomain ?? "" }, + onSubmit: async (values, { setFieldError }) => { + const domain = values.domain; + const setValueFieldError = (message: string) => + setFieldError("domain", message); + + try { + await updateCustomDomain(domain); + } catch (e) { + log.error(`Failed to submit input ${domain}`, e); + setValueFieldError(t("generic_error")); + } + }, + }); + const handleRootClose = () => { onClose(); onRootClose(); @@ -1023,18 +1041,32 @@ const DomainSettings: React.FC = ({ - Any domain or subdomain you own + {pt("Any domain or subdomain you own")} - +
+ + + {customDomain ? pt("Update") : pt("Save")} + +
@@ -1049,7 +1081,7 @@ const DomainSettings: React.FC = ({ - + Within 1 hour, your public albums will be accessible via your domain! @@ -1072,11 +1104,13 @@ const DomainSettings: React.FC = ({ interface DomainSectionProps { title: string; ordinal: string; + isEmoji?: boolean; } const DomainItem: React.FC> = ({ title, ordinal, + isEmoji, children, }) => ( @@ -1084,7 +1118,7 @@ const DomainItem: React.FC> = ({ direction="row" sx={{ alignItems: "center", justifyContent: "space-between" }} > - {title} + {title}