Merge branch 'dev-clone' of https://github.com/digitalsolutiongroup/amati into dev-clone

This commit is contained in:
Sukma Gladys 2024-11-06 08:24:42 +07:00
commit 27446b241e
7 changed files with 104 additions and 99 deletions

View File

@ -4,7 +4,9 @@ import { aspects } from "../schema/aspects";
import { eq, and } from "drizzle-orm"; import { eq, and } from "drizzle-orm";
const subAspectSeeder = async () => { const subAspectSeeder = async () => {
const subAspectsData: (typeof subAspects.$inferInsert & { aspectName: string })[] = [ const subAspectsData: (typeof subAspects.$inferInsert & {
aspectName: string;
})[] = [
/////// Aspect 1 /////// Aspect 1
{ {
name: "Kesadaran", name: "Kesadaran",
@ -114,7 +116,7 @@ const subAspectSeeder = async () => {
aspectName: "Proteksi", aspectName: "Proteksi",
}, },
{ {
name: "Manajemen Identitas dan Aset", name: "Manajemen Identitas dan Akses",
createdAt: new Date(), createdAt: new Date(),
updatedAt: new Date(), updatedAt: new Date(),
deletedAt: null, deletedAt: null,

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -62,68 +62,78 @@ export default function AppHeader({ toggle }: Props) {
</Button> </Button>
)} )}
<img src={logo} alt="" className="w-44 h-fit px-8 py-5" /> <img
src={logo}
alt=""
className="w-44 h-fit px-8 py-5 object-cover"
/>
</div> </div>
{/* Conditional Navlinks */} {/* Conditional Navlinks */}
{!isSuperAdmin && ( {!isSuperAdmin && (
<div className="flex space-x-4 justify-center w-full"> <div className="flex space-x-4 justify-center w-full">
{showAssessmentResultLinks && ( {showAssessmentResultLinks && (
<> <>
<Link <Link
to="/assessmentRequest" to="/assessmentRequest"
className={cx("text-sm font-medium", { className={cx("text-sm font-medium", {
"text-blue-600": assessmentRequestsLinks, // warna aktif "text-blue-600":
"text-gray-700": !assessmentRequestsLinks, // warna default assessmentRequestsLinks, // warna aktif
})} "text-gray-700":
onClick={() => { !assessmentRequestsLinks, // warna default
if (window.opener) { })}
window.close(); onClick={() => {
} if (window.opener) {
}} window.close();
> }
Permohonan Assessment }}
</Link> >
<Link Permohonan Assessment
to="/assessmentResult" </Link>
className={cx("text-sm font-medium", { <Link
"text-blue-600": showAssessmentResultLinks, // warna aktif to="/assessmentResult"
"text-gray-700": !showAssessmentResultLinks, // warna default className={cx("text-sm font-medium", {
})} "text-blue-600":
> showAssessmentResultLinks, // warna aktif
Hasil Assessment "text-gray-700":
</Link> !showAssessmentResultLinks, // warna default
</> })}
)} >
Hasil Assessment
</Link>
</>
)}
{showAssessmentLinks && ( {showAssessmentLinks && (
<> <>
<Link <Link
to="/assessmentRequest" to="/assessmentRequest"
className={cx("text-sm font-medium", { className={cx("text-sm font-medium", {
"text-blue-600": assessmentRequestsLinks, // warna aktif "text-blue-600":
"text-gray-700": !assessmentRequestsLinks, // warna default assessmentRequestsLinks, // warna aktif
})} "text-gray-700":
onClick={() => { !assessmentRequestsLinks, // warna default
if (window.opener) { })}
window.close(); onClick={() => {
} if (window.opener) {
}} window.close();
> }
Permohonan Assessment }}
</Link> >
<Link Permohonan Assessment
to="/assessment" </Link>
className={cx("text-sm font-medium", { <Link
"text-blue-600": showAssessmentLinks, // warna aktif to="/assessment"
"text-gray-700": !showAssessmentLinks, // warna default className={cx("text-sm font-medium", {
})} "text-blue-600": showAssessmentLinks, // warna aktif
> "text-gray-700": !showAssessmentLinks, // warna default
Assessment })}
</Link> >
</> Assessment
)} </Link>
</div> </>
)}
</div>
)} )}
<DropdownMenu <DropdownMenu
@ -142,7 +152,9 @@ export default function AppHeader({ toggle }: Props) {
{user?.photoProfile ? ( {user?.photoProfile ? (
<AvatarImage src={user.photoProfile} /> <AvatarImage src={user.photoProfile} />
) : ( ) : (
<AvatarFallback>{user?.name?.charAt(0) ?? "A"}</AvatarFallback> <AvatarFallback>
{user?.name?.charAt(0) ?? "A"}
</AvatarFallback>
)} )}
</Avatar> </Avatar>
</div> </div>

View File

@ -16,6 +16,7 @@ import { Route as rootRoute } from './routes/__root'
import { Route as VerifyingLayoutImport } from './routes/_verifyingLayout' import { Route as VerifyingLayoutImport } from './routes/_verifyingLayout'
import { Route as DashboardLayoutImport } from './routes/_dashboardLayout' import { Route as DashboardLayoutImport } from './routes/_dashboardLayout'
import { Route as AssessmentLayoutImport } from './routes/_assessmentLayout' import { Route as AssessmentLayoutImport } from './routes/_assessmentLayout'
import { Route as LoginIndexImport } from './routes/login/index'
import { Route as VerifyingLayoutVerifyingIndexImport } from './routes/_verifyingLayout/verifying/index' import { Route as VerifyingLayoutVerifyingIndexImport } from './routes/_verifyingLayout/verifying/index'
import { Route as DashboardLayoutUsersIndexImport } from './routes/_dashboardLayout/users/index' import { Route as DashboardLayoutUsersIndexImport } from './routes/_dashboardLayout/users/index'
import { Route as DashboardLayoutTimetableIndexImport } from './routes/_dashboardLayout/timetable/index' import { Route as DashboardLayoutTimetableIndexImport } from './routes/_dashboardLayout/timetable/index'
@ -32,7 +33,6 @@ import { Route as AssessmentLayoutAssessmentIndexImport } from './routes/_assess
const IndexLazyImport = createFileRoute('/')() const IndexLazyImport = createFileRoute('/')()
const RegisterIndexLazyImport = createFileRoute('/register/')() const RegisterIndexLazyImport = createFileRoute('/register/')()
const LogoutIndexLazyImport = createFileRoute('/logout/')() const LogoutIndexLazyImport = createFileRoute('/logout/')()
const LoginIndexLazyImport = createFileRoute('/login/')()
const ForgotPasswordIndexLazyImport = createFileRoute('/forgot-password/')() const ForgotPasswordIndexLazyImport = createFileRoute('/forgot-password/')()
const ForgotPasswordVerifyLazyImport = createFileRoute( const ForgotPasswordVerifyLazyImport = createFileRoute(
'/forgot-password/verify', '/forgot-password/verify',
@ -72,11 +72,6 @@ const LogoutIndexLazyRoute = LogoutIndexLazyImport.update({
getParentRoute: () => rootRoute, getParentRoute: () => rootRoute,
} as any).lazy(() => import('./routes/logout/index.lazy').then((d) => d.Route)) } as any).lazy(() => import('./routes/logout/index.lazy').then((d) => d.Route))
const LoginIndexLazyRoute = LoginIndexLazyImport.update({
path: '/login/',
getParentRoute: () => rootRoute,
} as any).lazy(() => import('./routes/login/index.lazy').then((d) => d.Route))
const ForgotPasswordIndexLazyRoute = ForgotPasswordIndexLazyImport.update({ const ForgotPasswordIndexLazyRoute = ForgotPasswordIndexLazyImport.update({
path: '/forgot-password/', path: '/forgot-password/',
getParentRoute: () => rootRoute, getParentRoute: () => rootRoute,
@ -84,6 +79,11 @@ const ForgotPasswordIndexLazyRoute = ForgotPasswordIndexLazyImport.update({
import('./routes/forgot-password/index.lazy').then((d) => d.Route), import('./routes/forgot-password/index.lazy').then((d) => d.Route),
) )
const LoginIndexRoute = LoginIndexImport.update({
path: '/login/',
getParentRoute: () => rootRoute,
} as any)
const ForgotPasswordVerifyLazyRoute = ForgotPasswordVerifyLazyImport.update({ const ForgotPasswordVerifyLazyRoute = ForgotPasswordVerifyLazyImport.update({
path: '/forgot-password/verify', path: '/forgot-password/verify',
getParentRoute: () => rootRoute, getParentRoute: () => rootRoute,
@ -222,6 +222,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ForgotPasswordVerifyLazyImport preLoaderRoute: typeof ForgotPasswordVerifyLazyImport
parentRoute: typeof rootRoute parentRoute: typeof rootRoute
} }
'/login/': {
id: '/login/'
path: '/login'
fullPath: '/login'
preLoaderRoute: typeof LoginIndexImport
parentRoute: typeof rootRoute
}
'/forgot-password/': { '/forgot-password/': {
id: '/forgot-password/' id: '/forgot-password/'
path: '/forgot-password' path: '/forgot-password'
@ -229,13 +236,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ForgotPasswordIndexLazyImport preLoaderRoute: typeof ForgotPasswordIndexLazyImport
parentRoute: typeof rootRoute parentRoute: typeof rootRoute
} }
'/login/': {
id: '/login/'
path: '/login'
fullPath: '/login'
preLoaderRoute: typeof LoginIndexLazyImport
parentRoute: typeof rootRoute
}
'/logout/': { '/logout/': {
id: '/logout/' id: '/logout/'
path: '/logout' path: '/logout'
@ -344,8 +344,8 @@ export const routeTree = rootRoute.addChildren({
VerifyingLayoutVerifyingIndexRoute, VerifyingLayoutVerifyingIndexRoute,
}), }),
ForgotPasswordVerifyLazyRoute, ForgotPasswordVerifyLazyRoute,
LoginIndexRoute,
ForgotPasswordIndexLazyRoute, ForgotPasswordIndexLazyRoute,
LoginIndexLazyRoute,
LogoutIndexLazyRoute, LogoutIndexLazyRoute,
RegisterIndexLazyRoute, RegisterIndexLazyRoute,
}) })
@ -363,8 +363,8 @@ export const routeTree = rootRoute.addChildren({
"/_dashboardLayout", "/_dashboardLayout",
"/_verifyingLayout", "/_verifyingLayout",
"/forgot-password/verify", "/forgot-password/verify",
"/forgot-password/",
"/login/", "/login/",
"/forgot-password/",
"/logout/", "/logout/",
"/register/" "/register/"
] ]
@ -400,12 +400,12 @@ export const routeTree = rootRoute.addChildren({
"/forgot-password/verify": { "/forgot-password/verify": {
"filePath": "forgot-password/verify.lazy.tsx" "filePath": "forgot-password/verify.lazy.tsx"
}, },
"/login/": {
"filePath": "login/index.tsx"
},
"/forgot-password/": { "/forgot-password/": {
"filePath": "forgot-password/index.lazy.tsx" "filePath": "forgot-password/index.lazy.tsx"
}, },
"/login/": {
"filePath": "login/index.lazy.tsx"
},
"/logout/": { "/logout/": {
"filePath": "logout/index.lazy.tsx" "filePath": "logout/index.lazy.tsx"
}, },

View File

@ -1,27 +1,17 @@
import { createLazyFileRoute, useNavigate } from "@tanstack/react-router"; import { createLazyFileRoute, Navigate } from "@tanstack/react-router";
import { useEffect } from "react";
export const Route = createLazyFileRoute("/")({ export const Route = createLazyFileRoute("/")({
component: HomePage, component: HomePage,
}); });
export default function HomePage() { export default function HomePage() {
const navigate = useNavigate(); const userRole = JSON.parse(localStorage.getItem("userRole") || "{}");
const userRole = JSON.parse(localStorage.getItem('userRole') || '{}');
useEffect(() => { return userRole === "super-admin" ? (
if (userRole === "super-admin") { <Navigate to="/users" replace />
navigate({ ) : userRole === "user" ? (
to: "/users", <Navigate to="/assessmentRequest" replace />
replace: true, ) : (
}); <Navigate to="/login" replace />
} else if (userRole === "user") { );
navigate({
to: "/assessmentRequest",
replace: true,
});
}
}, [navigate]);
return <div>index.lazy</div>;
} }

View File

@ -1,4 +1,4 @@
import { createLazyFileRoute, useNavigate } from "@tanstack/react-router"; import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { useMutation } from "@tanstack/react-query"; import { useMutation } from "@tanstack/react-query";
import { Input } from '@/shadcn/components/ui/input.tsx'; import { Input } from '@/shadcn/components/ui/input.tsx';
import { Button } from '@/shadcn/components/ui/button.tsx'; import { Button } from '@/shadcn/components/ui/button.tsx';
@ -21,7 +21,7 @@ import useAuth from "@/hooks/useAuth";
import { TbArrowNarrowRight } from "react-icons/tb"; import { TbArrowNarrowRight } from "react-icons/tb";
import amatilogo from "@/assets/logos/amati-logo.png"; import amatilogo from "@/assets/logos/amati-logo.png";
export const Route = createLazyFileRoute("/login/")({ export const Route = createFileRoute("/login/")({
component: LoginPage, component: LoginPage,
}); });
@ -36,6 +36,7 @@ const formSchema = z.object({
}); });
export default function LoginPage() { export default function LoginPage() {
console.log("hii");
const [errorMessage, setErrorMessage] = useState(""); const [errorMessage, setErrorMessage] = useState("");
const navigate = useNavigate(); const navigate = useNavigate();