Develop QR code generator app for campaign

This commit is contained in:
Hafid Nur
2026-02-14 16:38:15 +07:00
parent c79580b4ea
commit 5bb5a05a25
36 changed files with 3384 additions and 941 deletions
@@ -0,0 +1,21 @@
import React from 'react';
import { Navigate, useLocation } from 'react-router-dom';
import { useAuthStore } from '../../../features/auth/store/auth.store';
interface RequireAuthProps {
children: JSX.Element;
}
export const RequireAuth = ({ children }: RequireAuthProps) => {
const isAuthenticated = useAuthStore((state) => state.isAuthenticated);
const location = useLocation();
if (!isAuthenticated) {
// Redirect them to the /login page, but save the current location they were
// trying to go to when they were redirected. This allows us to send them
// along to that page after they login, which is a nicer user experience.
return <Navigate to="/login" state={{ from: location }} replace />;
}
return children;
};