fix login logout redirect

This commit is contained in:
Rizky 2024-07-12 21:40:39 -07:00
parent b661ec752b
commit f302ac6d74
4 changed files with 26 additions and 20 deletions

View File

@ -151,7 +151,13 @@ export const Form: FC<FMProps> = (props) => {
onSubmit={(e) => {
e.preventDefault();
e.stopPropagation();
fm.status = "saving";
fm.render();
fm.submit();
fm.status = "ready";
fm.render();
}}
ref={(el) => {
if (el) {
@ -168,7 +174,6 @@ export const Form: FC<FMProps> = (props) => {
className={cx(
"form c-flex-1 c-w-full c-h-full c-relative c-overflow-auto"
)}
action="#"
>
{toaster_el && createPortal(<Toaster cn={cx} />, toaster_el)}
<div

View File

@ -126,7 +126,7 @@ export { ButtonUpload } from "@/preset/profile/ButtonUpload";
export { Profile } from "@/preset/profile/Profile";
export { generateProfile } from "@/preset/profile/utils/generate";
export { formatTime, longDate, shortDate, timeAgo } from "@/utils/date";
export { getPathname } from "@/utils/pathname";
export { getPathname, getBasename } from "@/utils/pathname";
export * from "@/comps/ui/input";

View File

@ -1,4 +1,4 @@
import { getPathname } from "lib/utils/pathname";
import { getBasename, getPathname } from "lib/utils/pathname";
import get from "lodash.get";
const w = window as any;
@ -20,5 +20,6 @@ export const logout = (url_login?: string) => {
if (localStorage.getItem("user" + id_site)) {
localStorage.removeItem("user" + id_site);
}
if (url_login) navigate(url_login);
if (url_login !== getPathname())
location.href = `${getBasename()}${url_login}`;
};

View File

@ -1,5 +1,5 @@
export const getPathname = (url?: string) => {
// if (["localhost", "prasi.avolut.com"].includes(location.hostname)) {
if (["prasi.avolut.com"].includes(location.hostname)) {
if (
location.pathname.startsWith("/vi") ||
location.pathname.startsWith("/prod") ||
@ -16,7 +16,7 @@ export const getPathname = (url?: string) => {
return "/" + location.pathname.split("/").slice(3).join("/");
}
}
// }
}
return location.pathname;
};