Skip to content

Commit

Permalink
Fix: Fix posting page
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Aug 29, 2024
1 parent c2438ac commit 35c2886
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
34 changes: 17 additions & 17 deletions frontend/components/ChartForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,19 @@ const ChartForm: React.FC<
onSubmit={(e) => {
e.preventDefault();
if (isEdit) {
updateChart();
} else {
if (
(visibility !== "private") !==
(chartData.visibility !== "private")
) {
if (chartData.visibility !== "private") {
unpublishChart();
} else {
publishChart();
}
} else {
updateChart();
}
} else if (canPost) {
submitChart();
}
}}
Expand Down Expand Up @@ -810,32 +821,21 @@ const ChartForm: React.FC<
(visibility !== "private") !==
(chartData.visibility !== "private") ? (
chartData.visibility !== "private" ? (
<button
className="p-2 w-full button-danger"
onClick={unpublishChart}
>
<button className="p-2 w-full button-danger">
{t("unpublish")}
</button>
) : (
<button
className="p-2 w-full button-primary"
onClick={publishChart}
>
<button className="p-2 w-full button-primary">
{t("publish")}
</button>
)
) : (
<button
className="p-2 w-full button-secondary"
onClick={updateChart}
>
<button className="p-2 w-full button-secondary">
{t("update")}
</button>
)
) : (
<button className="p-2 w-full button-primary" onClick={submitChart}>
{t("submit")}
</button>
<button className="p-2 w-full button-primary">{t("submit")}</button>
)}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/lib/requireLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useNavigate } from "@remix-run/react";
import { createElement } from "react";
import { createElement, useEffect } from "react";
import { useSession } from "./contexts.ts";

const requireLogin = <T extends React.FC<never>>(component: T) => {
Expand All @@ -11,7 +11,7 @@ const requireLogin = <T extends React.FC<never>>(component: T) => {
if (session?.loggedIn === false) {
navigate("/login");
}
}, [session]);
}, [session, navigate]);
if (!session) return <div />;
if (session.loggedIn) return createElement(component, props);
return <div />;
Expand Down

0 comments on commit 35c2886

Please sign in to comment.