Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add Space profile settings

Anand Baburajan3e6b4571f16b
diff --git a/web/apps/space/src/pages/app/profile/cover-edit.tsx b/web/apps/space/src/pages/app/profile/cover-edit.tsx
index 7f703c5e5d..a47529a3a9 100644
--- a/web/apps/space/src/pages/app/profile/cover-edit.tsx
+++ b/web/apps/space/src/pages/app/profile/cover-edit.tsx
@@ -9,7 +9,10 @@ import {
spaceProfileErrorMessage,
} from "services/spaceProfile";
import { useSpaceAppState } from "state/spaceAppState";
-import { spaceRoutes } from "utils/spaceRoutes";
+import {
+ profileImageFlowSourceFromQuery,
+ spaceRoutes,
+} from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
@@ -21,6 +24,12 @@ const Page: React.FC = () => {
setPendingProfileCoverFile,
setProfile,
} = useSpaceAppState();
+ const imageFlowSource = profileImageFlowSourceFromQuery(router.query.from);
+ const profileCoverRoute = spaceRoutes.profileCoverFrom(imageFlowSource);
+ const savedRoute =
+ imageFlowSource == "settings"
+ ? spaceRoutes.settingsProfile
+ : spaceRoutes.profile;
useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
@@ -34,9 +43,15 @@ const Page: React.FC = () => {
profile &&
!pendingProfileCoverFile
) {
- void router.replace(spaceRoutes.profileCover);
+ void router.replace(profileCoverRoute);
}
- }, [pendingProfileCoverFile, profile, profileLoadStatus, router]);
+ }, [
+ pendingProfileCoverFile,
+ profile,
+ profileCoverRoute,
+ profileLoadStatus,
+ router,
+ ]);
if (profileLoadStatus != "ready" || !profile || !pendingProfileCoverFile) {
return (
@@ -54,7 +69,7 @@ const Page: React.FC = () => {
coverFile={pendingProfileCoverFile}
onBack={() => {
setPendingProfileCoverFile(null);
- void router.push(spaceRoutes.profileCover);
+ void router.push(profileCoverRoute);
}}
onSave={async (coverFile) => {
try {
@@ -63,7 +78,7 @@ const Page: React.FC = () => {
coverFile,
});
setProfile(savedProfile);
- await router.push(spaceRoutes.profile);
+ await router.push(savedRoute);
setPendingProfileCoverFile(null);
} catch (error) {
console.error("Space cover update failed", error);
diff --git a/web/apps/space/src/pages/app/profile/cover.tsx b/web/apps/space/src/pages/app/profile/cover.tsx
index 3c4a44e6bb..2311ef8073 100644
--- a/web/apps/space/src/pages/app/profile/cover.tsx
+++ b/web/apps/space/src/pages/app/profile/cover.tsx
@@ -5,7 +5,10 @@ import React, { useEffect } from "react";
import { ProfileImageViewerScreen } from "screens/ProfileImageViewerScreen";
import { profileBackground } from "screens/ProfileScreen";
import { useSpaceAppState } from "state/spaceAppState";
-import { spaceRoutes } from "utils/spaceRoutes";
+import {
+ profileImageFlowSourceFromQuery,
+ spaceRoutes,
+} from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
@@ -15,6 +18,11 @@ const Page: React.FC = () => {
profileLoadStatus,
setPendingProfileCoverFile,
} = useSpaceAppState();
+ const imageFlowSource = profileImageFlowSourceFromQuery(router.query.from);
+ const backRoute =
+ imageFlowSource == "settings"
+ ? spaceRoutes.settingsProfile
+ : spaceRoutes.profile;
useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
@@ -37,10 +45,12 @@ const Page: React.FC = () => {
<ProfileImageViewerScreen
profile={profile}
variant="cover"
- onBack={() => void router.push(spaceRoutes.profile)}
+ onBack={() => void router.push(backRoute)}
onSelectFile={(file) => {
setPendingProfileCoverFile(file);
- void router.push(spaceRoutes.editProfileCover);
+ void router.push(
+ spaceRoutes.editProfileCoverFrom(imageFlowSource),
+ );
}}
/>
</>
diff --git a/web/apps/space/src/pages/app/profile/photo-edit.tsx b/web/apps/space/src/pages/app/profile/photo-edit.tsx
index 2b458a36ae..f567f86cb6 100644
--- a/web/apps/space/src/pages/app/profile/photo-edit.tsx
+++ b/web/apps/space/src/pages/app/profile/photo-edit.tsx
@@ -9,7 +9,10 @@ import {
spaceProfileErrorMessage,
} from "services/spaceProfile";
import { useSpaceAppState } from "state/spaceAppState";
-import { spaceRoutes } from "utils/spaceRoutes";
+import {
+ profileImageFlowSourceFromQuery,
+ spaceRoutes,
+} from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
@@ -21,6 +24,12 @@ const Page: React.FC = () => {
setPendingProfileAvatarFile,
setProfile,
} = useSpaceAppState();
+ const imageFlowSource = profileImageFlowSourceFromQuery(router.query.from);
+ const profilePhotoRoute = spaceRoutes.profilePhotoFrom(imageFlowSource);
+ const savedRoute =
+ imageFlowSource == "settings"
+ ? spaceRoutes.settingsProfile
+ : spaceRoutes.profile;
useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
@@ -34,9 +43,15 @@ const Page: React.FC = () => {
profile &&
!pendingProfileAvatarFile
) {
- void router.replace(spaceRoutes.profilePhoto);
+ void router.replace(profilePhotoRoute);
}
- }, [pendingProfileAvatarFile, profile, profileLoadStatus, router]);
+ }, [
+ pendingProfileAvatarFile,
+ profile,
+ profileLoadStatus,
+ profilePhotoRoute,
+ router,
+ ]);
if (profileLoadStatus != "ready" || !profile || !pendingProfileAvatarFile) {
return (
@@ -54,7 +69,7 @@ const Page: React.FC = () => {
avatarFile={pendingProfileAvatarFile}
onBack={() => {
setPendingProfileAvatarFile(null);
- void router.push(spaceRoutes.profilePhoto);
+ void router.push(profilePhotoRoute);
}}
onSave={async (avatarFile) => {
try {
@@ -63,7 +78,7 @@ const Page: React.FC = () => {
avatarFile,
});
setProfile(savedProfile);
- await router.push(spaceRoutes.profile);
+ await router.push(savedRoute);
setPendingProfileAvatarFile(null);
} catch (error) {
console.error("Space avatar update failed", error);
diff --git a/web/apps/space/src/pages/app/profile/photo.tsx b/web/apps/space/src/pages/app/profile/photo.tsx
index e6b5d0aa62..8c87e48fee 100644
--- a/web/apps/space/src/pages/app/profile/photo.tsx
+++ b/web/apps/space/src/pages/app/profile/photo.tsx
@@ -5,7 +5,10 @@ import React, { useEffect } from "react";
import { ProfileImageViewerScreen } from "screens/ProfileImageViewerScreen";
import { profileBackground } from "screens/ProfileScreen";
import { useSpaceAppState } from "state/spaceAppState";
-import { spaceRoutes } from "utils/spaceRoutes";
+import {
+ profileImageFlowSourceFromQuery,
+ spaceRoutes,
+} from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
@@ -15,6 +18,11 @@ const Page: React.FC = () => {
profileLoadStatus,
setPendingProfileAvatarFile,
} = useSpaceAppState();
+ const imageFlowSource = profileImageFlowSourceFromQuery(router.query.from);
+ const backRoute =
+ imageFlowSource == "settings"
+ ? spaceRoutes.settingsProfile
+ : spaceRoutes.profile;
useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
@@ -37,10 +45,12 @@ const Page: React.FC = () => {
<ProfileImageViewerScreen
profile={profile}
variant="avatar"
- onBack={() => void router.push(spaceRoutes.profile)}
+ onBack={() => void router.push(backRoute)}
onSelectFile={(file) => {
setPendingProfileAvatarFile(file);
- void router.push(spaceRoutes.editProfilePhoto);
+ void router.push(
+ spaceRoutes.editProfilePhotoFrom(imageFlowSource),
+ );
}}
/>
</>
diff --git a/web/apps/space/src/pages/app/settings.tsx b/web/apps/space/src/pages/app/settings.tsx
index 1dc1891577..77231f3b7a 100644
--- a/web/apps/space/src/pages/app/settings.tsx
+++ b/web/apps/space/src/pages/app/settings.tsx
@@ -9,12 +9,8 @@ import { spaceRoutes } from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
- const {
- profile,
- profileLoadError,
- profileLoadStatus,
- resetAfterLogout,
- } = useSpaceAppState();
+ const { profile, profileLoadError, profileLoadStatus, resetAfterLogout } =
+ useSpaceAppState();
useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
@@ -36,6 +32,9 @@ const Page: React.FC = () => {
<SpacePageMeta themeColor={settingsBackground} />
<SettingsScreen
onBack={() => void router.push(spaceRoutes.profile)}
+ onOpenProfile={() =>
+ void router.push(spaceRoutes.settingsProfile)
+ }
onLogout={() => {
void accountLogout().then(() => {
resetAfterLogout();
diff --git a/web/apps/space/src/pages/app/settings/profile.tsx b/web/apps/space/src/pages/app/settings/profile.tsx
new file mode 100644
index 0000000000..2b3b2ce55d
--- /dev/null
+++ b/web/apps/space/src/pages/app/settings/profile.tsx
@@ -0,0 +1,50 @@
+import { SpacePageMeta } from "components/SpacePageMeta";
+import { SpaceRouteFallback } from "components/SpaceRouteFallback";
+import { useRouter } from "next/router";
+import React, { useEffect } from "react";
+import {
+ ProfileSettingsScreen,
+ settingsBackground,
+} from "screens/SettingsScreen";
+import { useSpaceAppState } from "state/spaceAppState";
+import { spaceRoutes } from "utils/spaceRoutes";
+
+const Page: React.FC = () => {
+ const router = useRouter();
+ const { profile, profileLoadError, profileLoadStatus } = useSpaceAppState();
+
+ useEffect(() => {
+ if (profileLoadStatus == "ready" && !profile) {
+ void router.replace(spaceRoutes.onboarding);
+ }
+ }, [profile, profileLoadStatus, router]);
+
+ if (profileLoadStatus != "ready" || !profile) {
+ return (
+ <SpaceRouteFallback
+ background={settingsBackground}
+ message={profileLoadError}
+ />
+ );
+ }
+
+ return (
+ <>
+ <SpacePageMeta themeColor={settingsBackground} />
+ <ProfileSettingsScreen
+ onBack={() => void router.push(spaceRoutes.settings)}
+ onChangeCoverImage={() =>
+ void router.push(spaceRoutes.profileCoverFrom("settings"))
+ }
+ onChangeName={() =>
+ void router.push(spaceRoutes.settingsProfileName)
+ }
+ onChangeProfilePicture={() =>
+ void router.push(spaceRoutes.profilePhotoFrom("settings"))
+ }
+ />
+ </>
+ );
+};
+
+export default Page;
diff --git a/web/apps/space/src/pages/app/settings/profile/name.tsx b/web/apps/space/src/pages/app/settings/profile/name.tsx
new file mode 100644
index 0000000000..ff72c6e412
--- /dev/null
+++ b/web/apps/space/src/pages/app/settings/profile/name.tsx
@@ -0,0 +1,65 @@
+import { SpacePageMeta } from "components/SpacePageMeta";
+import { SpaceRouteFallback } from "components/SpaceRouteFallback";
+import { useRouter } from "next/router";
+import React, { useEffect, useState } from "react";
+import {
+ ChangeNameSettingsScreen,
+ settingsBackground,
+} from "screens/SettingsScreen";
+import {
+ saveSpaceProfile,
+ spaceProfileErrorMessage,
+} from "services/spaceProfile";
+import { useSpaceAppState } from "state/spaceAppState";
+import { spaceRoutes } from "utils/spaceRoutes";
+
+const Page: React.FC = () => {
+ const router = useRouter();
+ const { profile, profileLoadError, profileLoadStatus, setProfile } =
+ useSpaceAppState();
+ const [errorMessage, setErrorMessage] = useState<string>();
+ const [isSaving, setIsSaving] = useState(false);
+
+ useEffect(() => {
+ if (profileLoadStatus == "ready" && !profile) {
+ void router.replace(spaceRoutes.onboarding);
+ }
+ }, [profile, profileLoadStatus, router]);
+
+ if (profileLoadStatus != "ready" || !profile) {
+ return (
+ <SpaceRouteFallback
+ background={settingsBackground}
+ message={profileLoadError}
+ />
+ );
+ }
+
+ return (
+ <>
+ <SpacePageMeta themeColor={settingsBackground} />
+ <ChangeNameSettingsScreen
+ errorMessage={errorMessage}
+ initialName={profile.fullName}
+ isSaving={isSaving}
+ onBack={() => void router.push(spaceRoutes.settingsProfile)}
+ onSave={(fullName) => {
+ setErrorMessage(undefined);
+ setIsSaving(true);
+ void saveSpaceProfile({ ...profile, fullName })
+ .then((savedProfile) => {
+ setProfile(savedProfile);
+ void router.push(spaceRoutes.settingsProfile);
+ })
+ .catch((error: unknown) => {
+ console.error("Space name update failed", error);
+ setErrorMessage(spaceProfileErrorMessage(error));
+ })
+ .finally(() => setIsSaving(false));
+ }}
+ />
+ </>
+ );
+};
+
+export default Page;
diff --git a/web/apps/space/src/screens/SettingsScreen.tsx b/web/apps/space/src/screens/SettingsScreen.tsx
index 780d7ff6cc..31bd80d545 100644
--- a/web/apps/space/src/screens/SettingsScreen.tsx
+++ b/web/apps/space/src/screens/SettingsScreen.tsx
@@ -1,13 +1,18 @@
import {
ArrowLeft02Icon,
+ Camera01Icon,
ArrowRight01Icon as ChevronRightIcon,
CustomerSupportIcon,
HelpCircleIcon,
+ Image01Icon,
Logout05Icon,
+ UserEdit01Icon,
+ UserIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";
import { Box } from "@mui/material";
import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";
+import { SpaceButtonSpinner } from "components/SpaceButtonSpinner";
import React from "react";
import { spaceTouchTargetSize } from "styles/touchTargets";
@@ -18,6 +23,7 @@ const textBase = "#000";
const rowBackground = "#FFFFFF";
const dangerColor = "#F63A3A";
const iconMuted = "#8C8C8C";
+const textLight = "#969696";
const helpURL = "https://ente.com/help/photos/features/profile";
const supportMailURL = "mailto:[email protected]";
const spaceLinks = [
@@ -56,6 +62,7 @@ const spaceLinks = [
interface SettingsScreenProps {
onLogout: () => void;
onBack?: () => void;
+ onOpenProfile: () => void;
}
interface SettingsRowProps {
@@ -72,6 +79,21 @@ interface SpaceIconProps {
url: string;
}
+interface ProfileSettingsScreenProps {
+ onBack: () => void;
+ onChangeCoverImage: () => void;
+ onChangeName: () => void;
+ onChangeProfilePicture: () => void;
+}
+
+interface ChangeNameSettingsScreenProps {
+ errorMessage?: string;
+ initialName: string;
+ isSaving?: boolean;
+ onBack: () => void;
+ onSave: (name: string) => void;
+}
+
const SettingsRow: React.FC<SettingsRowProps> = ({
danger,
href,
@@ -198,6 +220,7 @@ const SpaceIcon: React.FC<SpaceIconProps> = ({ label, src, url }) => (
export const SettingsScreen: React.FC<SettingsScreenProps> = ({
onLogout,
onBack,
+ onOpenProfile,
}) => {
const [logoutSheetOpen, setLogoutSheetOpen] = React.useState(false);
@@ -298,6 +321,11 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
width: "100%",
}}
>
+ <SettingsRow
+ icon={UserIcon}
+ label="Profile"
+ onClick={onOpenProfile}
+ />
<SettingsRow
href={helpURL}
icon={HelpCircleIcon}
@@ -347,3 +375,362 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
</Box>
);
};
+
+export const ProfileSettingsScreen: React.FC<ProfileSettingsScreenProps> = ({
+ onBack,
+ onChangeCoverImage,
+ onChangeName,
+ onChangeProfilePicture,
+}) => (
+ <Box
+ component="main"
+ sx={{
+ bgcolor: settingsBackground,
+ color: textBase,
+ display: "grid",
+ minHeight: "100svh",
+ overflowX: "hidden",
+ placeItems: { xs: "stretch", sm: "start center" },
+ }}
+ >
+ <Box
+ sx={{
+ bgcolor: settingsBackground,
+ boxSizing: "border-box",
+ display: "flex",
+ flexDirection: "column",
+ minHeight: "100svh",
+ mx: "auto",
+ width: "100%",
+ "@media (min-width: 600px)": { maxWidth: 390 },
+ }}
+ >
+ <Box
+ component="header"
+ sx={{
+ alignItems: "center",
+ display: "grid",
+ gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
+ height: 56,
+ px: 2,
+ width: "100%",
+ }}
+ >
+ <Box
+ component="button"
+ type="button"
+ aria-label="Back to settings"
+ onClick={onBack}
+ sx={{
+ alignItems: "center",
+ bgcolor: "transparent",
+ border: 0,
+ color: textBase,
+ cursor: "pointer",
+ display: "flex",
+ height: spaceTouchTargetSize,
+ justifyContent: "flex-start",
+ ml: "-2px",
+ p: 0,
+ width: spaceTouchTargetSize,
+ "&:focus-visible": {
+ borderRadius: "50%",
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <HugeiconsIcon
+ icon={ArrowLeft02Icon}
+ size={24}
+ strokeWidth={1.8}
+ />
+ </Box>
+ <Box
+ component="h1"
+ sx={{
+ color: textBase,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 18,
+ fontWeight: 700,
+ justifySelf: "center",
+ lineHeight: "24px",
+ m: 0,
+ }}
+ >
+ Profile
+ </Box>
+ </Box>
+
+ <Box
+ component="section"
+ sx={{
+ display: "flex",
+ flexDirection: "column",
+ gap: "8px",
+ mt: "24px",
+ px: "14px",
+ width: "100%",
+ }}
+ >
+ <SettingsRow
+ icon={UserEdit01Icon}
+ label="Change name"
+ onClick={onChangeName}
+ />
+ <SettingsRow
+ icon={Camera01Icon}
+ label="Change profile picture"
+ onClick={onChangeProfilePicture}
+ />
+ <SettingsRow
+ icon={Image01Icon}
+ label="Change cover image"
+ onClick={onChangeCoverImage}
+ />
+ </Box>
+ </Box>
+ </Box>
+);
+
+export const ChangeNameSettingsScreen: React.FC<
+ ChangeNameSettingsScreenProps
+> = ({ errorMessage, initialName, isSaving = false, onBack, onSave }) => {
+ const [name, setName] = React.useState(initialName);
+ const trimmedName = name.trim();
+ const canSave =
+ !isSaving &&
+ trimmedName.length > 0 &&
+ trimmedName != initialName.trim();
+
+ const handleSubmit: React.FormEventHandler<HTMLFormElement> = (event) => {
+ event.preventDefault();
+ if (canSave) onSave(trimmedName);
+ };
+
+ return (
+ <Box
+ component="main"
+ sx={{
+ bgcolor: settingsBackground,
+ color: textBase,
+ display: "grid",
+ minHeight: "100svh",
+ overflowX: "hidden",
+ placeItems: { xs: "stretch", sm: "start center" },
+ }}
+ >
+ <Box
+ sx={{
+ bgcolor: settingsBackground,
+ boxSizing: "border-box",
+ display: "flex",
+ flexDirection: "column",
+ minHeight: "100svh",
+ mx: "auto",
+ width: "100%",
+ "@media (min-width: 600px)": { maxWidth: 390 },
+ }}
+ >
+ <Box
+ component="header"
+ sx={{
+ alignItems: "center",
+ display: "grid",
+ gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,
+ height: 56,
+ px: 2,
+ width: "100%",
+ }}
+ >
+ <Box
+ component="button"
+ type="button"
+ aria-label="Back to profile settings"
+ onClick={onBack}
+ sx={{
+ alignItems: "center",
+ bgcolor: "transparent",
+ border: 0,
+ color: textBase,
+ cursor: "pointer",
+ display: "flex",
+ height: spaceTouchTargetSize,
+ justifyContent: "flex-start",
+ ml: "-2px",
+ p: 0,
+ width: spaceTouchTargetSize,
+ "&:focus-visible": {
+ borderRadius: "50%",
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <HugeiconsIcon
+ icon={ArrowLeft02Icon}
+ size={24}
+ strokeWidth={1.8}
+ />
+ </Box>
+ <Box
+ component="h1"
+ sx={{
+ color: textBase,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 18,
+ fontWeight: 700,
+ justifySelf: "center",
+ lineHeight: "24px",
+ m: 0,
+ }}
+ >
+ Change name
+ </Box>
+ </Box>
+
+ <Box
+ component="form"
+ onSubmit={handleSubmit}
+ sx={{
+ boxSizing: "border-box",
+ display: "flex",
+ flex: 1,
+ flexDirection: "column",
+ width: "100%",
+ }}
+ >
+ <Box sx={{ px: "14px", pt: "24px", width: "100%" }}>
+ <Box
+ component="label"
+ htmlFor="space-profile-name"
+ sx={{
+ color: textBase,
+ display: "block",
+ fontFamily:
+ '"Inter Variable", Inter, sans-serif',
+ fontSize: 14,
+ fontWeight: 500,
+ lineHeight: "20px",
+ mb: "9px",
+ }}
+ >
+ Name
+ </Box>
+ <Box
+ sx={{
+ alignItems: "center",
+ bgcolor: rowBackground,
+ borderRadius: "16px",
+ display: "flex",
+ height: 52,
+ px: 2,
+ width: "100%",
+ "&:focus-within": {
+ outline: `2px solid ${green}`,
+ outlineOffset: 1,
+ },
+ }}
+ >
+ <Box
+ id="space-profile-name"
+ component="input"
+ autoComplete="name"
+ onChange={(event) =>
+ setName(event.target.value)
+ }
+ placeholder="Enter your name"
+ type="text"
+ value={name}
+ sx={{
+ bgcolor: "transparent",
+ border: 0,
+ color: textBase,
+ flex: 1,
+ fontFamily:
+ '"Inter Variable", Inter, sans-serif',
+ fontSize: 14,
+ fontWeight: 500,
+ lineHeight: "20px",
+ minWidth: 0,
+ outline: 0,
+ p: 0,
+ "&::placeholder": {
+ color: textLight,
+ opacity: 1,
+ },
+ }}
+ />
+ </Box>
+ </Box>
+
+ {errorMessage && (
+ <Box
+ role="alert"
+ sx={{
+ color: dangerColor,
+ fontFamily:
+ '"Inter Variable", Inter, sans-serif',
+ fontSize: 13,
+ fontWeight: 500,
+ lineHeight: "18px",
+ mt: 2,
+ px: "14px",
+ }}
+ >
+ {errorMessage}
+ </Box>
+ )}
+
+ <Box sx={{ flex: 1, minHeight: 72 }} />
+
+ <Box
+ sx={{
+ boxSizing: "border-box",
+ mb: "calc(24px + env(safe-area-inset-bottom))",
+ px: 3,
+ width: "100%",
+ }}
+ >
+ <Box
+ className="green-bg"
+ component="button"
+ type="submit"
+ aria-label={isSaving ? "Saving name" : undefined}
+ aria-busy={isSaving ? true : undefined}
+ disabled={!canSave}
+ sx={{
+ alignItems: "center",
+ bgcolor: green,
+ border: 0,
+ borderRadius: "20px",
+ color: "white",
+ cursor: canSave ? "pointer" : "default",
+ display: "flex",
+ fontFamily:
+ '"Inter Variable", Inter, sans-serif',
+ fontSize: 14,
+ fontWeight: 500,
+ height: 44,
+ justifyContent: "center",
+ lineHeight: "20px",
+ opacity: canSave || isSaving ? 1 : 0.45,
+ px: 2,
+ width: "100%",
+ "&:focus-visible": {
+ outline: `2px solid ${green}`,
+ outlineOffset: 3,
+ },
+ "&:hover": {
+ bgcolor: canSave ? "#07AE22" : green,
+ },
+ }}
+ >
+ {isSaving ? <SpaceButtonSpinner /> : "Save"}
+ </Box>
+ </Box>
+ </Box>
+ </Box>
+ </Box>
+ );
+};
diff --git a/web/apps/space/src/utils/spaceRoutes.ts b/web/apps/space/src/utils/spaceRoutes.ts
index 7016b03e86..86ee00ecd5 100644
--- a/web/apps/space/src/utils/spaceRoutes.ts
+++ b/web/apps/space/src/utils/spaceRoutes.ts
@@ -1,9 +1,15 @@
export type SetupProfileSource = "login" | "verify";
+export type ProfileImageFlowSource = "profile" | "settings";
export type VerifyFlow = "login" | "signup";
const valueFromQuery = (value: string | string[] | undefined) =>
Array.isArray(value) ? value[0] : value;
+const routeWithProfileImageFlowSource = (
+ route: string,
+ source?: ProfileImageFlowSource,
+) => (source == "settings" ? `${route}?from=settings` : route);
+
export const spaceRoutes = {
friend: (spaceId: string) => `/app/friends/${encodeURIComponent(spaceId)}`,
friends: "/app/friends",
@@ -17,11 +23,21 @@ export const spaceRoutes = {
passkeysFinish: "/passkeys/finish",
passkeysVerify: "/passkeys/verify",
editProfileCover: "/app/profile/cover-edit",
+ editProfileCoverFrom: (source?: ProfileImageFlowSource) =>
+ routeWithProfileImageFlowSource("/app/profile/cover-edit", source),
editProfilePhoto: "/app/profile/photo-edit",
+ editProfilePhotoFrom: (source?: ProfileImageFlowSource) =>
+ routeWithProfileImageFlowSource("/app/profile/photo-edit", source),
profile: "/app/profile",
profileCover: "/app/profile/cover",
+ profileCoverFrom: (source?: ProfileImageFlowSource) =>
+ routeWithProfileImageFlowSource("/app/profile/cover", source),
profilePhoto: "/app/profile/photo",
+ profilePhotoFrom: (source?: ProfileImageFlowSource) =>
+ routeWithProfileImageFlowSource("/app/profile/photo", source),
settings: "/app/settings",
+ settingsProfile: "/app/settings/profile",
+ settingsProfileName: "/app/settings/profile/name",
setupProfile: (from?: SetupProfileSource) =>
from == "login" ? "/setup-profile?from=login" : "/setup-profile",
signup: "/signup",
@@ -40,5 +56,10 @@ export const setupProfileSourceFromQuery = (
): SetupProfileSource =>
valueFromQuery(value) == "login" ? "login" : "verify";
+export const profileImageFlowSourceFromQuery = (
+ value: string | string[] | undefined,
+): ProfileImageFlowSource =>
+ valueFromQuery(value) == "settings" ? "settings" : "profile";
+
export const friendSpaceIdFromQuery = (value: string | string[] | undefined) =>
valueFromQuery(value) ?? "";