an app to share curated trails
sidetrail.app
atproto
nextjs
react
rsc
1"use client";
2
3import { useLoginModal } from "@/app/LoginModalContext";
4import { useAuthContext } from "@/app/AuthContext";
5
6export function useAuthAction() {
7 const { openLoginModal } = useLoginModal();
8 const { did } = useAuthContext();
9
10 return <Args extends unknown[], R>(action: (...args: Args) => Promise<R>) =>
11 async (...args: Args): Promise<R | undefined> => {
12 if (did) {
13 return action(...args);
14 } else {
15 openLoginModal();
16 return undefined;
17 }
18 };
19}