base con autenticacion, registro, modulo encuestas

This commit is contained in:
2025-06-16 12:02:22 -04:00
commit 475e0754df
411 changed files with 26265 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
'use client';
import { usePathname } from 'next/navigation';
import { useMemo } from 'react';
type BreadcrumbItem = {
title: string;
link: string;
};
// This allows to add custom title as well
const routeMapping: Record<string, BreadcrumbItem[]> = {
'/dashboard': [{ title: 'Dashboard', link: '/dashboard' }],
'/dashboard/employee': [
{ title: 'Dashboard', link: '/dashboard' },
{ title: 'Employee', link: '/dashboard/employee' }
],
'/dashboard/product': [
{ title: 'Dashboard', link: '/dashboard' },
{ title: 'Product', link: '/dashboard/product' }
]
// Add more custom mappings as needed
};
export function useBreadcrumbs() {
const pathname = usePathname();
const breadcrumbs = useMemo(() => {
// Check if we have a custom mapping for this exact path
if (routeMapping[pathname]) {
return routeMapping[pathname];
}
// If no exact match, fall back to generating breadcrumbs from the path
const segments = pathname.split('/').filter(Boolean);
return segments.map((segment, index) => {
const path = `/${segments.slice(0, index + 1).join('/')}`;
return {
title: segment.charAt(0).toUpperCase() + segment.slice(1),
link: path
};
});
}, [pathname]);
return breadcrumbs;
}

View File

@@ -0,0 +1,19 @@
import * as React from "react"
const MOBILE_BREAKPOINT = 768
export function useIsMobile() {
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
}
mql.addEventListener("change", onChange)
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
return () => mql.removeEventListener("change", onChange)
}, [])
return !!isMobile
}

View File

@@ -0,0 +1,13 @@
import { UseQueryOptions, useQuery } from '@tanstack/react-query'
export function useSafeQuery<T, K = unknown>(
queryKey: [string, K?],
queryFn: () => Promise<T>,
options?: Omit<UseQueryOptions<T>, 'queryKey' | 'queryFn'>
) {
return useQuery({
queryKey,
queryFn,
...options,
})
}