π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Refresh family subscription and invite screens
AswinAsok7d2b33ffe71d
diff --git a/web/apps/accounts/src/pages/family.tsx b/web/apps/accounts/src/pages/family.tsxindex 8ab66582ef..d852ead7f4 100644--- a/web/apps/accounts/src/pages/family.tsx+++ b/web/apps/accounts/src/pages/family.tsx@@ -3,11 +3,20 @@ import {getFamilyInviteInfo,type FamilyInviteInfo,} from "@/services/family";+import CloseIcon from "@mui/icons-material/Close";import { Box, Stack, Typography } from "@mui/material";import { AccountsPageContents } from "ente-accounts/components/layouts/centered-paper";import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";import { LoadingButton } from "ente-base/components/mui/LoadingButton";+import {+ v2CancelButtonSx,+ v2CloseButtonSx,+ v2HeaderRowSx,+ v2PaperSx,+ v2SubmitButtonSx,+} from "ente-base/components/SingleInput.styles";+import { isSxArray } from "ente-base/components/utils/sx";import { useBaseContext } from "ente-base/context";import { isHTTPErrorWithStatus } from "ente-base/http";import { t } from "i18next";@@ -68,92 +77,133 @@ const Page: React.FC = () => {}};+ const accepting = phase == "accepting";+ const title = t(+ phase == "accepted"+ ? "family_invite_accepted"+ : phase == "invalid" || phase == "loading"+ ? "family_plan"+ : phase == "failed"+ ? "generic_error_retry"+ : "family_invite_title",+ );+return (- <AccountsPageContents>- {phase == "loading" ? (- <Stack- sx={{- flex: 1,- placeContent: "center",- alignItems: "center",- }}+ <AccountsPageContents+ paperSx={[+ ...(isSxArray(v2PaperSx) ? v2PaperSx : [v2PaperSx]),+ {+ width: "min(420px, calc(100svw - 32px))",+ maxWidth: 420,+ boxSizing: "border-box",+ "&&": { p: "20px" },+ minHeight: 0,+ gap: "20px",+ },+ ]}+ >+ <Stack direction="row" sx={v2HeaderRowSx}>+ <Typography+ component="h1"+ sx={{ fontSize: 20, lineHeight: "28px", fontWeight: 600 }}>+ {title}+ </Typography>+ <FocusVisibleButton+ aria-label={t("close")}+ disabled={accepting}+ href="https://photos.ente.com"+ sx={[+ v2CloseButtonSx,+ { minWidth: 38, borderRadius: "50%" },+ ]}+ >+ <CloseIcon sx={{ fontSize: 18 }} />+ </FocusVisibleButton>+ </Stack>+ {phase == "loading" ? (+ <Stack sx={{ alignItems: "center", py: 4 }}><ActivityIndicator /></Stack>) : phase == "invalid" ? (<FamilyInviteContents>- <Box- component="img"- alt=""- src="/images/family-invite-invalid.png"- sx={{ width: 180, height: "auto" }}- />- <Typography sx={{ color: "text.muted" }}>+ <FamilyInviteIllustration src="/images/family-invite-invalid.png" />+ <FamilyInviteDescription>{t("family_invite_invalid")}- </Typography>- </FamilyInviteContents>- ) : phase == "failed" ? (- <Stack sx={{ flex: 1, placeContent: "center", gap: 3 }}>- <Typography variant="h3" sx={{ textAlign: "center" }}>- {t("generic_error_retry")}- </Typography>+ </FamilyInviteDescription><FocusVisibleButton- onClick={() => void loadInvite(token.current!)}+ fullWidth+ href="https://photos.ente.com"+ sx={[+ v2CancelButtonSx,+ { flex: "none", fontWeight: 600 },+ ]}>- {t("retry")}+ {t("done")}</FocusVisibleButton>- </Stack>+ </FamilyInviteContents>+ ) : phase == "failed" ? (+ <FocusVisibleButton+ fullWidth+ sx={{ ...v2SubmitButtonSx, flex: "none", fontWeight: 600 }}+ onClick={() => void loadInvite(token.current!)}+ >+ {t("retry")}+ </FocusVisibleButton>) : phase == "accepted" ? (<FamilyInviteContents>- <Box- component="img"- alt=""- src="/images/family-invite-accepted.png"- sx={{ width: 200, height: "auto" }}- />- <Stack sx={{ gap: 1.5 }}>- <Typography variant="h3">- {t("family_invite_accepted")}- </Typography>- <Typography sx={{ color: "text.muted" }}>- {t("family_invite_accepted_description", {- email: invite?.adminEmail,- })}- </Typography>- </Stack>+ <FamilyInviteIllustration src="/images/family-invite-accepted.png" />+ <FamilyInviteDescription>+ {t("family_invite_accepted_description", {+ email: invite?.adminEmail,+ })}+ </FamilyInviteDescription><FocusVisibleButton- color="accent"+ fullWidthhref="https://photos.ente.com"+ sx={{+ ...v2SubmitButtonSx,+ flex: "none",+ fontWeight: 600,+ }}>{t("open_ente")}</FocusVisibleButton></FamilyInviteContents>) : (<FamilyInviteContents>- <Box- component="img"- alt=""- src="/images/family-invite.png"- sx={{ width: 160, height: "auto" }}- />+ <FamilyInviteIllustration src="/images/family-invite.png" />+ <FamilyInviteDescription>+ {t("family_invite_description", {+ email: invite?.adminEmail,+ })}+ </FamilyInviteDescription><Stack sx={{ gap: 1.5 }}>- <Typography variant="h3">- {t("family_invite_title")}- </Typography>- <Typography sx={{ color: "text.muted" }}>- {t("family_invite_description", {- email: invite?.adminEmail,- })}- </Typography>+ <LoadingButton+ fullWidth+ disabled={accepting}+ loading={accepting}+ sx={{+ ...v2SubmitButtonSx,+ flex: "none",+ fontWeight: 600,+ }}+ onClick={() => void accept()}+ >+ {t("accept_family_invite")}+ </LoadingButton>+ <FocusVisibleButton+ fullWidth+ disabled={accepting}+ href="https://photos.ente.com"+ sx={[+ v2CancelButtonSx,+ { flex: "none", fontWeight: 600 },+ ]}+ >+ {t("cancel")}+ </FocusVisibleButton></Stack>- <LoadingButton- fullWidth- color="accent"- loading={phase == "accepting"}- onClick={() => void accept()}- >- {t("accept_family_invite")}- </LoadingButton></FamilyInviteContents>)}</AccountsPageContents>@@ -162,18 +212,46 @@ const Page: React.FC = () => {const FamilyInviteContents: React.FC<React.PropsWithChildren> = ({children,+}) => <Stack sx={{ gap: 2 }}>{children}</Stack>;++const FamilyInviteDescription: React.FC<React.PropsWithChildren> = ({+ children,}) => (- <Stack+ <Typographysx={{- flex: 1,- placeContent: "center",- alignItems: "center",- textAlign: "center",- gap: 3,+ fontSize: 14,+ lineHeight: "22px",+ color: "text.muted",+ overflowWrap: "anywhere",}}>{children}- </Stack>+ </Typography>+);++const FamilyInviteIllustration: React.FC<{ src: string }> = ({ src }) => (+ <Box+ sx={(theme) => ({+ height: 142,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ bgcolor: "background.paper",+ borderRadius: "16px",+ ...theme.applyStyles("dark", { bgcolor: "#282828" }),+ })}+ >+ <Box+ component="img"+ alt=""+ src={src}+ sx={{+ maxHeight: 116,+ maxWidth: "min(180px, 100%)",+ objectFit: "contain",+ }}+ />+ </Box>);export default Page;diff --git a/web/apps/photos/src/components/sidebar/accounts/ManageMemberSubscription.tsx b/web/apps/photos/src/components/sidebar/accounts/ManageMemberSubscription.tsxindex e92a5deb94..61def6942f 100644--- a/web/apps/photos/src/components/sidebar/accounts/ManageMemberSubscription.tsx+++ b/web/apps/photos/src/components/sidebar/accounts/ManageMemberSubscription.tsx@@ -1,18 +1,29 @@-import { Box, Dialog, DialogContent, Stack } from "@mui/material";-import Typography from "@mui/material/Typography";-import { SpacedRow } from "ente-base/components/containers";-import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconButton";+import { Cancel01Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import { Avatar, Dialog, IconButton, Stack, Typography } from "@mui/material";+import {+ v2CancelButtonSx,+ v2CloseButtonSx,+ v2HeaderRowSx,+ v2PaperSx,+} from "ente-base/components/SingleInput.styles";import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";-import { useIsSmallWidth } from "ente-base/components/utils/hooks";import type { ModalVisibilityProps } from "ente-base/components/utils/modal";+import { isSxArray } from "ente-base/components/utils/sx";import { useBaseContext } from "ente-base/context";+import {+ uploadSheetMediaQuery,+ uploadSheetPaperSx,+ useIsUploadSheet,+} from "ente-gallery/components/upload-progress/bottom-sheet";+import { SlideUpTransition } from "ente-new/photos/components/mui/SlideUpTransition";import {familyAdminEmail,leaveFamily,type UserDetails,} from "ente-new/photos/services/user-details";import { t } from "i18next";-import React from "react";+import React, { useId } from "react";type ManageMemberSubscriptionProps = ModalVisibilityProps & {userDetails: UserDetails;@@ -22,7 +33,9 @@ export const ManageMemberSubscription: React.FC<ManageMemberSubscriptionProps> = ({ open, onClose, userDetails }) => {const { showMiniDialog } = useBaseContext();- const fullScreen = useIsSmallWidth();+ const isSheet = useIsUploadSheet();+ const titleID = useId();+ const adminEmail = familyAdminEmail(userDetails) ?? "";const confirmLeaveFamily = () =>showMiniDialog({@@ -31,63 +44,150 @@ export const ManageMemberSubscription: React.FC<continue: {text: t("leave"),color: "critical",- action: leaveFamily,+ action: async () => {+ await leaveFamily();+ onClose();+ },},});return (<Dialog- {...{ open, onClose, fullScreen }}- maxWidth="xs"- fullWidth- aria-labelledby="member-subscription-title"+ {...{ open, onClose }}+ maxWidth={false}+ aria-labelledby={titleID}+ slots={isSheet ? { transition: SlideUpTransition } : undefined}slotProps={{- paper: { sx: { borderRadius: fullScreen ? 0 : "20px" } },+ paper: {+ sx: [+ ...(isSxArray(v2PaperSx) ? v2PaperSx : [v2PaperSx]),+ {+ width: "min(420px, calc(100svw - 32px))",+ maxWidth: 420,+ boxSizing: "border-box",+ },+ uploadSheetPaperSx,+ ],+ },}}>- <SpacedRow+ <Stacksx={{- p: "24px 16px 16px 24px",- "& .MuiIconButton-root": { color: "text.muted" },+ p: "20px",+ gap: "20px",+ [uploadSheetMediaQuery]: {+ pb: "calc(20px + env(safe-area-inset-bottom, 0px))",+ },}}>- <Stack sx={{ gap: 0.5 }}>- <Typography variant="h2" id="member-subscription-title">+ <Stack direction="row" sx={v2HeaderRowSx}>+ <Typography+ component="h2"+ id={titleID}+ sx={{+ fontSize: 20,+ lineHeight: "28px",+ fontWeight: 600,+ }}+ >{t("subscription")}</Typography>- <Typography variant="small" sx={{ color: "text.muted" }}>- {t("family_plan")}- </Typography>+ <IconButton+ aria-label={t("close")}+ onClick={onClose}+ sx={v2CloseButtonSx}+ >+ <HugeiconsIcon icon={Cancel01Icon} size={18} />+ </IconButton></Stack>- <DialogCloseIconButton {...{ onClose }} />- </SpacedRow>- <DialogContent sx={{ "&&": { p: "8px 24px 24px" } }}>- <Stack sx={{ gap: 3 }}>- <Box- sx={{- p: 2,- borderRadius: "16px",- bgcolor: "fill.faint",- }}+ <Typography+ sx={{+ fontSize: 12,+ lineHeight: "18px",+ color: "text.muted",+ }}+ >+ {t("family_plan")}+ </Typography>+ <Stack+ direction="row"+ sx={(theme) => ({+ alignItems: "center",+ gap: 1.5,+ p: 2,+ borderRadius: "16px",+ bgcolor: "background.paper",+ ...theme.applyStyles("dark", { bgcolor: "#282828" }),+ })}+ >+ <Avatar+ sx={(theme) => ({+ width: 36,+ height: 36,+ fontSize: 14,+ bgcolor: "#f5d4ee",+ color: "text.base",+ ...theme.applyStyles("dark", {+ bgcolor: "#55334e",+ }),+ })}>- <Typography sx={{ color: "text.muted" }}>+ {adminEmail[0]?.toUpperCase()}+ </Avatar>+ <Stack sx={{ minWidth: 0, gap: 0.5 }}>+ <Typography+ sx={{+ fontSize: 12,+ lineHeight: "18px",+ color: "text.muted",+ }}+ >{t("subscription_info_family")}</Typography>- <Typography sx={{ mt: 0.5, overflowWrap: "anywhere" }}>- {familyAdminEmail(userDetails) ?? ""}+ <Typography+ sx={{+ fontSize: 14,+ lineHeight: "20px",+ fontWeight: 500,+ overflowWrap: "anywhere",+ }}+ >+ {adminEmail}</Typography>- </Box>+ </Stack>+ </Stack>+ <Stack sx={{ gap: 1.5 }}><FocusVisibleButtonfullWidth- variant="contained"- color="critical"onClick={confirmLeaveFamily}- sx={{ borderRadius: "20px", minHeight: 48 }}+ sx={(theme) => ({+ height: 52,+ borderRadius: "20px",+ fontSize: 14,+ lineHeight: "20px",+ fontWeight: 600,+ color: "critical.main",+ bgcolor: "background.paper",+ "&:hover": { bgcolor: "fill.faintHover" },+ ...theme.applyStyles("dark", {+ bgcolor: "#282828",+ }),+ })}>{t("leave_family_plan")}</FocusVisibleButton>+ <FocusVisibleButton+ fullWidth+ onClick={onClose}+ sx={[+ v2CancelButtonSx,+ { flex: "none", fontWeight: 600 },+ ]}+ >+ {t("done")}+ </FocusVisibleButton></Stack>- </DialogContent>+ </Stack></Dialog>);};diff --git a/web/packages/accounts/components/layouts/centered-paper.tsx b/web/packages/accounts/components/layouts/centered-paper.tsxindex 712fedc2b7..49387f2ac0 100644--- a/web/packages/accounts/components/layouts/centered-paper.tsx+++ b/web/packages/accounts/components/layouts/centered-paper.tsx@@ -1,11 +1,18 @@-import { Paper, Stack, styled, Typography } from "@mui/material";+import {+ Paper,+ Stack,+ styled,+ Typography,+ type SxProps,+ type Theme,+} from "@mui/material";import { CenteredFill } from "ente-base/components/containers";import { EnteLogo } from "ente-base/components/EnteLogo";import { NavbarBase } from "ente-base/components/Navbar";-export const AccountsPageContents: React.FC<React.PropsWithChildren> = ({- children,-}) => (+export const AccountsPageContents: React.FC<+ React.PropsWithChildren<{ paperSx?: SxProps<Theme> }>+> = ({ children, paperSx }) => (<Stacksx={[{ minHeight: "100svh", bgcolor: "secondary.main" },@@ -31,7 +38,7 @@ export const AccountsPageContents: React.FC<React.PropsWithChildren> = ({}),]}>- <AccountsPagePaper>{children}</AccountsPagePaper>+ <AccountsPagePaper sx={paperSx}>{children}</AccountsPagePaper></CenteredFill></Stack>);