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";
const subAspectSeeder = async () => {
const subAspectsData: (typeof subAspects.$inferInsert & { aspectName: string })[] = [
const subAspectsData: (typeof subAspects.$inferInsert & {
aspectName: string;
})[] = [
/////// Aspect 1
{
name: "Kesadaran",
@ -114,7 +116,7 @@ const subAspectSeeder = async () => {
aspectName: "Proteksi",
},
{
name: "Manajemen Identitas dan Aset",
name: "Manajemen Identitas dan Akses",
createdAt: new Date(),
updatedAt: new Date(),
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>
)}
<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>
{/* Conditional Navlinks */}
{!isSuperAdmin && (
<div className="flex space-x-4 justify-center w-full">
{showAssessmentResultLinks && (
<>
<Link
to="/assessmentRequest"
className={cx("text-sm font-medium", {
"text-blue-600": assessmentRequestsLinks, // warna aktif
"text-gray-700": !assessmentRequestsLinks, // warna default
})}
onClick={() => {
if (window.opener) {
window.close();
}
}}
>
Permohonan Assessment
</Link>
<Link
to="/assessmentResult"
className={cx("text-sm font-medium", {
"text-blue-600": showAssessmentResultLinks, // warna aktif
"text-gray-700": !showAssessmentResultLinks, // warna default
})}
>
Hasil Assessment
</Link>
</>
)}
<div className="flex space-x-4 justify-center w-full">
{showAssessmentResultLinks && (
<>
<Link
to="/assessmentRequest"
className={cx("text-sm font-medium", {
"text-blue-600":
assessmentRequestsLinks, // warna aktif
"text-gray-700":
!assessmentRequestsLinks, // warna default
})}
onClick={() => {
if (window.opener) {
window.close();
}
}}
>
Permohonan Assessment
</Link>
<Link
to="/assessmentResult"
className={cx("text-sm font-medium", {
"text-blue-600":
showAssessmentResultLinks, // warna aktif
"text-gray-700":
!showAssessmentResultLinks, // warna default
})}
>
Hasil Assessment
</Link>
</>
)}
{showAssessmentLinks && (
<>
<Link
to="/assessmentRequest"
className={cx("text-sm font-medium", {
"text-blue-600": assessmentRequestsLinks, // warna aktif
"text-gray-700": !assessmentRequestsLinks, // warna default
})}
onClick={() => {
if (window.opener) {
window.close();
}
}}
>
Permohonan Assessment
</Link>
<Link
to="/assessment"
className={cx("text-sm font-medium", {
"text-blue-600": showAssessmentLinks, // warna aktif
"text-gray-700": !showAssessmentLinks, // warna default
})}
>
Assessment
</Link>
</>
)}
</div>
{showAssessmentLinks && (
<>
<Link
to="/assessmentRequest"
className={cx("text-sm font-medium", {
"text-blue-600":
assessmentRequestsLinks, // warna aktif
"text-gray-700":
!assessmentRequestsLinks, // warna default
})}
onClick={() => {
if (window.opener) {
window.close();
}
}}
>
Permohonan Assessment
</Link>
<Link
to="/assessment"
className={cx("text-sm font-medium", {
"text-blue-600": showAssessmentLinks, // warna aktif
"text-gray-700": !showAssessmentLinks, // warna default
})}
>
Assessment
</Link>
</>
)}
</div>
)}
<DropdownMenu
@ -142,7 +152,9 @@ export default function AppHeader({ toggle }: Props) {
{user?.photoProfile ? (
<AvatarImage src={user.photoProfile} />
) : (
<AvatarFallback>{user?.name?.charAt(0) ?? "A"}</AvatarFallback>
<AvatarFallback>
{user?.name?.charAt(0) ?? "A"}
</AvatarFallback>
)}
</Avatar>
</div>

View File

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

View File

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

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 { Input } from '@/shadcn/components/ui/input.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 amatilogo from "@/assets/logos/amati-logo.png";
export const Route = createLazyFileRoute("/login/")({
export const Route = createFileRoute("/login/")({
component: LoginPage,
});
@ -36,6 +36,7 @@ const formSchema = z.object({
});
export default function LoginPage() {
console.log("hii");
const [errorMessage, setErrorMessage] = useState("");
const navigate = useNavigate();