fix: notifications now are not transparent. Modals for my account now close whe nfinished
This commit is contained in:
parent
7ca98d0cfb
commit
415d9d14a6
|
@ -60,7 +60,7 @@ const ToastAction = React.forwardRef<
|
||||||
<ToastPrimitives.Action
|
<ToastPrimitives.Action
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-background px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
|
@ -6,18 +6,23 @@ import {
|
||||||
ToastProvider,
|
ToastProvider,
|
||||||
ToastTitle,
|
ToastTitle,
|
||||||
ToastViewport,
|
ToastViewport,
|
||||||
} from "~/components/ui/toast"
|
} from "~/components/ui/toast";
|
||||||
import { useToast } from "~/components/ui/use-toast"
|
import { useToast } from "~/components/ui/use-toast";
|
||||||
|
|
||||||
export function Toaster() {
|
export function Toaster() {
|
||||||
const { toasts } = useToast()
|
const { toasts } = useToast();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToastProvider>
|
<ToastProvider>
|
||||||
{toasts.map(({ id, title, description, action, cancelMutation, ...props }) => {
|
{toasts.map(
|
||||||
const undoButton = cancelMutation ? <ToastAction altText="Undo" onClick={cancelMutation}>Undo</ToastAction> : undefined
|
({ id, title, description, action, cancelMutation, ...props }) => {
|
||||||
|
const undoButton = cancelMutation ? (
|
||||||
|
<ToastAction altText="Undo" onClick={cancelMutation}>
|
||||||
|
Undo
|
||||||
|
</ToastAction>
|
||||||
|
) : undefined;
|
||||||
return (
|
return (
|
||||||
<Toast key={id} {...props}>
|
<Toast key={id} {...props} variant={"default"}>
|
||||||
<div className="grid gap-1">
|
<div className="grid gap-1">
|
||||||
{title && <ToastTitle>{title}</ToastTitle>}
|
{title && <ToastTitle>{title}</ToastTitle>}
|
||||||
{description && (
|
{description && (
|
||||||
|
@ -28,9 +33,10 @@ export function Toaster() {
|
||||||
{undoButton}
|
{undoButton}
|
||||||
<ToastClose />
|
<ToastClose />
|
||||||
</Toast>
|
</Toast>
|
||||||
)
|
);
|
||||||
})}
|
},
|
||||||
|
)}
|
||||||
<ToastViewport />
|
<ToastViewport />
|
||||||
</ToastProvider>
|
</ToastProvider>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
useUpdate,
|
useUpdate,
|
||||||
useUpdatePassword,
|
useUpdatePassword,
|
||||||
} from "@refinedev/core";
|
} from "@refinedev/core";
|
||||||
import { useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { Field } from "~/components/forms";
|
import { Field } from "~/components/forms";
|
||||||
import { GeneralLayout } from "~/components/general-layout";
|
import { GeneralLayout } from "~/components/general-layout";
|
||||||
|
@ -53,21 +53,28 @@ export default function MyAccount() {
|
||||||
changeAvatar: false,
|
changeAvatar: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
const closeModal = () => {
|
||||||
<Authenticated key="account" v3LegacyAuthProviderCompatible>
|
|
||||||
<GeneralLayout>
|
|
||||||
<h1 className="text-lg font-bold mb-4">My Account</h1>
|
|
||||||
<Dialog
|
|
||||||
onOpenChange={(open) => {
|
|
||||||
if (!open) {
|
|
||||||
setModal({
|
setModal({
|
||||||
changeEmail: false,
|
changeEmail: false,
|
||||||
changePassword: false,
|
changePassword: false,
|
||||||
setupTwoFactor: false,
|
setupTwoFactor: false,
|
||||||
changeAvatar: false,
|
changeAvatar: false,
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
const isModalOpen = Object.values(openModal).some(isOpen => isOpen);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Authenticated key="account">
|
||||||
|
<GeneralLayout>
|
||||||
|
<h1 className="text-lg font-bold mb-4">My Account</h1>
|
||||||
|
<Dialog
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) {
|
||||||
|
closeModal();
|
||||||
}
|
}
|
||||||
}}>
|
}}
|
||||||
|
open={isModalOpen}
|
||||||
|
>
|
||||||
<UsageCard
|
<UsageCard
|
||||||
label="Usage"
|
label="Usage"
|
||||||
currentUsage={2}
|
currentUsage={2}
|
||||||
|
@ -213,12 +220,12 @@ export default function MyAccount() {
|
||||||
</ManagementCard>
|
</ManagementCard>
|
||||||
</div>
|
</div>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
{openModal.changeAvatar && <ChangeAvatarForm />}
|
{openModal.changeAvatar && <ChangeAvatarForm close={closeModal} />}
|
||||||
{openModal.changeEmail && (
|
{openModal.changeEmail && (
|
||||||
<ChangeEmailForm currentValue={identity?.email || ""} />
|
<ChangeEmailForm currentValue={identity?.email || ""} close={closeModal} />
|
||||||
)}
|
)}
|
||||||
{openModal.changePassword && <ChangePasswordForm />}
|
{openModal.changePassword && <ChangePasswordForm close={closeModal} />}
|
||||||
{openModal.setupTwoFactor && <SetupTwoFactorDialog />}
|
{openModal.setupTwoFactor && <SetupTwoFactorDialog close={closeModal} />}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</GeneralLayout>
|
</GeneralLayout>
|
||||||
|
@ -243,9 +250,9 @@ const ChangeEmailSchema = z
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const ChangeEmailForm = ({ currentValue }: { currentValue: string }) => {
|
const ChangeEmailForm = ({ currentValue, close }: { currentValue: string, close: () => void }) => {
|
||||||
const { data: identity } = useGetIdentity<{ id: BaseKey }>();
|
const { data: identity } = useGetIdentity<{ id: BaseKey }>();
|
||||||
const { mutate: updateEmail } = useUpdate();
|
const { mutate: updateEmail, isSuccess } = useUpdate();
|
||||||
const [form, fields] = useForm({
|
const [form, fields] = useForm({
|
||||||
id: "login",
|
id: "login",
|
||||||
constraint: getZodConstraint(ChangeEmailSchema),
|
constraint: getZodConstraint(ChangeEmailSchema),
|
||||||
|
@ -269,6 +276,12 @@ const ChangeEmailForm = ({ currentValue }: { currentValue: string }) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isSuccess) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}, [isSuccess, close]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
|
@ -320,8 +333,8 @@ const ChangePasswordSchema = z
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const ChangePasswordForm = () => {
|
const ChangePasswordForm = ({ close }: { close: () => void }) => {
|
||||||
const { mutate: updatePassword } =
|
const { mutate: updatePassword, isSuccess } =
|
||||||
useUpdatePassword<UpdatePasswordFormRequest>();
|
useUpdatePassword<UpdatePasswordFormRequest>();
|
||||||
const [form, fields] = useForm({
|
const [form, fields] = useForm({
|
||||||
id: "login",
|
id: "login",
|
||||||
|
@ -342,6 +355,12 @@ const ChangePasswordForm = () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isSuccess) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}, [isSuccess, close]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
|
@ -375,7 +394,7 @@ const ChangePasswordForm = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const SetupTwoFactorDialog = () => {
|
const SetupTwoFactorDialog = ({ close }: { close: () => void }) => {
|
||||||
const [continueModal, setContinue] = useState<boolean>(false);
|
const [continueModal, setContinue] = useState<boolean>(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -414,7 +433,7 @@ const SetupTwoFactorDialog = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ChangeAvatarForm = () => {
|
const ChangeAvatarForm = ({ close }: { close: () => void }) => {
|
||||||
const {
|
const {
|
||||||
getRootProps,
|
getRootProps,
|
||||||
getInputProps,
|
getInputProps,
|
||||||
|
@ -424,9 +443,6 @@ const ChangeAvatarForm = () => {
|
||||||
removeFile,
|
removeFile,
|
||||||
cancelAll,
|
cancelAll,
|
||||||
} = useUppy();
|
} = useUppy();
|
||||||
|
|
||||||
console.log({ state, files: getFiles() });
|
|
||||||
|
|
||||||
const isUploading = state === "uploading";
|
const isUploading = state === "uploading";
|
||||||
const isCompleted = state === "completed";
|
const isCompleted = state === "completed";
|
||||||
const hasStarted = state !== "idle" && state !== "initializing";
|
const hasStarted = state !== "idle" && state !== "initializing";
|
||||||
|
@ -439,6 +455,12 @@ const ChangeAvatarForm = () => {
|
||||||
}
|
}
|
||||||
}, [file]);
|
}, [file]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isCompleted) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}, [isCompleted, close]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DialogHeader className="mb-6">
|
<DialogHeader className="mb-6">
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { Authenticated } from "@refinedev/core";
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
return (
|
return (
|
||||||
<Authenticated key="dashboard" v3LegacyAuthProviderCompatible>
|
<Authenticated key="dashboard">
|
||||||
<GeneralLayout>
|
<GeneralLayout>
|
||||||
<h1 className="font-bold mb-4 text-3xl">Dashboard</h1>
|
<h1 className="font-bold mb-4 text-3xl">Dashboard</h1>
|
||||||
<UpgradeAccountBanner />
|
<UpgradeAccountBanner />
|
||||||
|
|
Loading…
Reference in New Issue