Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,13 @@ export const apiClient = {
},

onboarding: {
get: (guildId: string) => api.get<OnboardingState>(`/api/${guildId}/onboarding`),
get: (guildId: string) =>
api.get<OnboardingState>(`/api/${guildId}/onboarding`, SKIP_ERROR_TOAST),
update: (
guildId: string,
body: { current_step?: number; completed?: boolean; skipped?: boolean },
) => api.post<{ success: boolean }>(`/api/${guildId}/onboarding`, body),
config?: AxiosRequestConfig,
) => api.post<{ success: boolean }>(`/api/${guildId}/onboarding`, body, config),
getFeaturedListings: (guildId: string) =>
api.get<GalleryListing[]>(`/api/${guildId}/gallery/featured`),
},
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/pages/manage/GuildLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function GuildLayout() {
const navigate = useNavigate();
const { selectedGuild, selectGuild, updateGuild } = useGuildStore();
const updateGuildPermission = useAuthStore((s) => s.updateGuildPermission);
const { setState: setOnboardingState } = useOnboardingStore();
const { setState: setOnboardingState, reset: resetOnboarding } = useOnboardingStore();
const [verified, setVerified] = useState(false);
const [bootstrapReady, setBootstrapReady] = useState(false);

Expand All @@ -32,6 +32,7 @@ export default function GuildLayout() {

setVerified(false);
setBootstrapReady(false);
resetOnboarding();

let cancelled = false;

Expand Down Expand Up @@ -155,6 +156,7 @@ export default function GuildLayout() {
updateGuildPermission,
navigate,
setOnboardingState,
resetOnboarding,
isTranscriptView,
]);

Expand All @@ -177,7 +179,7 @@ export default function GuildLayout() {
return (
<GuildBootstrapContext.Provider value={true}>
<GuildContext.Provider value={selectedGuild == undefined ? null : selectedGuild}>
{guildId && (selectedGuild?.permission_level ?? 0) >= 1 && (
{guildId && (selectedGuild?.permission_level ?? 0) >= 2 && (
<OnboardingBanner guildId={guildId} />
)}
<Outlet />
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/pages/manage/setup/SetupLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ function SetupLayoutContent() {
return;
}

if ((g.permission_level ?? 0) < 2) {
selectGuild(null);
toast.warning("You need administrator permissions to access the setup wizard.");
navigate("/", { replace: true });
return;
}

setVerified(false);

const verifyAndLoad = async () => {
Expand Down
13 changes: 10 additions & 3 deletions frontend/src/pages/manage/setup/components/OnboardingBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC } from "react";
import { Link } from "react-router";
import { apiClient } from "@/lib/api";
import { apiClient, SKIP_ERROR_TOAST } from "@/lib/api";
import { useOnboardingStore } from "@/stores/onboarding";
import Button from "@/components/Button";
import { useFeatureFlag } from "@/hooks/useFeatureFlag";
Expand All @@ -17,13 +17,20 @@ const OnboardingBanner: FC<OnboardingBannerProps> = ({ guildId }) => {
guildId,
);

if (!state || state.onboarding_completed || state.skipped || flagLoading || !wizardEnabled) {
if (
!state ||
state.guild_id !== guildId ||
state.onboarding_completed ||
state.skipped ||
flagLoading ||
!wizardEnabled
) {
return null;
}

const handleDismiss = async () => {
try {
await apiClient.onboarding.update(guildId, { skipped: true });
await apiClient.onboarding.update(guildId, { skipped: true }, SKIP_ERROR_TOAST);
setOnboardingState({ ...state, skipped: true });
} catch {
// Silently fail - the banner will persist until next page load
Expand Down
Loading