20 lines
362 B
TypeScript
20 lines
362 B
TypeScript
type AuthenticatedSidebarActionOptions = {
|
|
action: () => void;
|
|
isAuthenticated: boolean;
|
|
onRequireLogin: () => void;
|
|
};
|
|
|
|
export function runAuthenticatedSidebarAction({
|
|
action,
|
|
isAuthenticated,
|
|
onRequireLogin,
|
|
}: AuthenticatedSidebarActionOptions) {
|
|
if (!isAuthenticated) {
|
|
onRequireLogin();
|
|
return false;
|
|
}
|
|
|
|
action();
|
|
return true;
|
|
}
|