Merge branch 'dev' of https://github.com/digitalsolutiongroup/amati into assessment-request-frontend
This commit is contained in:
commit
b9b40ddaad
|
|
@ -47,6 +47,15 @@ const permissionsData = [
|
||||||
{
|
{
|
||||||
code: "questions.restore",
|
code: "questions.restore",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
code :"assessmentRequestManagement.readAll",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: "assessmentRequestManagement.update",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code :"assessmentRequestManagement.read",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
code: "managementAspect.readAll",
|
code: "managementAspect.readAll",
|
||||||
},
|
},
|
||||||
|
|
@ -104,6 +113,18 @@ const permissionsData = [
|
||||||
{
|
{
|
||||||
code: "assessments.updateAnswer",
|
code: "assessments.updateAnswer",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
code: "assessments.readAverageSubAspect",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: "assessments.readAverageAllSubAspects",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: "assessments.readAverageAspect",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: "assessments.readAverageAllAspects",
|
||||||
|
},
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type SpecificPermissionCode = (typeof permissionsData)[number]["code"];
|
export type SpecificPermissionCode = (typeof permissionsData)[number]["code"];
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ const sidebarMenus: SidebarMenu[] = [
|
||||||
link: "/dashboard",
|
link: "/dashboard",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Users",
|
label: "Manajemen Pengguna",
|
||||||
icon: { tb: "TbUsers" },
|
icon: { tb: "TbUsers" },
|
||||||
allowedPermissions: ["permissions.read"],
|
allowedPermissions: ["permissions.read"],
|
||||||
link: "/users",
|
link: "/users",
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ export const assessments = pgTable("assessments", {
|
||||||
reviewedAt: timestamp("reviewedAt", { mode: "date" }),
|
reviewedAt: timestamp("reviewedAt", { mode: "date" }),
|
||||||
validatedBy: varchar("validatedBy"),
|
validatedBy: varchar("validatedBy"),
|
||||||
validatedAt: timestamp("validatedAt", { mode: "date" }),
|
validatedAt: timestamp("validatedAt", { mode: "date" }),
|
||||||
createdAt: timestamp("createdAt", { mode: "date" }).defaultNow(),
|
createdAt: timestamp("createdAt", { mode: "date" }).defaultNow(),
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
// Query Tools in PosgreSQL
|
// Query Tools in PosgreSQL
|
||||||
// CREATE TYPE status AS ENUM ('menunggu konfirmasi', 'disetujui', 'ditolak', 'selesai');
|
// CREATE TYPE status AS ENUM ('menunggu konfirmasi', 'diterima', 'ditolak', 'selesai');
|
||||||
|
|
@ -22,6 +22,7 @@ import assessmentResultRoute from "./routes/assessmentResult/route";
|
||||||
import assessmentRequestRoute from "./routes/assessmentRequest/route";
|
import assessmentRequestRoute from "./routes/assessmentRequest/route";
|
||||||
import forgotPasswordRoutes from "./routes/forgotPassword/route";
|
import forgotPasswordRoutes from "./routes/forgotPassword/route";
|
||||||
import assessmentsRoute from "./routes/assessments/route";
|
import assessmentsRoute from "./routes/assessments/route";
|
||||||
|
import assessmentsRequestManagementRoutes from "./routes/assessmentRequestManagement/route";
|
||||||
|
|
||||||
configDotenv();
|
configDotenv();
|
||||||
|
|
||||||
|
|
@ -92,11 +93,13 @@ const routes = app
|
||||||
.route("/assessmentRequest", assessmentRequestRoute)
|
.route("/assessmentRequest", assessmentRequestRoute)
|
||||||
.route("/forgot-password", forgotPasswordRoutes)
|
.route("/forgot-password", forgotPasswordRoutes)
|
||||||
.route("/assessments", assessmentsRoute)
|
.route("/assessments", assessmentsRoute)
|
||||||
|
.route("/assessmentRequestManagement",assessmentsRequestManagementRoutes)
|
||||||
.onError((err, c) => {
|
.onError((err, c) => {
|
||||||
if (err instanceof DashboardError) {
|
if (err instanceof DashboardError) {
|
||||||
return c.json(
|
return c.json(
|
||||||
{
|
{
|
||||||
message: err.message,
|
message: err.message,
|
||||||
|
|
||||||
errorCode: err.errorCode,
|
errorCode: err.errorCode,
|
||||||
formErrors: err.formErrors,
|
formErrors: err.formErrors,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
173
apps/backend/src/routes/assessmentRequestManagement/route.ts
Normal file
173
apps/backend/src/routes/assessmentRequestManagement/route.ts
Normal file
|
|
@ -0,0 +1,173 @@
|
||||||
|
import { and, eq, ilike, or, sql } from "drizzle-orm";
|
||||||
|
import { Hono } from "hono";
|
||||||
|
import checkPermission from "../../middlewares/checkPermission";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { HTTPException } from "hono/http-exception";
|
||||||
|
import db from "../../drizzle";
|
||||||
|
import { assessments } from "../../drizzle/schema/assessments";
|
||||||
|
import { respondents } from "../../drizzle/schema/respondents";
|
||||||
|
import { users } from "../../drizzle/schema/users";
|
||||||
|
import HonoEnv from "../../types/HonoEnv";
|
||||||
|
import requestValidator from "../../utils/requestValidator";
|
||||||
|
import authInfo from "../../middlewares/authInfo";
|
||||||
|
|
||||||
|
export const assessmentFormSchema = z.object({
|
||||||
|
respondentId: z.string().min(1),
|
||||||
|
status: z.enum(["menunggu konfirmasi", "diterima", "ditolak", "selesai"]),
|
||||||
|
reviewedBy: z.string().min(1),
|
||||||
|
validatedBy: z.string().min(1),
|
||||||
|
validatedAt: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const assessmentUpdateSchema = assessmentFormSchema.extend({
|
||||||
|
validatedAt: z.string().optional().or(z.literal("")),
|
||||||
|
});
|
||||||
|
|
||||||
|
const assessmentsRequestManagementRoutes = new Hono<HonoEnv>()
|
||||||
|
.use(authInfo)
|
||||||
|
/**
|
||||||
|
* Get All Assessments (With Metadata)
|
||||||
|
*
|
||||||
|
* Query params:
|
||||||
|
* - withMetadata: boolean
|
||||||
|
*/
|
||||||
|
.get(
|
||||||
|
"/",
|
||||||
|
checkPermission("assessmentRequestManagement.readAll"),
|
||||||
|
requestValidator(
|
||||||
|
"query",
|
||||||
|
z.object({
|
||||||
|
withMetadata: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform((v) => v?.toLowerCase() === "true"),
|
||||||
|
page: z.coerce.number().int().min(0).default(0),
|
||||||
|
limit: z.coerce.number().int().min(1).max(1000).default(10),
|
||||||
|
q: z.string().default(""),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
async (c) => {
|
||||||
|
const { page, limit, q } = c.req.valid("query");
|
||||||
|
|
||||||
|
const totalCountQuery = sql<number>`(SELECT count(*) FROM ${assessments})`;
|
||||||
|
|
||||||
|
const result = await db
|
||||||
|
.select({
|
||||||
|
idPermohonan: assessments.id,
|
||||||
|
namaResponden: users.name,
|
||||||
|
namaPerusahaan: respondents.companyName,
|
||||||
|
status: assessments.status,
|
||||||
|
tanggal: assessments.createdAt,
|
||||||
|
fullCount: totalCountQuery,
|
||||||
|
})
|
||||||
|
.from(assessments)
|
||||||
|
.leftJoin(respondents, eq(assessments.respondentId, respondents.id))
|
||||||
|
.leftJoin(users, eq(respondents.userId, users.id))
|
||||||
|
.where(
|
||||||
|
q
|
||||||
|
? or(
|
||||||
|
ilike(users.name, `%${q}%`),
|
||||||
|
ilike(respondents.companyName, `%${q}%`),
|
||||||
|
eq(assessments.id, q)
|
||||||
|
)
|
||||||
|
: undefined
|
||||||
|
)
|
||||||
|
.offset(page * limit)
|
||||||
|
.limit(limit);
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
data: result.map((d) => ({
|
||||||
|
idPermohonan: d.idPermohonan,
|
||||||
|
namaResponden: d.namaResponden,
|
||||||
|
namaPerusahaan: d.namaPerusahaan,
|
||||||
|
status: d.status,
|
||||||
|
tanggal: d.tanggal,
|
||||||
|
})),
|
||||||
|
_metadata: {
|
||||||
|
currentPage: page,
|
||||||
|
totalPages: Math.ceil(
|
||||||
|
(Number(result[0]?.fullCount) ?? 0) / limit
|
||||||
|
),
|
||||||
|
totalItems: Number(result[0]?.fullCount) ?? 0,
|
||||||
|
perPage: limit,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get assessment by id
|
||||||
|
.get(
|
||||||
|
"/:id",
|
||||||
|
checkPermission("assessmentRequestManagement.read"),
|
||||||
|
async (c) => {
|
||||||
|
const assessmentId = c.req.param("id");
|
||||||
|
|
||||||
|
const queryResult = await db
|
||||||
|
.select({
|
||||||
|
// id: assessments.id,
|
||||||
|
tanggal: assessments.createdAt,
|
||||||
|
nama: users.name,
|
||||||
|
posisi: respondents.position,
|
||||||
|
pengalamanKerja: respondents.workExperience,
|
||||||
|
email: users.email,
|
||||||
|
namaPerusahaan: respondents.companyName,
|
||||||
|
alamat: respondents.address,
|
||||||
|
nomorTelepon: respondents.phoneNumber,
|
||||||
|
username: users.username,
|
||||||
|
status: assessments.status,
|
||||||
|
})
|
||||||
|
.from(assessments)
|
||||||
|
.leftJoin(respondents, eq(assessments.respondentId, respondents.id))
|
||||||
|
.leftJoin(users, eq(respondents.userId, users.id))
|
||||||
|
.where(eq(assessments.id, assessmentId));
|
||||||
|
|
||||||
|
if (!queryResult.length)
|
||||||
|
throw new HTTPException(404, {
|
||||||
|
message: "The assessment does not exist",
|
||||||
|
});
|
||||||
|
|
||||||
|
const assessmentData = queryResult[0];
|
||||||
|
|
||||||
|
return c.json(assessmentData);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
.patch(
|
||||||
|
"/:id",
|
||||||
|
checkPermission("assessmentRequestManagement.update"),
|
||||||
|
requestValidator(
|
||||||
|
"json",
|
||||||
|
z.object({
|
||||||
|
status: z.enum(["menunggu konfirmasi", "diterima", "ditolak", "selesai"]),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
async (c) => {
|
||||||
|
const assessmentId = c.req.param("id");
|
||||||
|
const { status } = c.req.valid("json");
|
||||||
|
|
||||||
|
const assessment = await db
|
||||||
|
.select()
|
||||||
|
.from(assessments)
|
||||||
|
.where(and(eq(assessments.id, assessmentId),));
|
||||||
|
|
||||||
|
if (!assessment[0]) throw new HTTPException(404, {
|
||||||
|
message: "Assessment tidak ditemukan.",
|
||||||
|
});
|
||||||
|
|
||||||
|
await db
|
||||||
|
.update(assessments)
|
||||||
|
.set({
|
||||||
|
status,
|
||||||
|
})
|
||||||
|
.where(eq(assessments.id, assessmentId));
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
message: "Status assessment berhasil diperbarui.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default assessmentsRequestManagementRoutes;
|
||||||
|
|
@ -409,7 +409,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
|
||||||
// Get data for One Sub Aspect average score By Sub Aspect Id and Assessment Id
|
// Get data for One Sub Aspect average score By Sub Aspect Id and Assessment Id
|
||||||
.get(
|
.get(
|
||||||
'/average-score/sub-aspects/:subAspectId/assessments/:assessmentId',
|
'/average-score/sub-aspects/:subAspectId/assessments/:assessmentId',
|
||||||
// checkPermission("assessments.readAssessmentScore"),
|
checkPermission("assessments.readAverageSubAspect"),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const { subAspectId, assessmentId } = c.req.param();
|
const { subAspectId, assessmentId } = c.req.param();
|
||||||
|
|
||||||
|
|
@ -440,7 +440,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
|
||||||
// Get data for All Sub Aspects average score By Assessment Id
|
// Get data for All Sub Aspects average score By Assessment Id
|
||||||
.get(
|
.get(
|
||||||
'/average-score/sub-aspects/assessments/:assessmentId',
|
'/average-score/sub-aspects/assessments/:assessmentId',
|
||||||
// checkPermission("assessments.readAssessmentScore"),
|
checkPermission("assessments.readAverageAllSubAspects"),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const { assessmentId } = c.req.param();
|
const { assessmentId } = c.req.param();
|
||||||
|
|
||||||
|
|
@ -472,6 +472,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
|
||||||
// Get data for One Aspect average score By Aspect Id and Assessment Id
|
// Get data for One Aspect average score By Aspect Id and Assessment Id
|
||||||
.get(
|
.get(
|
||||||
"/average-score/aspects/:aspectId/assessments/:assessmentId",
|
"/average-score/aspects/:aspectId/assessments/:assessmentId",
|
||||||
|
checkPermission("assessments.readAverageAspect"),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const { aspectId, assessmentId } = c.req.param();
|
const { aspectId, assessmentId } = c.req.param();
|
||||||
|
|
||||||
|
|
@ -503,7 +504,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
|
||||||
// Get data for All Aspects average score By Assessment Id
|
// Get data for All Aspects average score By Assessment Id
|
||||||
.get(
|
.get(
|
||||||
'/average-score/aspects/assessments/:assessmentId',
|
'/average-score/aspects/assessments/:assessmentId',
|
||||||
// checkPermission("assessments.readAssessmentScore"),
|
checkPermission("assessments.readAverageAllAspects"),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const { assessmentId } = c.req.param();
|
const { assessmentId } = c.req.param();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { and, eq, ilike, isNull, or, sql } from "drizzle-orm";
|
import { and, eq, ilike, isNull, or, sql, inArray } from "drizzle-orm";
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
import { questions } from "../../drizzle/schema/questions";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import db from "../../drizzle";
|
import db from "../../drizzle";
|
||||||
import { aspects } from "../../drizzle/schema/aspects";
|
import { aspects } from "../../drizzle/schema/aspects";
|
||||||
|
|
@ -33,14 +33,16 @@ export const aspectFormSchema = z.object({
|
||||||
.optional(),
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const aspectUpdateSchema = aspectFormSchema.extend({
|
|
||||||
subAspects: z.string().optional().or(z.literal("")),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Schema for creating and updating subAspects
|
// Schema for creating and updating subAspects
|
||||||
export const subAspectFormSchema = z.object({
|
export const subAspectFormSchema = z.object({
|
||||||
|
id: z.string(),
|
||||||
name: z.string().min(1).max(50),
|
name: z.string().min(1).max(50),
|
||||||
aspectId: z.string().uuid(),
|
aspectId: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const aspectUpdateSchema = z.object({
|
||||||
|
name: z.string(),
|
||||||
|
subAspects: z.array(subAspectFormSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const subAspectUpdateSchema = subAspectFormSchema.extend({});
|
export const subAspectUpdateSchema = subAspectFormSchema.extend({});
|
||||||
|
|
@ -55,140 +57,223 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
||||||
* - withMetadata: boolean
|
* - withMetadata: boolean
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Get all aspects
|
// Get all aspects
|
||||||
.get(
|
.get(
|
||||||
"/",
|
"/",
|
||||||
checkPermission("managementAspect.readAll"),
|
checkPermission("managementAspect.readAll"),
|
||||||
requestValidator(
|
requestValidator(
|
||||||
"query",
|
"query",
|
||||||
z.object({
|
z.object({
|
||||||
includeTrashed: z
|
includeTrashed: z
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
.transform((v) => v?.toLowerCase() === "true"),
|
.transform((v) => v?.toLowerCase() === "true"),
|
||||||
withMetadata: z
|
withMetadata: z
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
.transform((v) => v?.toLowerCase() === "true"),
|
.transform((v) => v?.toLowerCase() === "true"),
|
||||||
page: z.coerce.number().int().min(0).default(0),
|
page: z.coerce.number().int().min(0).default(0),
|
||||||
limit: z.coerce.number().int().min(1).max(1000).default(10),
|
limit: z.coerce.number().int().min(1).max(1000).default(10),
|
||||||
q: z.string().default(""),
|
q: z.string().default(""),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
async (c) => {
|
||||||
|
const { includeTrashed, page, limit, q } = c.req.valid("query");
|
||||||
|
|
||||||
|
const totalCountQuery = includeTrashed
|
||||||
|
? sql<number>`(SELECT count(DISTINCT ${aspects.id}) FROM ${aspects})`
|
||||||
|
: sql<number>`(SELECT count(DISTINCT ${aspects.id}) FROM ${aspects} WHERE ${aspects.deletedAt} IS NULL)`;
|
||||||
|
|
||||||
|
const aspectIdsQuery = await db
|
||||||
|
.select({
|
||||||
|
id: aspects.id,
|
||||||
})
|
})
|
||||||
),
|
.from(aspects)
|
||||||
async (c) => {
|
.where(
|
||||||
const { includeTrashed, page, limit, q } = c.req.valid("query");
|
and(
|
||||||
|
includeTrashed ? undefined : isNull(aspects.deletedAt),
|
||||||
const totalCountQuery = includeTrashed
|
q ? or(ilike(aspects.name, q), eq(aspects.id, q)) : undefined
|
||||||
? sql<number>`(SELECT count(*) FROM ${aspects})`
|
|
||||||
: sql<number>`(SELECT count(*) FROM ${aspects} WHERE ${aspects.deletedAt} IS NULL)`;
|
|
||||||
|
|
||||||
const result = await db
|
|
||||||
.select({
|
|
||||||
id: aspects.id,
|
|
||||||
name: aspects.name,
|
|
||||||
createdAt: aspects.createdAt,
|
|
||||||
updatedAt: aspects.updatedAt,
|
|
||||||
...(includeTrashed ? { deletedAt: aspects.deletedAt } : {}),
|
|
||||||
fullCount: totalCountQuery,
|
|
||||||
})
|
|
||||||
.from(aspects)
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
includeTrashed ? undefined : isNull(aspects.deletedAt),
|
|
||||||
q ? or(ilike(aspects.name, q), eq(aspects.id, q)) : undefined
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.offset(page * limit)
|
)
|
||||||
.limit(limit);
|
.offset(page * limit)
|
||||||
|
.limit(limit);
|
||||||
|
|
||||||
|
const aspectIds = aspectIdsQuery.map(a => a.id);
|
||||||
|
|
||||||
|
if (aspectIds.length === 0) {
|
||||||
return c.json({
|
return c.json({
|
||||||
data: result.map((d) => ({ ...d, fullCount: undefined })),
|
data: [],
|
||||||
_metadata: {
|
_metadata: {
|
||||||
currentPage: page,
|
currentPage: page,
|
||||||
totalPages: Math.ceil((Number(result[0]?.fullCount) ?? 0) / limit),
|
totalPages: 0,
|
||||||
totalItems: Number(result[0]?.fullCount) ?? 0,
|
totalItems: 0,
|
||||||
perPage: limit,
|
perPage: limit,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
// Main query to get aspects, sub-aspects, and number of questions
|
||||||
// Get aspect by id
|
const result = await db
|
||||||
.get(
|
.select({
|
||||||
"/:id",
|
id: aspects.id,
|
||||||
checkPermission("managementAspect.readAll"),
|
name: aspects.name,
|
||||||
requestValidator(
|
createdAt: aspects.createdAt,
|
||||||
"query",
|
updatedAt: aspects.updatedAt,
|
||||||
z.object({
|
...(includeTrashed ? { deletedAt: aspects.deletedAt } : {}),
|
||||||
includeTrashed: z.string().default("false"),
|
subAspectId: subAspects.id,
|
||||||
|
subAspectName: subAspects.name,
|
||||||
|
// Increase the number of questions related to sub aspects
|
||||||
|
questionCount: sql<number>`(
|
||||||
|
SELECT count(*)
|
||||||
|
FROM ${questions}
|
||||||
|
WHERE ${questions.subAspectId} = ${subAspects.id}
|
||||||
|
)`.as('questionCount'),
|
||||||
|
fullCount: totalCountQuery,
|
||||||
})
|
})
|
||||||
),
|
.from(aspects)
|
||||||
async (c) => {
|
.leftJoin(subAspects, eq(subAspects.aspectId, aspects.id))
|
||||||
const aspectId = c.req.param("id");
|
.where(inArray(aspects.id, aspectIds));
|
||||||
|
|
||||||
|
// Grouping sub aspects by aspect ID
|
||||||
|
const groupedResult = result.reduce((acc, curr) => {
|
||||||
|
const aspectId = curr.id;
|
||||||
|
|
||||||
|
if (!acc[aspectId]) {
|
||||||
|
acc[aspectId] = {
|
||||||
|
id: curr.id,
|
||||||
|
name: curr.name,
|
||||||
|
createdAt: curr.createdAt ? new Date(curr.createdAt).toISOString() : null,
|
||||||
|
updatedAt: curr.updatedAt ? new Date(curr.updatedAt).toISOString() : null,
|
||||||
|
subAspects: curr.subAspectName
|
||||||
|
? [{ id: curr.subAspectId!, name: curr.subAspectName, questionCount: curr.questionCount }]
|
||||||
|
: [],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
if (curr.subAspectName) {
|
||||||
|
const exists = acc[aspectId].subAspects.some(sub => sub.id === curr.subAspectId);
|
||||||
|
if (!exists) {
|
||||||
|
acc[aspectId].subAspects.push({
|
||||||
|
id: curr.subAspectId!,
|
||||||
|
name: curr.subAspectName,
|
||||||
|
questionCount: curr.questionCount,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, {} as Record<string, {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
createdAt: string | null;
|
||||||
|
updatedAt: string | null;
|
||||||
|
subAspects: { id: string; name: string; questionCount: number }[];
|
||||||
|
}>);
|
||||||
|
|
||||||
|
const groupedArray = Object.values(groupedResult);
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
data: groupedArray,
|
||||||
|
_metadata: {
|
||||||
|
currentPage: page,
|
||||||
|
totalPages: Math.ceil((Number(result[0]?.fullCount) ?? 0) / limit),
|
||||||
|
totalItems: Number(result[0]?.fullCount) ?? 0,
|
||||||
|
perPage: limit,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if (!aspectId)
|
// Get aspect by id
|
||||||
throw notFound({
|
.get(
|
||||||
message: "Missing id",
|
"/:id",
|
||||||
});
|
checkPermission("managementAspect.readAll"),
|
||||||
|
requestValidator(
|
||||||
|
"query",
|
||||||
|
z.object({
|
||||||
|
includeTrashed: z.string().default("false"),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
async (c) => {
|
||||||
|
const aspectId = c.req.param("id");
|
||||||
|
|
||||||
const includeTrashed = c.req.query("includeTrashed")?.toLowerCase() === "true";
|
if (!aspectId)
|
||||||
|
throw notFound({
|
||||||
|
message: "Missing id",
|
||||||
|
});
|
||||||
|
|
||||||
const queryResult = await db
|
const includeTrashed = c.req.query("includeTrashed")?.toLowerCase() === "true";
|
||||||
.select({
|
|
||||||
id: aspects.id,
|
|
||||||
name: aspects.name,
|
|
||||||
createdAt: aspects.createdAt,
|
|
||||||
updatedAt: aspects.updatedAt,
|
|
||||||
...(includeTrashed ? { deletedAt: aspects.deletedAt } : {}),
|
|
||||||
subAspect: {
|
|
||||||
name: subAspects.name,
|
|
||||||
id: subAspects.id,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.from(aspects)
|
|
||||||
.leftJoin(subAspects, eq(aspects.id, subAspects.aspectId))
|
|
||||||
.where(and(eq(aspects.id, aspectId), !includeTrashed ? isNull(aspects.deletedAt) : undefined));
|
|
||||||
|
|
||||||
if (!queryResult.length)
|
const queryResult = await db
|
||||||
throw forbidden({
|
.select({
|
||||||
message: "The aspect does not exist",
|
id: aspects.id,
|
||||||
});
|
name: aspects.name,
|
||||||
|
createdAt: aspects.createdAt,
|
||||||
|
updatedAt: aspects.updatedAt,
|
||||||
|
...(includeTrashed ? { deletedAt: aspects.deletedAt } : {}),
|
||||||
|
subAspect: {
|
||||||
|
name: subAspects.name,
|
||||||
|
id: subAspects.id,
|
||||||
|
questionCount: sql`COUNT(${questions.id})`.as("questionCount"),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.from(aspects)
|
||||||
|
.leftJoin(subAspects, eq(aspects.id, subAspects.aspectId))
|
||||||
|
.leftJoin(questions, eq(subAspects.id, questions.subAspectId))
|
||||||
|
.where(and(eq(aspects.id, aspectId), !includeTrashed ? isNull(aspects.deletedAt) : undefined))
|
||||||
|
.groupBy(aspects.id, aspects.name, aspects.createdAt, aspects.updatedAt, subAspects.id, subAspects.name);
|
||||||
|
|
||||||
const subAspectsList = queryResult.reduce((prev, curr) => {
|
if (!queryResult.length)
|
||||||
if (!curr.subAspect) return prev;
|
throw notFound({
|
||||||
prev.set(curr.subAspect.id, curr.subAspect.name);
|
message: "The aspect does not exist",
|
||||||
return prev;
|
});
|
||||||
}, new Map<string, string>()); // Map<id, name>
|
|
||||||
|
|
||||||
const aspectData = {
|
const subAspectsList = queryResult.reduce((prev, curr) => {
|
||||||
...queryResult[0],
|
if (!curr.subAspect) return prev;
|
||||||
subAspect: undefined,
|
prev.set(curr.subAspect.id, {
|
||||||
subAspects: Array.from(subAspectsList, ([id, name]) => ({ id, name })),
|
name: curr.subAspect.name,
|
||||||
};
|
questionCount: Number(curr.subAspect.questionCount),
|
||||||
|
});
|
||||||
|
return prev;
|
||||||
|
}, new Map<string, { name: string; questionCount: number }>());
|
||||||
|
|
||||||
return c.json(aspectData);
|
const aspectData = {
|
||||||
}
|
...queryResult[0],
|
||||||
)
|
subAspect: undefined,
|
||||||
|
subAspects: Array.from(subAspectsList, ([id, { name, questionCount }]) => ({ id, name, questionCount })),
|
||||||
|
};
|
||||||
|
|
||||||
// Create aspect
|
return c.json(aspectData);
|
||||||
.post("/",
|
}
|
||||||
checkPermission("managementAspect.create"),
|
)
|
||||||
requestValidator("json", aspectFormSchema),
|
|
||||||
async (c) => {
|
|
||||||
const aspectData = c.req.valid("json");
|
|
||||||
|
|
||||||
// Validation to check if the aspect name already exists
|
// Create aspect
|
||||||
|
.post("/",
|
||||||
|
checkPermission("managementAspect.create"),
|
||||||
|
requestValidator("json", aspectFormSchema),
|
||||||
|
async (c) => {
|
||||||
|
const aspectData = c.req.valid("json");
|
||||||
|
|
||||||
|
// Check if aspect name already exists and is not deleted
|
||||||
const existingAspect = await db
|
const existingAspect = await db
|
||||||
.select()
|
.select()
|
||||||
.from(aspects)
|
.from(aspects)
|
||||||
.where(eq(aspects.name, aspectData.name));
|
.where(
|
||||||
|
and(
|
||||||
|
eq(aspects.name, aspectData.name),
|
||||||
|
isNull(aspects.deletedAt)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (existingAspect.length > 0) {
|
if (existingAspect.length > 0) {
|
||||||
throw forbidden({
|
// Return an error if the aspect name already exists
|
||||||
message: "Aspect name already exists",
|
return c.json(
|
||||||
});
|
{ message: "Aspect name already exists" },
|
||||||
|
400 // Bad Request
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it doesn't exist, create a new aspect
|
||||||
const aspect = await db
|
const aspect = await db
|
||||||
.insert(aspects)
|
.insert(aspects)
|
||||||
.values({
|
.values({
|
||||||
|
|
@ -196,56 +281,60 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
// if sub-aspects are available, parse them into a string array
|
const aspectId = aspect[0].id;
|
||||||
|
|
||||||
|
// If there is sub aspect data, parse and insert into the database.
|
||||||
if (aspectData.subAspects) {
|
if (aspectData.subAspects) {
|
||||||
const subAspectsArray = JSON.parse(aspectData.subAspects) as string[];
|
const subAspectsArray = JSON.parse(aspectData.subAspects) as string[];
|
||||||
// if there are sub-aspects, insert them into the database
|
|
||||||
|
// Insert new sub aspects into the database without checking for sub aspect duplication
|
||||||
if (subAspectsArray.length) {
|
if (subAspectsArray.length) {
|
||||||
await db.insert(subAspects).values(
|
await db.insert(subAspects).values(
|
||||||
subAspectsArray.map((subAspect) => ({
|
subAspectsArray.map((subAspect) => ({
|
||||||
aspectId: aspect[0].id,
|
aspectId,
|
||||||
name: subAspect,
|
name: subAspect,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.json(
|
return c.json(
|
||||||
{
|
{
|
||||||
message: "Aspect created successfully",
|
message: "Aspect and sub aspects created successfully",
|
||||||
},
|
},
|
||||||
201
|
201
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update aspect
|
// Update aspect
|
||||||
.patch(
|
.patch(
|
||||||
"/:id",
|
"/:id",
|
||||||
checkPermission("managementAspect.update"),
|
checkPermission("managementAspect.update"),
|
||||||
requestValidator("json", aspectUpdateSchema),
|
requestValidator("json", aspectUpdateSchema),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const aspectId = c.req.param("id");
|
const aspectId = c.req.param("id");
|
||||||
const aspectData = c.req.valid("json");
|
const aspectData = c.req.valid("json");
|
||||||
|
|
||||||
// Validation to check if the new aspect name already exists
|
// Check if new aspect name already exists
|
||||||
const existingAspect = await db
|
const existingAspect = await db
|
||||||
.select()
|
.select()
|
||||||
.from(aspects)
|
.from(aspects)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(aspects.name, aspectData.name),
|
eq(aspects.name, aspectData.name),
|
||||||
isNull(aspects.deletedAt),
|
isNull(aspects.deletedAt),
|
||||||
sql`${aspects.id} <> ${aspectId}`
|
sql`${aspects.id} <> ${aspectId}`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (existingAspect.length > 0) {
|
if (existingAspect.length > 0) {
|
||||||
throw forbidden({
|
throw notFound({
|
||||||
message: "Aspect name already exists",
|
message: "Aspect name already exists",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the aspect in question exists
|
||||||
const aspect = await db
|
const aspect = await db
|
||||||
.select()
|
.select()
|
||||||
.from(aspects)
|
.from(aspects)
|
||||||
|
|
@ -253,240 +342,153 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
||||||
|
|
||||||
if (!aspect[0]) throw notFound();
|
if (!aspect[0]) throw notFound();
|
||||||
|
|
||||||
|
// Update aspect name
|
||||||
await db
|
await db
|
||||||
.update(aspects)
|
.update(aspects)
|
||||||
.set({
|
.set({
|
||||||
...aspectData,
|
name: aspectData.name,
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
})
|
})
|
||||||
.where(eq(aspects.id, aspectId));
|
.where(eq(aspects.id, aspectId));
|
||||||
|
|
||||||
//Update for Sub-Aspects
|
// Get new sub aspect data from request
|
||||||
// if (aspectData.subAspects) {
|
const newSubAspects = aspectData.subAspects || [];
|
||||||
// const subAspectsArray = JSON.parse(aspectData.subAspects) as string[];
|
|
||||||
|
|
||||||
// await db.delete(subAspects).where(eq(subAspects.aspectId, aspectId));
|
// Take the existing sub aspects
|
||||||
|
const currentSubAspects = await db
|
||||||
|
.select({ id: subAspects.id, name: subAspects.name })
|
||||||
|
.from(subAspects)
|
||||||
|
.where(eq(subAspects.aspectId, aspectId));
|
||||||
|
|
||||||
// if (subAspectsArray.length) {
|
const currentSubAspectMap = new Map(currentSubAspects.map(sub => [sub.id, sub.name]));
|
||||||
// await db.insert(subAspects).values(
|
|
||||||
// subAspectsArray.map((subAspect) => ({
|
|
||||||
// aspectId: aspectId,
|
|
||||||
// name: subAspect,
|
|
||||||
// }))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return c.json({
|
// Sub aspects to be removed
|
||||||
message: "Aspect updated successfully",
|
const subAspectsToDelete = currentSubAspects
|
||||||
});
|
.filter(sub => !newSubAspects.some(newSub => newSub.id === sub.id))
|
||||||
}
|
.map(sub => sub.id);
|
||||||
)
|
|
||||||
|
|
||||||
// Delete aspect
|
|
||||||
.delete(
|
|
||||||
"/:id",
|
|
||||||
checkPermission("managementAspect.delete"),
|
|
||||||
requestValidator(
|
|
||||||
"form",
|
|
||||||
z.object({
|
|
||||||
// skipTrash: z.string().default("false"),
|
|
||||||
})
|
|
||||||
),
|
|
||||||
async (c) => {
|
|
||||||
const aspectId = c.req.param("id");
|
|
||||||
|
|
||||||
// const skipTrash = c.req.valid("form").skipTrash.toLowerCase() === "true";
|
|
||||||
|
|
||||||
const aspect = await db
|
|
||||||
.select()
|
|
||||||
.from(aspects)
|
|
||||||
.where(and(eq(aspects.id, aspectId), isNull(aspects.deletedAt)));
|
|
||||||
|
|
||||||
if (!aspect[0])
|
|
||||||
throw notFound({
|
|
||||||
message: "The aspect is not found",
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// Delete sub aspects that do not exist in the new data
|
||||||
|
if (subAspectsToDelete.length) {
|
||||||
await db
|
await db
|
||||||
.update(aspects)
|
.delete(subAspects)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(subAspects.aspectId, aspectId),
|
||||||
|
inArray(subAspects.id, subAspectsToDelete)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update or add new sub aspects
|
||||||
|
for (const subAspect of newSubAspects) {
|
||||||
|
const existingSubAspect = currentSubAspectMap.has(subAspect.id);
|
||||||
|
|
||||||
|
if (existingSubAspect) {
|
||||||
|
// Update if sub aspect already exists
|
||||||
|
await db
|
||||||
|
.update(subAspects)
|
||||||
.set({
|
.set({
|
||||||
deletedAt: new Date(),
|
name: subAspect.name,
|
||||||
|
updatedAt: new Date(),
|
||||||
})
|
})
|
||||||
.where(eq(aspects.id, aspectId));
|
.where(
|
||||||
|
and(
|
||||||
return c.json({
|
eq(subAspects.id, subAspect.id),
|
||||||
message: "Aspect deleted successfully",
|
eq(subAspects.aspectId, aspectId)
|
||||||
});
|
)
|
||||||
}
|
);
|
||||||
)
|
} else {
|
||||||
|
// Add if new sub aspect
|
||||||
// Undo delete
|
await db
|
||||||
.patch(
|
.insert(subAspects)
|
||||||
"/restore/:id",
|
.values({
|
||||||
checkPermission("managementAspect.restore"),
|
id: subAspect.id,
|
||||||
async (c) => {
|
aspectId,
|
||||||
const aspectId = c.req.param("id");
|
name: subAspect.name,
|
||||||
|
createdAt: new Date(),
|
||||||
const aspect = (await db.select().from(aspects).where(eq(aspects.id, aspectId)))[0];
|
});
|
||||||
|
|
||||||
if (!aspect) throw notFound();
|
|
||||||
|
|
||||||
if (!aspect.deletedAt) {
|
|
||||||
throw forbidden({
|
|
||||||
message: "The aspect is not deleted",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await db.update(aspects).set({ deletedAt: null }).where(eq(aspects.id, aspectId));
|
return c.json({
|
||||||
|
message: "Aspect and sub aspects updated successfully",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return c.json({
|
// Delete aspect
|
||||||
message: "Aspect restored successfully",
|
.delete(
|
||||||
|
"/:id",
|
||||||
|
checkPermission("managementAspect.delete"),
|
||||||
|
async (c) => {
|
||||||
|
const aspectId = c.req.param("id");
|
||||||
|
|
||||||
|
// Check if aspect exists before deleting
|
||||||
|
const aspect = await db
|
||||||
|
.select()
|
||||||
|
.from(aspects)
|
||||||
|
.where(and(eq(aspects.id, aspectId), isNull(aspects.deletedAt)));
|
||||||
|
|
||||||
|
if (!aspect[0])
|
||||||
|
throw notFound({
|
||||||
|
message: "The aspect is not found",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update deletedAt column on aspect (soft delete)
|
||||||
|
await db
|
||||||
|
.update(aspects)
|
||||||
|
.set({
|
||||||
|
deletedAt: new Date(),
|
||||||
|
})
|
||||||
|
.where(eq(aspects.id, aspectId));
|
||||||
|
|
||||||
|
// Soft delete related sub aspects (update deletedAt on the sub-aspect)
|
||||||
|
await db
|
||||||
|
.update(subAspects)
|
||||||
|
.set({
|
||||||
|
deletedAt: new Date(),
|
||||||
|
})
|
||||||
|
.where(eq(subAspects.aspectId, aspectId));
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
message: "Aspect and sub aspects soft deleted successfully",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Undo delete
|
||||||
|
.patch(
|
||||||
|
"/restore/:id",
|
||||||
|
checkPermission("managementAspect.restore"),
|
||||||
|
async (c) => {
|
||||||
|
const aspectId = c.req.param("id");
|
||||||
|
|
||||||
|
// Check if the desired aspects are present
|
||||||
|
const aspect = (await db.select().from(aspects).where(eq(aspects.id, aspectId)))[0];
|
||||||
|
|
||||||
|
if (!aspect) {
|
||||||
|
throw notFound({
|
||||||
|
message: "The aspect is not found",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
// Get sub aspects by aspect ID
|
// Make sure the aspect has been deleted (there is deletedAt)
|
||||||
.get(
|
if (!aspect.deletedAt) {
|
||||||
"/subAspects/:aspectId",
|
throw notFound({
|
||||||
checkPermission("managementAspect.readAll"),
|
message: "The aspect is not deleted",
|
||||||
async (c) => {
|
|
||||||
const aspectId = c.req.param("aspectId");
|
|
||||||
|
|
||||||
const aspect = await db
|
|
||||||
.select()
|
|
||||||
.from(aspects)
|
|
||||||
.where(and(
|
|
||||||
eq(aspects.id, aspectId),
|
|
||||||
isNull(aspects.deletedAt)));
|
|
||||||
|
|
||||||
if (!aspect[0])
|
|
||||||
throw notFound({
|
|
||||||
message: "The aspect is not found",
|
|
||||||
});
|
|
||||||
|
|
||||||
const subAspectsData = await db
|
|
||||||
.select()
|
|
||||||
.from(subAspects)
|
|
||||||
.where(eq(subAspects.aspectId, aspectId));
|
|
||||||
|
|
||||||
return c.json({
|
|
||||||
subAspects: subAspectsData,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
// Create sub aspect
|
// Restore aspects (remove deletedAt mark)
|
||||||
.post(
|
await db.update(aspects).set({ deletedAt: null }).where(eq(aspects.id, aspectId));
|
||||||
"/subAspect",
|
|
||||||
checkPermission("managementAspect.create"),
|
|
||||||
requestValidator("json", subAspectFormSchema),
|
|
||||||
async (c) => {
|
|
||||||
const subAspectData = c.req.valid("json");
|
|
||||||
|
|
||||||
// Validation to check if the sub aspect name already exists
|
// Restore all related sub aspects that have also been deleted (if any)
|
||||||
const existingSubAspect = await db
|
await db.update(subAspects).set({ deletedAt: null }).where(eq(subAspects.aspectId, aspectId));
|
||||||
.select()
|
|
||||||
.from(subAspects)
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(subAspects.name, subAspectData.name),
|
|
||||||
eq(subAspects.aspectId, subAspectData.aspectId)));
|
|
||||||
|
|
||||||
if (existingSubAspect.length > 0) {
|
return c.json({
|
||||||
throw forbidden({ message: "Nama Sub Aspek sudah tersedia!" });
|
message: "Aspect and sub aspects restored successfully",
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const [aspect] = await db
|
export default managementAspectRoute;
|
||||||
.select()
|
|
||||||
.from(aspects)
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(aspects.id, subAspectData.aspectId),
|
|
||||||
isNull(aspects.deletedAt)));
|
|
||||||
|
|
||||||
if (!aspect)
|
|
||||||
throw forbidden({
|
|
||||||
message: "The aspect is not found",
|
|
||||||
});
|
|
||||||
|
|
||||||
await db.insert(subAspects).values(subAspectData);
|
|
||||||
|
|
||||||
return c.json(
|
|
||||||
{
|
|
||||||
message: "Sub aspect created successfully",
|
|
||||||
},
|
|
||||||
201
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update sub aspect
|
|
||||||
.patch(
|
|
||||||
"/subAspect/:id", checkPermission("managementAspect.update"),
|
|
||||||
requestValidator("json", subAspectUpdateSchema),
|
|
||||||
async (c) => {
|
|
||||||
const subAspectId = c.req.param("id");
|
|
||||||
const subAspectData = c.req.valid("json");
|
|
||||||
|
|
||||||
// Validation to check if the new sub aspect name already exists
|
|
||||||
const existingSubAspect = await db
|
|
||||||
.select()
|
|
||||||
.from(subAspects)
|
|
||||||
.where(
|
|
||||||
eq(subAspects.aspectId, subAspectData.aspectId));
|
|
||||||
|
|
||||||
if (existingSubAspect.length > 0) {
|
|
||||||
throw forbidden({ message: "Name Sub Aspect already exists" });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!existingSubAspect[0])
|
|
||||||
throw notFound({
|
|
||||||
message: "The sub aspect is not found",
|
|
||||||
});
|
|
||||||
|
|
||||||
await db
|
|
||||||
.update(subAspects)
|
|
||||||
.set({
|
|
||||||
...subAspectData,
|
|
||||||
updatedAt: new Date(),
|
|
||||||
})
|
|
||||||
.where(eq(subAspects.id, subAspectId));
|
|
||||||
|
|
||||||
return c.json({
|
|
||||||
message: "Sub aspect updated successfully",
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
// Delete sub aspect
|
|
||||||
.delete(
|
|
||||||
"/subAspect/:id",
|
|
||||||
checkPermission("managementAspect.delete"),
|
|
||||||
async (c) => {
|
|
||||||
const subAspectId = c.req.param("id");
|
|
||||||
|
|
||||||
const subAspect = await db
|
|
||||||
.select()
|
|
||||||
.from(subAspects)
|
|
||||||
.where(eq(subAspects.id, subAspectId));
|
|
||||||
|
|
||||||
if (!subAspect[0])
|
|
||||||
throw notFound({
|
|
||||||
message: "The sub aspect is not found",
|
|
||||||
});
|
|
||||||
|
|
||||||
await db
|
|
||||||
.update(subAspects)
|
|
||||||
.set({
|
|
||||||
deletedAt: new Date(),
|
|
||||||
})
|
|
||||||
.where(eq(subAspects.id, subAspectId));
|
|
||||||
// await db.delete(subAspects).where(eq(subAspects.id, subAspectId));
|
|
||||||
|
|
||||||
return c.json({
|
|
||||||
message: "Sub aspect deleted successfully",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export default managementAspectRoute;
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { and, eq, ilike, isNull, or, sql } from "drizzle-orm";
|
import { and, eq, ilike, isNull, or, sql, not, inArray } from "drizzle-orm";
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
@ -12,30 +12,21 @@ import HonoEnv from "../../types/HonoEnv";
|
||||||
import requestValidator from "../../utils/requestValidator";
|
import requestValidator from "../../utils/requestValidator";
|
||||||
import authInfo from "../../middlewares/authInfo";
|
import authInfo from "../../middlewares/authInfo";
|
||||||
import checkPermission from "../../middlewares/checkPermission";
|
import checkPermission from "../../middlewares/checkPermission";
|
||||||
|
import { respondents } from "../../drizzle/schema/respondents";
|
||||||
|
import { forbidden, notFound } from "../../errors/DashboardError";
|
||||||
|
|
||||||
export const userFormSchema = z.object({
|
export const userFormSchema = z.object({
|
||||||
name: z.string().min(1).max(255),
|
name: z.string().min(1, "Name is required").max(255),
|
||||||
username: z.string().min(1).max(255),
|
username: z.string().min(1, "Username is required").max(255),
|
||||||
email: z.string().email().optional().or(z.literal("")),
|
email: z.string().min(1, "Email is required").email().optional().or(z.literal("")),
|
||||||
password: z.string().min(6),
|
password: z.string().min(6, "Password is required"),
|
||||||
|
companyName: z.string().min(1, "Company name is required").max(255),
|
||||||
|
position: z.string().min(1, "Position is required").max(255),
|
||||||
|
workExperience: z.string().min(1, "Work experience is required").max(255),
|
||||||
|
address: z.string().min(1, "Address is required"),
|
||||||
|
phoneNumber: z.string().min(1, "Phone number is required").max(13),
|
||||||
isEnabled: z.string().default("false"),
|
isEnabled: z.string().default("false"),
|
||||||
roles: z
|
roles: z.array(z.string().min(1, "Role is required")),
|
||||||
.string()
|
|
||||||
.refine(
|
|
||||||
(data) => {
|
|
||||||
console.log(data);
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(data);
|
|
||||||
return Array.isArray(parsed);
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
message: "Roles must be an array",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.optional(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const userUpdateSchema = userFormSchema.extend({
|
export const userUpdateSchema = userFormSchema.extend({
|
||||||
|
|
@ -50,75 +41,169 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
* Query params:
|
* Query params:
|
||||||
* - includeTrashed: boolean (default: false)\
|
* - includeTrashed: boolean (default: false)\
|
||||||
* - withMetadata: boolean
|
* - withMetadata: boolean
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Get all users with search
|
||||||
.get(
|
.get(
|
||||||
"/",
|
"/",
|
||||||
checkPermission("users.readAll"),
|
checkPermission("users.readAll"),
|
||||||
requestValidator(
|
requestValidator(
|
||||||
"query",
|
"query",
|
||||||
z.object({
|
z.object({
|
||||||
includeTrashed: z
|
includeTrashed: z
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
.transform((v) => v?.toLowerCase() === "true"),
|
.transform((v) => v?.toLowerCase() === "true"),
|
||||||
withMetadata: z
|
withMetadata: z
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
.transform((v) => v?.toLowerCase() === "true"),
|
.transform((v) => v?.toLowerCase() === "true"),
|
||||||
page: z.coerce.number().int().min(0).default(0),
|
page: z.coerce.number().int().min(0).default(0),
|
||||||
limit: z.coerce.number().int().min(1).max(1000).default(1),
|
limit: z.coerce.number().int().min(1).max(1000).default(10),
|
||||||
q: z.string().default(""),
|
q: z.string().default(""), // Keyword search
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const { includeTrashed, page, limit, q } = c.req.valid("query");
|
const { includeTrashed, page, limit, q } = c.req.valid("query");
|
||||||
|
|
||||||
const totalCountQuery = includeTrashed
|
// Query to count total data without duplicates
|
||||||
? sql<number>`(SELECT count(*) FROM ${users})`
|
const totalCountQuery = db
|
||||||
: sql<number>`(SELECT count(*) FROM ${users} WHERE ${users.deletedAt} IS NULL)`;
|
.select({
|
||||||
|
count: sql<number>`count(distinct ${users.id})`,
|
||||||
const result = await db
|
})
|
||||||
.select({
|
.from(users)
|
||||||
id: users.id,
|
.leftJoin(respondents, eq(users.id, respondents.userId))
|
||||||
name: users.name,
|
.leftJoin(rolesToUsers, eq(users.id, rolesToUsers.userId))
|
||||||
email: users.email,
|
.leftJoin(rolesSchema, eq(rolesToUsers.roleId, rolesSchema.id))
|
||||||
username: users.username,
|
.where(
|
||||||
isEnabled: users.isEnabled,
|
and(
|
||||||
createdAt: users.createdAt,
|
includeTrashed ? undefined : isNull(users.deletedAt),
|
||||||
updatedAt: users.updatedAt,
|
q
|
||||||
...(includeTrashed ? { deletedAt: users.deletedAt } : {}),
|
? or(
|
||||||
fullCount: totalCountQuery,
|
ilike(users.name, `%${q}%`), // Search by name
|
||||||
})
|
ilike(users.username, `%${q}%`), // Search by username
|
||||||
.from(users)
|
ilike(users.email, `%${q}%`), // Search by email
|
||||||
.where(
|
ilike(respondents.companyName, `%${q}%`), // Search by companyName (from respondents)
|
||||||
and(
|
ilike(rolesSchema.name, `%${q}%`) // Search by role name (from rolesSchema)
|
||||||
includeTrashed ? undefined : isNull(users.deletedAt),
|
|
||||||
q
|
|
||||||
? or(
|
|
||||||
ilike(users.name, q),
|
|
||||||
ilike(users.username, q),
|
|
||||||
ilike(users.email, q),
|
|
||||||
eq(users.id, q)
|
|
||||||
)
|
|
||||||
: undefined
|
|
||||||
)
|
)
|
||||||
)
|
: undefined
|
||||||
.offset(page * limit)
|
)
|
||||||
.limit(limit);
|
);
|
||||||
|
|
||||||
return c.json({
|
// Get the total count result from the query
|
||||||
data: result.map((d) => ({ ...d, fullCount: undefined })),
|
const totalCountResult = await totalCountQuery;
|
||||||
_metadata: {
|
const totalCount = totalCountResult[0]?.count || 0;
|
||||||
currentPage: page,
|
|
||||||
totalPages: Math.ceil(
|
// Query to get unique user IDs based on pagination (Sub Query)
|
||||||
(Number(result[0]?.fullCount) ?? 0) / limit
|
const userIdsQuery = db
|
||||||
),
|
.select({
|
||||||
totalItems: Number(result[0]?.fullCount) ?? 0,
|
id: users.id,
|
||||||
perPage: limit,
|
})
|
||||||
},
|
.from(users)
|
||||||
});
|
.leftJoin(respondents, eq(users.id, respondents.userId))
|
||||||
|
.leftJoin(rolesToUsers, eq(users.id, rolesToUsers.userId))
|
||||||
|
.leftJoin(rolesSchema, eq(rolesToUsers.roleId, rolesSchema.id))
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
includeTrashed ? undefined : isNull(users.deletedAt),
|
||||||
|
q
|
||||||
|
? or(
|
||||||
|
ilike(users.name, `%${q}%`), // Search by name
|
||||||
|
ilike(users.username, `%${q}%`), // Search by username
|
||||||
|
ilike(users.email, `%${q}%`),
|
||||||
|
ilike(respondents.companyName, `%${q}%`),
|
||||||
|
ilike(rolesSchema.name, `%${q}%`)
|
||||||
|
)
|
||||||
|
: undefined
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.groupBy(users.id) // Group by user ID to avoid the effect of duplicate data
|
||||||
|
.offset(page * limit)
|
||||||
|
.limit(limit);
|
||||||
|
|
||||||
|
// Main Query
|
||||||
|
const result = await db
|
||||||
|
.select({
|
||||||
|
id: users.id,
|
||||||
|
name: users.name,
|
||||||
|
email: users.email,
|
||||||
|
username: users.username,
|
||||||
|
isEnabled: users.isEnabled,
|
||||||
|
createdAt: users.createdAt,
|
||||||
|
updatedAt: users.updatedAt,
|
||||||
|
...(includeTrashed ? { deletedAt: users.deletedAt } : {}),
|
||||||
|
company: respondents.companyName,
|
||||||
|
role: {
|
||||||
|
name: rolesSchema.name,
|
||||||
|
id: rolesSchema.id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.from(users)
|
||||||
|
.leftJoin(respondents, eq(users.id, respondents.userId))
|
||||||
|
.leftJoin(rolesToUsers, eq(users.id, rolesToUsers.userId))
|
||||||
|
.leftJoin(rolesSchema, eq(rolesToUsers.roleId, rolesSchema.id))
|
||||||
|
.where(inArray(users.id, userIdsQuery)) // Only take data based on IDs from subquery
|
||||||
|
.orderBy(users.createdAt);
|
||||||
|
|
||||||
|
// Group roles for each user to avoid duplication
|
||||||
|
const userMap = new Map<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
email: string | null;
|
||||||
|
username: string;
|
||||||
|
isEnabled: boolean;
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt: Date;
|
||||||
|
deletedAt?: Date;
|
||||||
|
company: string | null;
|
||||||
|
roles: { id: string; name: string }[];
|
||||||
|
}
|
||||||
|
>();
|
||||||
|
|
||||||
|
result.forEach((item) => {
|
||||||
|
if (!userMap.has(item.id)) {
|
||||||
|
userMap.set(item.id, {
|
||||||
|
id: item.id,
|
||||||
|
name: item.name,
|
||||||
|
email: item.email ?? null,
|
||||||
|
username: item.username,
|
||||||
|
isEnabled: item.isEnabled ?? false,
|
||||||
|
createdAt: item.createdAt ?? new Date(),
|
||||||
|
updatedAt: item.updatedAt ?? new Date(),
|
||||||
|
deletedAt: item.deletedAt ?? undefined,
|
||||||
|
company: item.company,
|
||||||
|
roles: item.role
|
||||||
|
? [{ id: item.role.id, name: item.role.name }]
|
||||||
|
: [],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const existingUser = userMap.get(item.id);
|
||||||
|
if (item.role) {
|
||||||
|
existingUser?.roles.push({
|
||||||
|
id: item.role.id,
|
||||||
|
name: item.role.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Return user data without duplicates, with roles array
|
||||||
|
const groupedData = Array.from(userMap.values());
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
data: groupedData,
|
||||||
|
_metadata: {
|
||||||
|
currentPage: page,
|
||||||
|
totalPages: Math.ceil(totalCount / limit),
|
||||||
|
totalItems: totalCount,
|
||||||
|
perPage: limit,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//get user by id
|
//get user by id
|
||||||
.get(
|
.get(
|
||||||
"/:id",
|
"/:id",
|
||||||
|
|
@ -139,7 +224,12 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
.select({
|
.select({
|
||||||
id: users.id,
|
id: users.id,
|
||||||
name: users.name,
|
name: users.name,
|
||||||
|
position: respondents.position,
|
||||||
|
workExperience: respondents.workExperience,
|
||||||
email: users.email,
|
email: users.email,
|
||||||
|
companyName: respondents.companyName,
|
||||||
|
address: respondents.address,
|
||||||
|
phoneNumber: respondents.phoneNumber,
|
||||||
username: users.username,
|
username: users.username,
|
||||||
isEnabled: users.isEnabled,
|
isEnabled: users.isEnabled,
|
||||||
createdAt: users.createdAt,
|
createdAt: users.createdAt,
|
||||||
|
|
@ -151,6 +241,7 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.from(users)
|
.from(users)
|
||||||
|
.leftJoin(respondents, eq(users.id, respondents.userId))
|
||||||
.leftJoin(rolesToUsers, eq(users.id, rolesToUsers.userId))
|
.leftJoin(rolesToUsers, eq(users.id, rolesToUsers.userId))
|
||||||
.leftJoin(rolesSchema, eq(rolesToUsers.roleId, rolesSchema.id))
|
.leftJoin(rolesSchema, eq(rolesToUsers.roleId, rolesSchema.id))
|
||||||
.where(
|
.where(
|
||||||
|
|
@ -161,9 +252,9 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!queryResult.length)
|
if (!queryResult.length)
|
||||||
throw new HTTPException(404, {
|
throw notFound({
|
||||||
message: "The user does not exists",
|
message : "The user does not exists",
|
||||||
});
|
})
|
||||||
|
|
||||||
const roles = queryResult.reduce((prev, curr) => {
|
const roles = queryResult.reduce((prev, curr) => {
|
||||||
if (!curr.role) return prev;
|
if (!curr.role) return prev;
|
||||||
|
|
@ -180,38 +271,121 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
return c.json(userData);
|
return c.json(userData);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//create user
|
//create user
|
||||||
.post(
|
.post(
|
||||||
"/",
|
"/",
|
||||||
checkPermission("users.create"),
|
checkPermission("users.create"),
|
||||||
requestValidator("form", userFormSchema),
|
requestValidator("json", userFormSchema),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const userData = c.req.valid("form");
|
const userData = c.req.valid("json");
|
||||||
|
|
||||||
const user = await db
|
// Check if the provided email or username is already exists in database
|
||||||
.insert(users)
|
const conditions = [];
|
||||||
.values({
|
if (userData.email) {
|
||||||
name: userData.name,
|
conditions.push(eq(users.email, userData.email));
|
||||||
username: userData.username,
|
|
||||||
email: userData.email,
|
|
||||||
password: await hashPassword(userData.password),
|
|
||||||
isEnabled: userData.isEnabled.toLowerCase() === "true",
|
|
||||||
})
|
|
||||||
.returning();
|
|
||||||
|
|
||||||
if (userData.roles) {
|
|
||||||
const roles = JSON.parse(userData.roles) as string[];
|
|
||||||
console.log(roles);
|
|
||||||
|
|
||||||
if (roles.length) {
|
|
||||||
await db.insert(rolesToUsers).values(
|
|
||||||
roles.map((role) => ({
|
|
||||||
userId: user[0].id,
|
|
||||||
roleId: role,
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
conditions.push(eq(users.username, userData.username));
|
||||||
|
|
||||||
|
const existingUser = await db
|
||||||
|
.select()
|
||||||
|
.from(users)
|
||||||
|
.where(
|
||||||
|
or(
|
||||||
|
eq(users.email, userData.email),
|
||||||
|
eq(users.username, userData.username)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const existingRespondent = await db
|
||||||
|
.select()
|
||||||
|
.from(respondents)
|
||||||
|
.where(eq(respondents.phoneNumber, userData.phoneNumber));
|
||||||
|
|
||||||
|
if (existingUser.length > 0) {
|
||||||
|
throw forbidden({
|
||||||
|
message: "Email or username has been registered",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingRespondent.length > 0) {
|
||||||
|
throw forbidden({
|
||||||
|
message: "Phone number has been registered",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hash the password
|
||||||
|
const hashedPassword = await hashPassword(userData.password);
|
||||||
|
|
||||||
|
// Start a transaction
|
||||||
|
const result = await db.transaction(async (trx) => {
|
||||||
|
// Create user
|
||||||
|
const [newUser] = await trx
|
||||||
|
.insert(users)
|
||||||
|
.values({
|
||||||
|
name: userData.name,
|
||||||
|
username: userData.username,
|
||||||
|
email: userData.email,
|
||||||
|
password: hashedPassword,
|
||||||
|
isEnabled: userData.isEnabled?.toLowerCase() === "true" || true,
|
||||||
|
})
|
||||||
|
.returning()
|
||||||
|
.catch(() => {
|
||||||
|
throw forbidden({
|
||||||
|
message: "Error creating user",
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create respondent
|
||||||
|
const [newRespondent] = await trx
|
||||||
|
.insert(respondents)
|
||||||
|
.values({
|
||||||
|
companyName: userData.companyName,
|
||||||
|
position: userData.position,
|
||||||
|
workExperience: userData.workExperience,
|
||||||
|
address: userData.address,
|
||||||
|
phoneNumber: userData.phoneNumber,
|
||||||
|
userId: newUser.id,
|
||||||
|
})
|
||||||
|
.returning()
|
||||||
|
.catch((err) => {
|
||||||
|
throw new HTTPException(500, {
|
||||||
|
message: "Error creating respondent: " + err.message,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add other roles if provided
|
||||||
|
if (userData.roles && userData.roles.length > 0) {
|
||||||
|
const roles = userData.roles;
|
||||||
|
|
||||||
|
for (let roleId of roles) {
|
||||||
|
const role = (
|
||||||
|
await trx
|
||||||
|
.select()
|
||||||
|
.from(rolesSchema)
|
||||||
|
.where(eq(rolesSchema.id, roleId))
|
||||||
|
.limit(1)
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
if (role) {
|
||||||
|
await trx.insert(rolesToUsers).values({
|
||||||
|
userId: newUser.id,
|
||||||
|
roleId: role.id,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw new HTTPException(404, {
|
||||||
|
message: `Role ${roleId} does not exists`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw forbidden({
|
||||||
|
message: "Harap pilih minimal satu role",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return newUser;
|
||||||
|
});
|
||||||
|
|
||||||
return c.json(
|
return c.json(
|
||||||
{
|
{
|
||||||
|
|
@ -226,10 +400,32 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
.patch(
|
.patch(
|
||||||
"/:id",
|
"/:id",
|
||||||
checkPermission("users.update"),
|
checkPermission("users.update"),
|
||||||
requestValidator("form", userUpdateSchema),
|
requestValidator("json", userUpdateSchema),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const userId = c.req.param("id");
|
const userId = c.req.param("id");
|
||||||
const userData = c.req.valid("form");
|
const userData = c.req.valid("json");
|
||||||
|
|
||||||
|
// Check if the provided email or username is already exists in the database (excluding the current user)
|
||||||
|
if (userData.email || userData.username) {
|
||||||
|
const existingUser = await db
|
||||||
|
.select()
|
||||||
|
.from(users)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
or(
|
||||||
|
eq(users.email, userData.email),
|
||||||
|
eq(users.username, userData.username)
|
||||||
|
),
|
||||||
|
not(eq(users.id, userId))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (existingUser.length > 0) {
|
||||||
|
throw forbidden({
|
||||||
|
message: "Email or username has been registered by another user",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const user = await db
|
const user = await db
|
||||||
.select()
|
.select()
|
||||||
|
|
@ -238,18 +434,71 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
|
|
||||||
if (!user[0]) return c.notFound();
|
if (!user[0]) return c.notFound();
|
||||||
|
|
||||||
await db
|
// Start transaction to update both user and respondent
|
||||||
.update(users)
|
await db.transaction(async (trx) => {
|
||||||
.set({
|
// Update user
|
||||||
...userData,
|
await trx
|
||||||
...(userData.password
|
.update(users)
|
||||||
? { password: await hashPassword(userData.password) }
|
.set({
|
||||||
: {}),
|
...userData,
|
||||||
updatedAt: new Date(),
|
...(userData.password
|
||||||
isEnabled: userData.isEnabled.toLowerCase() === "true",
|
? { password: await hashPassword(userData.password) }
|
||||||
})
|
: {}),
|
||||||
.where(eq(users.id, userId));
|
updatedAt: new Date(),
|
||||||
|
isEnabled: userData.isEnabled.toLowerCase() === "true",
|
||||||
|
})
|
||||||
|
.where(eq(users.id, userId));
|
||||||
|
|
||||||
|
// Update respondent data if provided
|
||||||
|
if (userData.companyName || userData.position || userData.workExperience || userData.address || userData.phoneNumber) {
|
||||||
|
await trx
|
||||||
|
.update(respondents)
|
||||||
|
.set({
|
||||||
|
...(userData.companyName ? {companyName: userData.companyName} : {}),
|
||||||
|
...(userData.position ? {position: userData.position} : {}),
|
||||||
|
...(userData.workExperience ? {workExperience: userData.workExperience} : {}),
|
||||||
|
...(userData.address ? {address: userData.address} : {}),
|
||||||
|
...(userData.phoneNumber ? {phoneNumber: userData.phoneNumber} : {}),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
})
|
||||||
|
.where(eq(respondents.userId, userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update roles if provided
|
||||||
|
if (userData.roles && userData.roles.length > 0) {
|
||||||
|
const roles = userData.roles;
|
||||||
|
|
||||||
|
// Remove existing roles for the user
|
||||||
|
await trx.delete(rolesToUsers).where(eq(rolesToUsers.userId, userId));
|
||||||
|
|
||||||
|
// Assign new roles
|
||||||
|
for (let roleId of roles) {
|
||||||
|
const role = (
|
||||||
|
await trx
|
||||||
|
.select()
|
||||||
|
.from(rolesSchema)
|
||||||
|
.where(eq(rolesSchema.id, roleId))
|
||||||
|
.limit(1)
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
if (role) {
|
||||||
|
await trx.insert(rolesToUsers).values({
|
||||||
|
userId: userId,
|
||||||
|
roleId: role.id,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw new HTTPException(404, {
|
||||||
|
message: `Role ${roleId} does not exist`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw forbidden({
|
||||||
|
message: "Harap pilih minimal satu role",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return c.json({
|
return c.json({
|
||||||
message: "User updated successfully",
|
message: "User updated successfully",
|
||||||
});
|
});
|
||||||
|
|
@ -273,6 +522,7 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
const skipTrash =
|
const skipTrash =
|
||||||
c.req.valid("form").skipTrash.toLowerCase() === "true";
|
c.req.valid("form").skipTrash.toLowerCase() === "true";
|
||||||
|
|
||||||
|
// Check if the user exists
|
||||||
const user = await db
|
const user = await db
|
||||||
.select()
|
.select()
|
||||||
.from(users)
|
.from(users)
|
||||||
|
|
@ -283,17 +533,20 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Throw error if the user does not exist
|
||||||
if (!user[0])
|
if (!user[0])
|
||||||
throw new HTTPException(404, {
|
throw notFound ({
|
||||||
message: "The user is not found",
|
message: "The user is not found",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Throw error if the user is trying to delete themselves
|
||||||
if (user[0].id === currentUserId) {
|
if (user[0].id === currentUserId) {
|
||||||
throw new HTTPException(400, {
|
throw forbidden ({
|
||||||
message: "You cannot delete yourself",
|
message: "You cannot delete yourself",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete or soft delete user
|
||||||
if (skipTrash) {
|
if (skipTrash) {
|
||||||
await db.delete(users).where(eq(users.id, userId));
|
await db.delete(users).where(eq(users.id, userId));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -311,28 +564,34 @@ const usersRoute = new Hono<HonoEnv>()
|
||||||
)
|
)
|
||||||
|
|
||||||
//undo delete
|
//undo delete
|
||||||
.patch("/restore/:id", checkPermission("users.restore"), async (c) => {
|
.patch(
|
||||||
const userId = c.req.param("id");
|
"/restore/:id",
|
||||||
|
checkPermission("users.restore"),
|
||||||
|
async (c) => {
|
||||||
|
const userId = c.req.param("id");
|
||||||
|
|
||||||
const user = (
|
// Check if the user exists
|
||||||
await db.select().from(users).where(eq(users.id, userId))
|
const user = (
|
||||||
)[0];
|
await db.select().from(users).where(eq(users.id, userId))
|
||||||
|
)[0];
|
||||||
|
|
||||||
if (!user) return c.notFound();
|
if (!user) return c.notFound();
|
||||||
|
|
||||||
if (!user.deletedAt) {
|
// Throw error if the user is not deleted
|
||||||
throw new HTTPException(400, {
|
if (!user.deletedAt) {
|
||||||
message: "The user is not deleted",
|
throw forbidden({
|
||||||
|
message: "The user is not deleted",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore user
|
||||||
|
await db
|
||||||
|
.update(users)
|
||||||
|
.set({ deletedAt: null })
|
||||||
|
.where(eq(users.id, userId));
|
||||||
|
|
||||||
|
return c.json({
|
||||||
|
message: "User restored successfully",
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
await db
|
|
||||||
.update(users)
|
|
||||||
.set({ deletedAt: null })
|
|
||||||
.where(eq(users.id, userId));
|
|
||||||
|
|
||||||
return c.json({
|
|
||||||
message: "User restored successfully",
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
export default usersRoute;
|
export default usersRoute;
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,14 @@
|
||||||
"@mantine/form": "^7.10.2",
|
"@mantine/form": "^7.10.2",
|
||||||
"@mantine/hooks": "^7.10.2",
|
"@mantine/hooks": "^7.10.2",
|
||||||
"@mantine/notifications": "^7.10.2",
|
"@mantine/notifications": "^7.10.2",
|
||||||
|
"@radix-ui/react-avatar": "^1.1.0",
|
||||||
"@radix-ui/react-checkbox": "^1.1.1",
|
"@radix-ui/react-checkbox": "^1.1.1",
|
||||||
|
"@radix-ui/react-dialog": "^1.1.1",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
||||||
"@radix-ui/react-label": "^2.1.0",
|
"@radix-ui/react-label": "^2.1.0",
|
||||||
|
"@radix-ui/react-radio-group": "^1.2.0",
|
||||||
|
"@radix-ui/react-scroll-area": "^1.1.0",
|
||||||
|
"@radix-ui/react-select": "^2.1.1",
|
||||||
"@radix-ui/react-slot": "^1.1.0",
|
"@radix-ui/react-slot": "^1.1.0",
|
||||||
"@tanstack/react-query": "^5.45.0",
|
"@tanstack/react-query": "^5.45.0",
|
||||||
"@tanstack/react-router": "^1.38.1",
|
"@tanstack/react-router": "^1.38.1",
|
||||||
|
|
|
||||||
BIN
apps/frontend/src/assets/logos/amati-logo.png
Normal file
BIN
apps/frontend/src/assets/logos/amati-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
|
|
@ -1,20 +1,13 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import {
|
import logo from "@/assets/logos/amati-logo.png";
|
||||||
AppShell,
|
|
||||||
Avatar,
|
|
||||||
Burger,
|
|
||||||
Group,
|
|
||||||
Menu,
|
|
||||||
UnstyledButton,
|
|
||||||
Text,
|
|
||||||
rem,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import logo from "@/assets/logos/logo.png";
|
|
||||||
import cx from "clsx";
|
import cx from "clsx";
|
||||||
import classNames from "./styles/appHeader.module.css";
|
import classNames from "./styles/appHeader.module.css";
|
||||||
import { TbChevronDown } from "react-icons/tb";
|
import { IoMdMenu } from "react-icons/io";
|
||||||
import { Link } from "@tanstack/react-router";
|
import { Link } from "@tanstack/react-router";
|
||||||
import useAuth from "@/hooks/useAuth";
|
import useAuth from "@/hooks/useAuth";
|
||||||
|
import { Avatar, AvatarFallback, AvatarImage } from "@/shadcn/components/ui/avatar";
|
||||||
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/shadcn/components/ui/dropdown-menu";
|
||||||
|
import { Button } from "@/shadcn/components/ui/button";
|
||||||
// import getUserMenus from "../actions/getUserMenus";
|
// import getUserMenus from "../actions/getUserMenus";
|
||||||
// import { useAuth } from "@/modules/auth/contexts/AuthContext";
|
// import { useAuth } from "@/modules/auth/contexts/AuthContext";
|
||||||
// import UserMenuItem from "./UserMenuItem";
|
// import UserMenuItem from "./UserMenuItem";
|
||||||
|
|
@ -24,73 +17,73 @@ interface Props {
|
||||||
toggle: () => void;
|
toggle: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface User {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
permissions: string[];
|
||||||
|
photoProfile?: string;
|
||||||
|
}
|
||||||
|
|
||||||
// const mockUserData = {
|
// const mockUserData = {
|
||||||
// name: "Fulan bin Fulanah",
|
// name: "Fulan bin Fulanah",
|
||||||
// email: "janspoon@fighter.dev",
|
// email: "janspoon@fighter.dev",
|
||||||
// image: "https://raw.githubusercontent.com/mantinedev/mantine/master/.demo/avatars/avatar-5.png",
|
// image: "https://raw.githubusercontent.com/mantinedev/mantine/master/.demo/avatars/avatar-5.png",
|
||||||
// };
|
// };
|
||||||
|
|
||||||
export default function AppHeader(props: Props) {
|
export default function AppHeader({ toggle }: Props) {
|
||||||
const [userMenuOpened, setUserMenuOpened] = useState(false);
|
const [userMenuOpened, setUserMenuOpened] = useState(false);
|
||||||
|
|
||||||
const { user } = useAuth();
|
const { user }: { user: User | null } = useAuth();
|
||||||
|
|
||||||
// const userMenus = getUserMenus().map((item, i) => (
|
// const userMenus = getUserMenus().map((item, i) => (
|
||||||
// <UserMenuItem item={item} key={i} />
|
// <UserMenuItem item={item} key={i} />
|
||||||
// ));
|
// ));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppShell.Header>
|
<header className="fixed top-0 left-0 w-full h-16 bg-white z-50 border">
|
||||||
<Group h="100%" px="md" justify="space-between">
|
<div className="flex h-full justify-between w-full items-center">
|
||||||
<Burger
|
<Button
|
||||||
opened={props.openNavbar}
|
onClick={toggle}
|
||||||
onClick={props.toggle}
|
className="flex items-center px-5 py-5 lg:hidden bg-white text-black hover:bg-white hover:text-black focus:bg-white focus:text-black active:bg-white active:text-black"
|
||||||
hiddenFrom="sm"
|
|
||||||
size="sm"
|
|
||||||
/>
|
|
||||||
<img src={logo} alt="" className="h-8" />
|
|
||||||
<Menu
|
|
||||||
width={260}
|
|
||||||
position="bottom-end"
|
|
||||||
transitionProps={{ transition: "pop-top-right" }}
|
|
||||||
onOpen={() => setUserMenuOpened(true)}
|
|
||||||
onClose={() => setUserMenuOpened(false)}
|
|
||||||
withinPortal
|
|
||||||
>
|
>
|
||||||
<Menu.Target>
|
<IoMdMenu />
|
||||||
<UnstyledButton
|
</Button>
|
||||||
|
|
||||||
|
<img src={logo} alt="" className="w-fit h-full px-8 py-5" />
|
||||||
|
|
||||||
|
<DropdownMenu
|
||||||
|
modal={false}
|
||||||
|
open={userMenuOpened}
|
||||||
|
onOpenChange={setUserMenuOpened}
|
||||||
|
>
|
||||||
|
<DropdownMenuTrigger asChild className="flex">
|
||||||
|
<button
|
||||||
className={cx(classNames.user, {
|
className={cx(classNames.user, {
|
||||||
[classNames.userActive]: userMenuOpened,
|
[classNames.userActive]: userMenuOpened,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Group gap={7}>
|
<div className="flex items-center">
|
||||||
<Avatar
|
<Avatar>
|
||||||
// src={user?.photoProfile}
|
{user?.photoProfile ? (
|
||||||
// alt={user?.name}
|
<AvatarImage src={user.photoProfile} />
|
||||||
radius="xl"
|
) : (
|
||||||
size={30}
|
<AvatarFallback>{user?.name?.charAt(0) ?? "A"}</AvatarFallback>
|
||||||
/>
|
)}
|
||||||
<Text fw={500} size="sm" lh={1} mr={3}>
|
</Avatar>
|
||||||
{/* {user?.name} */}
|
</div>
|
||||||
{user?.name ?? "Anonymous"}
|
</button>
|
||||||
</Text>
|
</DropdownMenuTrigger>
|
||||||
<TbChevronDown
|
|
||||||
style={{ width: rem(12), height: rem(12) }}
|
|
||||||
strokeWidth={1.5}
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
</UnstyledButton>
|
|
||||||
</Menu.Target>
|
|
||||||
|
|
||||||
<Menu.Dropdown>
|
<DropdownMenuContent
|
||||||
<Menu.Item component={Link} to="/logout">
|
align="end"
|
||||||
Logout
|
className="transition-all duration-200 z-50 border bg-white w-64"
|
||||||
</Menu.Item>
|
>
|
||||||
|
<DropdownMenuItem asChild>
|
||||||
{/* {userMenus} */}
|
<Link to="/logout">Logout</Link>
|
||||||
</Menu.Dropdown>
|
</DropdownMenuItem>
|
||||||
</Menu>
|
</DropdownMenuContent>
|
||||||
</Group>
|
</DropdownMenu>
|
||||||
</AppShell.Header>
|
</div>
|
||||||
|
</header>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
import { AppShell, ScrollArea } from "@mantine/core";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import client from "../honoClient";
|
import client from "../honoClient";
|
||||||
import MenuItem from "./NavbarMenuItem";
|
import MenuItem from "./NavbarMenuItem";
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import { useLocation } from "@tanstack/react-router";
|
||||||
|
import { ScrollArea } from "@/shadcn/components/ui/scroll-area";
|
||||||
|
import AppHeader from "./AppHeader";
|
||||||
|
|
||||||
// import MenuItem from "./SidebarMenuItem";
|
// import MenuItem from "./SidebarMenuItem";
|
||||||
// import { useAuth } from "@/modules/auth/contexts/AuthContext";
|
// import { useAuth } from "@/modules/auth/contexts/AuthContext";
|
||||||
|
|
@ -15,30 +18,70 @@ import MenuItem from "./NavbarMenuItem";
|
||||||
export default function AppNavbar() {
|
export default function AppNavbar() {
|
||||||
// const {user} = useAuth();
|
// const {user} = useAuth();
|
||||||
|
|
||||||
|
const { pathname } = useLocation();
|
||||||
|
|
||||||
|
const [isSidebarOpen, setSidebarOpen] = useState(true);
|
||||||
|
const toggleSidebar = () => {
|
||||||
|
setSidebarOpen(!isSidebarOpen);
|
||||||
|
};
|
||||||
|
|
||||||
const { data } = useQuery({
|
const { data } = useQuery({
|
||||||
queryKey: ["sidebarData"],
|
queryKey: ["sidebarData"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const res = await client.dashboard.getSidebarItems.$get();
|
const res = await client.dashboard.getSidebarItems.$get();
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
console.error("Error:", res.status, res.statusText);
|
console.error("Error:", res.status, res.statusText);
|
||||||
|
|
||||||
//TODO: Handle error properly
|
|
||||||
throw new Error("Error fetching sidebar data");
|
throw new Error("Error fetching sidebar data");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleResize = () => {
|
||||||
|
if (window.innerWidth < 768) { // Ganti 768 dengan breakpoint mobile Anda
|
||||||
|
setSidebarOpen(false);
|
||||||
|
} else {
|
||||||
|
setSidebarOpen(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
handleResize(); // Initial check
|
||||||
|
|
||||||
|
return () => window.removeEventListener('resize', handleResize);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleMenuItemClick = () => {
|
||||||
|
if (window.innerWidth < 768) {
|
||||||
|
setSidebarOpen(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppShell.Navbar p="md">
|
<>
|
||||||
<ScrollArea style={{ flex: "1" }}>
|
<div>
|
||||||
{data?.map((menu, i) => <MenuItem menu={menu} key={i} />)}
|
{/* Header */}
|
||||||
{/* {user?.sidebarMenus.map((menu, i) => (
|
<AppHeader toggle={toggleSidebar} openNavbar={isSidebarOpen} />
|
||||||
<MenuItem menu={menu} key={i} />
|
|
||||||
)) ?? null} */}
|
{/* Sidebar */}
|
||||||
</ScrollArea>
|
<div
|
||||||
</AppShell.Navbar>
|
className={`fixed lg:relative w-64 bg-white top-16 left-0 h-full z-40 px-3 py-4 transition-transform border-x
|
||||||
|
${isSidebarOpen ? 'translate-x-0' : '-translate-x-full'}`}
|
||||||
|
>
|
||||||
|
<ScrollArea className="flex flex-1 h-full">
|
||||||
|
{data?.map((menu, i) => (
|
||||||
|
<MenuItem
|
||||||
|
key={i}
|
||||||
|
menu={menu}
|
||||||
|
isActive={pathname === menu.link}
|
||||||
|
onClick={handleMenuItemClick}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ScrollArea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
import { Table, Center, ScrollArea } from "@mantine/core";
|
import { ScrollArea } from "@/shadcn/components/ui/scroll-area";
|
||||||
import { Table as ReactTable, flexRender } from "@tanstack/react-table";
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow
|
||||||
|
} from "@/shadcn/components/ui/table";
|
||||||
|
import { flexRender, Table as ReactTable } from "@tanstack/react-table";
|
||||||
|
|
||||||
interface Props<TData> {
|
interface Props<TData> {
|
||||||
table: ReactTable<TData>;
|
table: ReactTable<TData>;
|
||||||
|
|
@ -7,68 +15,55 @@ interface Props<TData> {
|
||||||
|
|
||||||
export default function DashboardTable<T>({ table }: Props<T>) {
|
export default function DashboardTable<T>({ table }: Props<T>) {
|
||||||
return (
|
return (
|
||||||
<ScrollArea.Autosize>
|
<div className="w-full max-w-full overflow-x-auto border rounded-lg">
|
||||||
<Table
|
<Table className="min-w-full divide-y divide-muted-foreground bg-white">
|
||||||
verticalSpacing="xs"
|
<TableHeader>
|
||||||
horizontalSpacing="xs"
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
striped
|
<TableRow key={headerGroup.id}>
|
||||||
highlightOnHover
|
{headerGroup.headers.map((header) => (
|
||||||
withColumnBorders
|
<TableHead
|
||||||
withRowBorders
|
key={header.id}
|
||||||
>
|
className="px-6 py-3 text-left text-sm font-medium text-muted-foreground"
|
||||||
{/* Thead */}
|
style={{
|
||||||
<Table.Thead>
|
maxWidth: `${header.column.columnDef.maxSize}px`,
|
||||||
{table.getHeaderGroups().map((headerGroup) => (
|
width: `${header.getSize()}`,
|
||||||
<Table.Tr key={headerGroup.id}>
|
}}
|
||||||
{headerGroup.headers.map((header) => (
|
>
|
||||||
<Table.Th
|
{header.isPlaceholder
|
||||||
key={header.id}
|
? null
|
||||||
style={{
|
: flexRender(header.column.columnDef.header, header.getContext())}
|
||||||
maxWidth: `${header.column.columnDef.maxSize}px`,
|
</TableHead>
|
||||||
width: `${header.getSize()}`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{header.isPlaceholder
|
|
||||||
? null
|
|
||||||
: flexRender(
|
|
||||||
header.column.columnDef.header,
|
|
||||||
header.getContext()
|
|
||||||
)}
|
|
||||||
</Table.Th>
|
|
||||||
))}
|
|
||||||
</Table.Tr>
|
|
||||||
))}
|
))}
|
||||||
</Table.Thead>
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableHeader>
|
||||||
|
|
||||||
{/* Tbody */}
|
<TableBody>
|
||||||
<Table.Tbody>
|
{table.getRowModel().rows.length > 0 ? (
|
||||||
{table.getRowModel().rows.length > 0 ? (
|
table.getRowModel().rows.map((row) => (
|
||||||
table.getRowModel().rows.map((row) => (
|
<TableRow key={row.id}>
|
||||||
<Table.Tr key={row.id}>
|
{row.getVisibleCells().map((cell) => (
|
||||||
{row.getVisibleCells().map((cell) => (
|
<TableCell
|
||||||
<Table.Td
|
key={cell.id}
|
||||||
key={cell.id}
|
className="px-6 py-4 whitespace-nowrap text-sm text-black"
|
||||||
style={{
|
style={{
|
||||||
maxWidth: `${cell.column.columnDef.maxSize}px`,
|
maxWidth: `${cell.column.columnDef.maxSize}px`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{flexRender(
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||||
cell.column.columnDef.cell,
|
</TableCell>
|
||||||
cell.getContext()
|
))}
|
||||||
)}
|
</TableRow>
|
||||||
</Table.Td>
|
))
|
||||||
))}
|
) : (
|
||||||
</Table.Tr>
|
<TableRow>
|
||||||
))
|
<TableCell colSpan={table.getAllColumns().length} className="px-6 py-4 text-center text-sm text-gray-500">
|
||||||
) : (
|
- No Data -
|
||||||
<Table.Tr>
|
</TableCell>
|
||||||
<Table.Td colSpan={table.getAllColumns().length}>
|
</TableRow>
|
||||||
<Center>- No Data -</Center>
|
)}
|
||||||
</Table.Td>
|
</TableBody>
|
||||||
</Table.Tr>
|
|
||||||
)}
|
|
||||||
</Table.Tbody>
|
|
||||||
</Table>
|
</Table>
|
||||||
</ScrollArea.Autosize>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import { Text } from "@mantine/core";
|
|
||||||
|
|
||||||
import classNames from "./styles/navbarChildMenu.module.css";
|
import classNames from "./styles/navbarChildMenu.module.css";
|
||||||
import { SidebarMenu } from "backend/types";
|
import { SidebarMenu } from "backend/types";
|
||||||
|
|
||||||
|
|
@ -22,13 +20,10 @@ export default function ChildMenu(props: Props) {
|
||||||
: `/${props.item.link}`;
|
: `/${props.item.link}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text<"a">
|
<a href={`${linkPath}`}
|
||||||
component="a"
|
className={`${props.active ? "font-bold" : "font-normal"} ${classNames.link} text-blue-600 hover:underline`}
|
||||||
className={classNames.link}
|
|
||||||
href={`${linkPath}`}
|
|
||||||
fw={props.active ? "bold" : "normal"}
|
|
||||||
>
|
>
|
||||||
{props.item.label}
|
{props.item.label}
|
||||||
</Text>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,6 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Collapse,
|
|
||||||
Group,
|
|
||||||
ThemeIcon,
|
|
||||||
UnstyledButton,
|
|
||||||
rem,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { TbChevronRight } from "react-icons/tb";
|
|
||||||
import * as TbIcons from "react-icons/tb";
|
import * as TbIcons from "react-icons/tb";
|
||||||
|
// import classNames from "./styles/navbarMenuItem.module.css";
|
||||||
import classNames from "./styles/navbarMenuItem.module.css";
|
|
||||||
// import dashboardConfig from "../dashboard.config";
|
// import dashboardConfig from "../dashboard.config";
|
||||||
// import { usePathname } from "next/navigation";
|
// import { usePathname } from "next/navigation";
|
||||||
// import areURLsSame from "@/utils/areUrlSame";
|
// import areURLsSame from "@/utils/areUrlSame";
|
||||||
|
|
@ -19,9 +8,14 @@ import classNames from "./styles/navbarMenuItem.module.css";
|
||||||
import { SidebarMenu } from "backend/types";
|
import { SidebarMenu } from "backend/types";
|
||||||
import ChildMenu from "./NavbarChildMenu";
|
import ChildMenu from "./NavbarChildMenu";
|
||||||
import { Link } from "@tanstack/react-router";
|
import { Link } from "@tanstack/react-router";
|
||||||
|
import { Button } from "@/shadcn/components/ui/button";
|
||||||
|
import { ChevronRightIcon} from "lucide-react";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
menu: SidebarMenu;
|
menu: SidebarMenu;
|
||||||
|
isActive: boolean;
|
||||||
|
onClick: (link: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Make bold and collapsed when the item is active
|
//TODO: Make bold and collapsed when the item is active
|
||||||
|
|
@ -34,7 +28,7 @@ interface Props {
|
||||||
* @param props.menu - The menu item data to display.
|
* @param props.menu - The menu item data to display.
|
||||||
* @returns A React element representing an individual menu item.
|
* @returns A React element representing an individual menu item.
|
||||||
*/
|
*/
|
||||||
export default function MenuItem({ menu }: Props) {
|
export default function MenuItem({ menu, isActive, onClick }: Props) {
|
||||||
const hasChildren = Array.isArray(menu.children);
|
const hasChildren = Array.isArray(menu.children);
|
||||||
|
|
||||||
// const pathname = usePathname();
|
// const pathname = usePathname();
|
||||||
|
|
@ -50,6 +44,13 @@ export default function MenuItem({ menu }: Props) {
|
||||||
setOpened((prev) => !prev);
|
setOpened((prev) => !prev);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClick = () => {
|
||||||
|
onClick(menu.link ?? "");
|
||||||
|
if (!hasChildren) {
|
||||||
|
toggleOpenMenu();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Mapping children menu items if available
|
// Mapping children menu items if available
|
||||||
const subItems = (hasChildren ? menu.children! : []).map((child, index) => (
|
const subItems = (hasChildren ? menu.children! : []).map((child, index) => (
|
||||||
<ChildMenu key={index} item={child} active={false} />
|
<ChildMenu key={index} item={child} active={false} />
|
||||||
|
|
@ -69,43 +70,41 @@ export default function MenuItem({ menu }: Props) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Main Menu Item */}
|
{/* Main Menu Item */}
|
||||||
<UnstyledButton<typeof Link | "button">
|
<Button
|
||||||
onClick={toggleOpenMenu}
|
variant="ghost"
|
||||||
className={`${classNames.control} py-2`}
|
className={cn(
|
||||||
to={menu.link}
|
"w-full p-2 rounded-md justify-between focus:outline-none",
|
||||||
component={menu.link ? Link : "button"}
|
isActive ? "bg-black text-white" : "text-black"
|
||||||
|
)}
|
||||||
|
onClick={handleClick}
|
||||||
|
asChild
|
||||||
>
|
>
|
||||||
<Group justify="space-between" gap={0}>
|
<Link to={menu.link ?? "#"}>
|
||||||
{/* Icon and Label */}
|
<div className="flex items-center">
|
||||||
<Box style={{ display: "flex", alignItems: "center" }}>
|
{/* Icon */}
|
||||||
<ThemeIcon variant="light" size={30} color={menu.color}>
|
<span className="mr-3">
|
||||||
<Icon style={{ width: rem(18), height: rem(18) }} />
|
<Icon className="w-4 h-4" />
|
||||||
</ThemeIcon>
|
</span>
|
||||||
|
{/* Label */}
|
||||||
<Box ml="md" fw={500}>
|
<span className="text-xs font-bold">{menu.label}</span>
|
||||||
{menu.label}
|
</div>
|
||||||
</Box>
|
{/* Chevron Icon */}
|
||||||
</Box>
|
|
||||||
|
|
||||||
{/* Chevron Icon for collapsible items */}
|
|
||||||
{hasChildren && (
|
{hasChildren && (
|
||||||
<TbChevronRight
|
<ChevronRightIcon
|
||||||
strokeWidth={1.5}
|
className={`w-4 h-4 transition-transform ${
|
||||||
style={{
|
opened ? "rotate-90" : "rotate-0"
|
||||||
width: rem(16),
|
}`}
|
||||||
height: rem(16),
|
|
||||||
transform: opened
|
|
||||||
? "rotate(-90deg)"
|
|
||||||
: "rotate(90deg)",
|
|
||||||
}}
|
|
||||||
className={classNames.chevron}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Group>
|
</Link>
|
||||||
</UnstyledButton>
|
</Button>
|
||||||
|
|
||||||
{/* Collapsible Sub-Menu */}
|
{/* Collapsible Sub-Menu */}
|
||||||
{hasChildren && <Collapse in={opened}>{subItems}</Collapse>}
|
{hasChildren && (
|
||||||
|
<div className={cn("transition-all", opened ? "block" : "hidden")}>
|
||||||
|
{subItems}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/* eslint-disable no-mixed-spaces-and-tabs */
|
/* eslint-disable no-mixed-spaces-and-tabs */
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Card,
|
|
||||||
Flex,
|
|
||||||
Pagination,
|
|
||||||
Select,
|
|
||||||
Stack,
|
|
||||||
Text,
|
|
||||||
TextInput,
|
|
||||||
Title,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { Link } from "@tanstack/react-router";
|
|
||||||
import React, { ReactNode, useState } from "react";
|
import React, { ReactNode, useState } from "react";
|
||||||
import { TbPlus, TbSearch } from "react-icons/tb";
|
import { TbPlus, TbSearch } from "react-icons/tb";
|
||||||
import DashboardTable from "./DashboardTable";
|
import DashboardTable from "./DashboardTable";
|
||||||
|
|
@ -25,7 +13,25 @@ import {
|
||||||
keepPreviousData,
|
keepPreviousData,
|
||||||
useQuery,
|
useQuery,
|
||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
import { useDebouncedCallback } from "@mantine/hooks";
|
import { useDebouncedValue } from "@mantine/hooks";
|
||||||
|
import { Button } from "@/shadcn/components/ui/button";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import { Card } from "@/shadcn/components/ui/card";
|
||||||
|
import { Input } from "@/shadcn/components/ui/input";
|
||||||
|
import {
|
||||||
|
Pagination,
|
||||||
|
PaginationContent,
|
||||||
|
PaginationEllipsis,
|
||||||
|
PaginationItem,
|
||||||
|
} from "@/shadcn/components/ui/pagination";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/shadcn/components/ui/select";
|
||||||
|
import { HiChevronLeft, HiChevronRight } from "react-icons/hi";
|
||||||
|
|
||||||
type PaginatedResponse<T extends Record<string, unknown>> = {
|
type PaginatedResponse<T extends Record<string, unknown>> = {
|
||||||
data: Array<T>;
|
data: Array<T>;
|
||||||
|
|
@ -70,24 +76,32 @@ const createCreateButton = (
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
property: Props<any, any, any>["createButton"] = true
|
property: Props<any, any, any>["createButton"] = true
|
||||||
) => {
|
) => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const addQuery = () => {
|
||||||
|
navigate({ to: `${window.location.pathname}`, search: { create: true } });
|
||||||
|
}
|
||||||
|
|
||||||
if (property === true) {
|
if (property === true) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
leftSection={<TbPlus />}
|
className="gap-2"
|
||||||
component={Link}
|
variant={"outline"}
|
||||||
search={{ create: true }}
|
onClick={addQuery}
|
||||||
>
|
>
|
||||||
Create New
|
Tambah Data
|
||||||
|
<TbPlus />
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
} else if (typeof property === "string") {
|
} else if (typeof property === "string") {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
leftSection={<TbPlus />}
|
className="gap-2"
|
||||||
component={Link}
|
variant={"outline"}
|
||||||
search={{ create: true }}
|
onClick={addQuery}
|
||||||
>
|
>
|
||||||
{property}
|
{property}
|
||||||
|
<TbPlus />
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -95,6 +109,109 @@ const createCreateButton = (
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pagination component for handling page navigation.
|
||||||
|
*
|
||||||
|
* @param props - The properties object.
|
||||||
|
* @returns The rendered Pagination component.
|
||||||
|
*/
|
||||||
|
const CustomPagination = ({
|
||||||
|
currentPage,
|
||||||
|
totalPages,
|
||||||
|
onChange,
|
||||||
|
}: {
|
||||||
|
currentPage: number;
|
||||||
|
totalPages: number;
|
||||||
|
onChange: (page: number) => void;
|
||||||
|
}) => {
|
||||||
|
const getPaginationItems = () => {
|
||||||
|
let items = [];
|
||||||
|
|
||||||
|
// Determine start and end pages
|
||||||
|
let startPage =
|
||||||
|
currentPage == totalPages && currentPage > 3 ?
|
||||||
|
Math.max(1, currentPage - 2) :
|
||||||
|
Math.max(1, currentPage - 1);
|
||||||
|
let endPage =
|
||||||
|
currentPage == 1 ?
|
||||||
|
Math.min(totalPages, currentPage + 2) :
|
||||||
|
Math.min(totalPages, currentPage + 1);
|
||||||
|
|
||||||
|
// Add ellipsis if needed
|
||||||
|
if (startPage > 2) {
|
||||||
|
items.push(<PaginationEllipsis key="start-ellipsis" />);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add page numbers
|
||||||
|
for (let i = startPage; i <= endPage; i++) {
|
||||||
|
items.push(
|
||||||
|
<Button className='cursor-pointer' key={i} onClick={() => onChange(i)} variant={currentPage == i ? "outline" : "ghost"}>
|
||||||
|
{i}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add ellipsis after
|
||||||
|
if (endPage < totalPages - 1) {
|
||||||
|
items.push(<PaginationEllipsis key="end-ellipsis" />);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add last page
|
||||||
|
if (endPage < totalPages) {
|
||||||
|
items.push(
|
||||||
|
<Button className='cursor-pointer' key={totalPages} onClick={() => onChange(totalPages)} variant={"ghost"}>
|
||||||
|
{totalPages}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (currentPage > 2) {
|
||||||
|
items.unshift(
|
||||||
|
<Button className='cursor-pointer' key={1} onClick={() => onChange(1)} variant={"ghost"}>
|
||||||
|
1
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Pagination>
|
||||||
|
<PaginationContent className="flex flex-col items-center gap-4 md:flex-row">
|
||||||
|
<PaginationItem className="w-full md:w-auto">
|
||||||
|
<Button
|
||||||
|
onClick={() => onChange(Math.max(1, currentPage - 1))}
|
||||||
|
disabled={currentPage - 1 == 0 ? true : false}
|
||||||
|
className="w-full gap-2 md:w-auto"
|
||||||
|
variant={"ghost"}
|
||||||
|
>
|
||||||
|
<HiChevronLeft />
|
||||||
|
Sebelumnya
|
||||||
|
</Button>
|
||||||
|
</PaginationItem>
|
||||||
|
<div className="flex flex-wrap justify-center gap-2">
|
||||||
|
{getPaginationItems().map((item) => (
|
||||||
|
<PaginationItem key={item.key}>
|
||||||
|
{item}
|
||||||
|
</PaginationItem>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<PaginationItem className="w-full md:w-auto">
|
||||||
|
<Button
|
||||||
|
onClick={() => onChange(Math.min(totalPages, currentPage + 1))}
|
||||||
|
disabled={currentPage == totalPages ? true : false}
|
||||||
|
className="w-full gap-2 md:w-auto"
|
||||||
|
variant={"ghost"}
|
||||||
|
>
|
||||||
|
Selanjutnya
|
||||||
|
<HiChevronRight />
|
||||||
|
</Button>
|
||||||
|
</PaginationItem>
|
||||||
|
</PaginationContent>
|
||||||
|
</Pagination>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PageTemplate component for displaying a paginated table with search and filter functionality.
|
* PageTemplate component for displaying a paginated table with search and filter functionality.
|
||||||
|
|
||||||
|
|
@ -113,15 +230,15 @@ export default function PageTemplate<
|
||||||
q: "",
|
q: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
// const [deboucedSearchQuery] = useDebouncedValue(filterOptions.q, 500);
|
const [debouncedSearchQuery] = useDebouncedValue(filterOptions.q, 500);
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
...(typeof props.queryOptions === "function"
|
...(typeof props.queryOptions === "function"
|
||||||
? props.queryOptions(
|
? props.queryOptions(
|
||||||
filterOptions.page,
|
filterOptions.page,
|
||||||
filterOptions.limit,
|
filterOptions.limit,
|
||||||
filterOptions.q
|
debouncedSearchQuery
|
||||||
)
|
)
|
||||||
: props.queryOptions),
|
: props.queryOptions),
|
||||||
placeholderData: keepPreviousData,
|
placeholderData: keepPreviousData,
|
||||||
});
|
});
|
||||||
|
|
@ -131,7 +248,11 @@ export default function PageTemplate<
|
||||||
columns: props.columnDefs,
|
columns: props.columnDefs,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
defaultColumn: {
|
defaultColumn: {
|
||||||
cell: (props) => <Text>{props.getValue() as ReactNode}</Text>,
|
cell: (props) => (
|
||||||
|
<span>
|
||||||
|
{props.getValue() as ReactNode}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -140,13 +261,13 @@ export default function PageTemplate<
|
||||||
*
|
*
|
||||||
* @param value - The new search query value.
|
* @param value - The new search query value.
|
||||||
*/
|
*/
|
||||||
const handleSearchQueryChange = useDebouncedCallback((value: string) => {
|
const handleSearchQueryChange = (value: string) => {
|
||||||
setFilterOptions((prev) => ({
|
setFilterOptions((prev) => ({
|
||||||
page: 0,
|
page: 0,
|
||||||
limit: prev.limit,
|
limit: prev.limit,
|
||||||
q: value,
|
q: value,
|
||||||
}));
|
}));
|
||||||
}, 500);
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the change in page number.
|
* Handles the change in page number.
|
||||||
|
|
@ -155,33 +276,34 @@ export default function PageTemplate<
|
||||||
*/
|
*/
|
||||||
const handlePageChange = (page: number) => {
|
const handlePageChange = (page: number) => {
|
||||||
setFilterOptions((prev) => ({
|
setFilterOptions((prev) => ({
|
||||||
page: page - 1,
|
page: page - 1, // Adjust for zero-based index
|
||||||
limit: prev.limit,
|
limit: prev.limit,
|
||||||
q: prev.q,
|
q: prev.q,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<div className="flex flex-col space-y-4">
|
||||||
<Title order={1}>{props.title}</Title>
|
<p className="text-2xl font-bold">{props.title}</p>
|
||||||
<Card>
|
<Card className="p-4 border-hidden">
|
||||||
{/* Top Section */}
|
|
||||||
<Flex justify="flex-end">
|
|
||||||
{createCreateButton(props.createButton)}
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
{/* Table Functionality */}
|
{/* Table Functionality */}
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{/* Search */}
|
{/* Search and Create Button */}
|
||||||
<div className="flex pb-4">
|
<div className="flex flex-col md:flex-row lg:flex-row pb-4 justify-between gap-4">
|
||||||
<TextInput
|
<div className="relative w-full">
|
||||||
leftSection={<TbSearch />}
|
<TbSearch className="absolute top-1/2 left-3 transform -translate-y-1/2 text-muted-foreground pointer-events-none" />
|
||||||
value={filterOptions.q}
|
<Input
|
||||||
onChange={(e) =>
|
id="search"
|
||||||
handleSearchQueryChange(e.target.value)
|
name="search"
|
||||||
}
|
className="w-full max-w-xs pl-10"
|
||||||
placeholder="Search..."
|
value={filterOptions.q}
|
||||||
/>
|
onChange={(e) => handleSearchQueryChange(e.target.value)}
|
||||||
|
placeholder="Pencarian..."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex">
|
||||||
|
{createCreateButton(props.createButton)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Table */}
|
{/* Table */}
|
||||||
|
|
@ -189,41 +311,50 @@ export default function PageTemplate<
|
||||||
|
|
||||||
{/* Pagination */}
|
{/* Pagination */}
|
||||||
{query.data && (
|
{query.data && (
|
||||||
<div className="pt-4 flex-wrap flex items-center gap-4">
|
<div className="pt-4 flex flex-col md:flex-row lg:flex-row items-center justify-between gap-2">
|
||||||
<Select
|
<div className="flex flex-row lg:flex-col items-center w-fit gap-2">
|
||||||
label="Per Page"
|
<span className="block text-sm font-medium text-muted-foreground whitespace-nowrap">Per Halaman</span>
|
||||||
data={["5", "10", "50", "100", "500", "1000"]}
|
<Select
|
||||||
allowDeselect={false}
|
onValueChange={(value) =>
|
||||||
defaultValue="10"
|
setFilterOptions((prev) => ({
|
||||||
searchValue={filterOptions.limit.toString()}
|
page: prev.page,
|
||||||
onChange={(value) =>
|
limit: parseInt(value ?? "10"),
|
||||||
setFilterOptions((prev) => ({
|
q: prev.q,
|
||||||
page: prev.page,
|
}))
|
||||||
limit: parseInt(value ?? "10"),
|
}
|
||||||
q: prev.q,
|
defaultValue="10"
|
||||||
}))
|
>
|
||||||
}
|
<SelectTrigger className="w-fit p-4 gap-4">
|
||||||
checkIconPosition="right"
|
<SelectValue placeholder="Per Page" />
|
||||||
className="w-20"
|
</SelectTrigger>
|
||||||
/>
|
<SelectContent>
|
||||||
<Pagination
|
<SelectItem value="5">5</SelectItem>
|
||||||
value={filterOptions.page + 1}
|
<SelectItem value="10">10</SelectItem>
|
||||||
total={query.data._metadata.totalPages}
|
<SelectItem value="50">50</SelectItem>
|
||||||
|
<SelectItem value="100">100</SelectItem>
|
||||||
|
<SelectItem value="500">500</SelectItem>
|
||||||
|
<SelectItem value="1000">1000</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<CustomPagination
|
||||||
|
currentPage={filterOptions.page + 1}
|
||||||
|
totalPages={query.data._metadata.totalPages}
|
||||||
onChange={handlePageChange}
|
onChange={handlePageChange}
|
||||||
/>
|
/>
|
||||||
<Text c="dimmed" size="sm">
|
<div className="flex items-center gap-4">
|
||||||
Showing {query.data.data.length} of{" "}
|
<span className="text-sm text-muted-foreground whitespace-nowrap">
|
||||||
{query.data._metadata.totalItems}
|
Menampilkan {query.data.data.length} dari {query.data._metadata.totalItems}
|
||||||
</Text>
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* The Modals */}
|
|
||||||
{props.modals?.map((modal, index) => (
|
{props.modals?.map((modal, index) => (
|
||||||
<React.Fragment key={index}>{modal}</React.Fragment>
|
<React.Fragment key={index}>{modal}</React.Fragment>
|
||||||
))}
|
))}
|
||||||
</Card>
|
</Card>
|
||||||
</Stack>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,4 +66,8 @@
|
||||||
body {
|
body {
|
||||||
@apply bg-background text-foreground;
|
@apply bg-background text-foreground;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--primary-color: #2555FF
|
||||||
}
|
}
|
||||||
|
|
@ -63,14 +63,14 @@ export default function UserDeleteModal() {
|
||||||
<Modal
|
<Modal
|
||||||
opened={isModalOpen}
|
opened={isModalOpen}
|
||||||
onClose={() => navigate({ search: {} })}
|
onClose={() => navigate({ search: {} })}
|
||||||
title={`Delete confirmation`}
|
title={`Konfirmasi Hapus`}
|
||||||
>
|
>
|
||||||
<Text size="sm">
|
<Text size="sm">
|
||||||
Are you sure you want to delete user{" "}
|
Apakah Anda yakin ingin menghapus pengguna{" "}
|
||||||
<Text span fw={700}>
|
<Text span fw={700}>
|
||||||
{userQuery.data?.name}
|
{userQuery.data?.name}
|
||||||
</Text>
|
</Text>
|
||||||
? This action is irreversible.
|
? Tindakan ini tidak dapat diubah.
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{/* {errorMessage && <Alert color="red">{errorMessage}</Alert>} */}
|
{/* {errorMessage && <Alert color="red">{errorMessage}</Alert>} */}
|
||||||
|
|
@ -81,7 +81,7 @@ export default function UserDeleteModal() {
|
||||||
onClick={() => navigate({ search: {} })}
|
onClick={() => navigate({ search: {} })}
|
||||||
disabled={mutation.isPending}
|
disabled={mutation.isPending}
|
||||||
>
|
>
|
||||||
Cancel
|
Batal
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
|
|
@ -91,7 +91,7 @@ export default function UserDeleteModal() {
|
||||||
loading={mutation.isPending}
|
loading={mutation.isPending}
|
||||||
onClick={() => mutation.mutate({ id: userId })}
|
onClick={() => mutation.mutate({ id: userId })}
|
||||||
>
|
>
|
||||||
Delete User
|
Hapus Pengguna
|
||||||
</Button>
|
</Button>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export default function UserFormModal() {
|
||||||
const detailId = searchParams.detail;
|
const detailId = searchParams.detail;
|
||||||
const editId = searchParams.edit;
|
const editId = searchParams.edit;
|
||||||
|
|
||||||
const formType = detailId ? "detail" : editId ? "edit" : "create";
|
const formType = detailId ? "detail" : editId ? "ubah" : "tambah";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CHANGE FOLLOWING:
|
* CHANGE FOLLOWING:
|
||||||
|
|
@ -51,7 +51,7 @@ export default function UserFormModal() {
|
||||||
const userQuery = useQuery(getUserByIdQueryOptions(dataId));
|
const userQuery = useQuery(getUserByIdQueryOptions(dataId));
|
||||||
|
|
||||||
const modalTitle =
|
const modalTitle =
|
||||||
formType.charAt(0).toUpperCase() + formType.slice(1) + " User";
|
formType.charAt(0).toUpperCase() + formType.slice(1) + " Pengguna";
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
|
|
@ -62,6 +62,11 @@ export default function UserFormModal() {
|
||||||
photoProfileUrl: "",
|
photoProfileUrl: "",
|
||||||
password: "",
|
password: "",
|
||||||
roles: [] as string[],
|
roles: [] as string[],
|
||||||
|
companyName: "",
|
||||||
|
position: "",
|
||||||
|
workExperience: "",
|
||||||
|
address: "",
|
||||||
|
phoneNumber: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -81,6 +86,11 @@ export default function UserFormModal() {
|
||||||
username: data.username,
|
username: data.username,
|
||||||
password: "",
|
password: "",
|
||||||
roles: data.roles.map((v) => v.id), //only extract the id
|
roles: data.roles.map((v) => v.id), //only extract the id
|
||||||
|
companyName: data.companyName ?? "",
|
||||||
|
position: data.position ?? "",
|
||||||
|
workExperience: data.workExperience ?? "",
|
||||||
|
address: data.address ?? "",
|
||||||
|
phoneNumber: data.phoneNumber ?? "",
|
||||||
});
|
});
|
||||||
|
|
||||||
form.setErrors({});
|
form.setErrors({});
|
||||||
|
|
@ -91,11 +101,11 @@ export default function UserFormModal() {
|
||||||
mutationKey: ["usersMutation"],
|
mutationKey: ["usersMutation"],
|
||||||
mutationFn: async (
|
mutationFn: async (
|
||||||
options:
|
options:
|
||||||
| { action: "edit"; data: Parameters<typeof updateUser>[0] }
|
| { action: "ubah"; data: Parameters<typeof updateUser>[0] }
|
||||||
| { action: "create"; data: Parameters<typeof createUser>[0] }
|
| { action: "tambah"; data: Parameters<typeof createUser>[0] }
|
||||||
) => {
|
) => {
|
||||||
console.log("called");
|
console.log("called");
|
||||||
return options.action === "edit"
|
return options.action === "ubah"
|
||||||
? await updateUser(options.data)
|
? await updateUser(options.data)
|
||||||
: await createUser(options.data);
|
: await createUser(options.data);
|
||||||
},
|
},
|
||||||
|
|
@ -120,16 +130,21 @@ export default function UserFormModal() {
|
||||||
if (formType === "detail") return;
|
if (formType === "detail") return;
|
||||||
|
|
||||||
//TODO: OPtimize this code
|
//TODO: OPtimize this code
|
||||||
if (formType === "create") {
|
if (formType === "tambah") {
|
||||||
await mutation.mutateAsync({
|
await mutation.mutateAsync({
|
||||||
action: formType,
|
action: formType,
|
||||||
data: {
|
data: {
|
||||||
email: values.email,
|
email: values.email,
|
||||||
name: values.name,
|
name: values.name,
|
||||||
password: values.password,
|
password: values.password,
|
||||||
roles: JSON.stringify(values.roles),
|
roles: values.roles,
|
||||||
isEnabled: "true",
|
isEnabled: "true",
|
||||||
username: values.username,
|
username: values.username,
|
||||||
|
companyName: values.email,
|
||||||
|
position: values.position,
|
||||||
|
workExperience: values.workExperience,
|
||||||
|
address: values.address,
|
||||||
|
phoneNumber: values.phoneNumber,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -140,15 +155,20 @@ export default function UserFormModal() {
|
||||||
email: values.email,
|
email: values.email,
|
||||||
name: values.name,
|
name: values.name,
|
||||||
password: values.password,
|
password: values.password,
|
||||||
roles: JSON.stringify(values.roles),
|
roles: values.roles,
|
||||||
isEnabled: "true",
|
isEnabled: "true",
|
||||||
username: values.username,
|
username: values.username,
|
||||||
|
companyName: values.companyName,
|
||||||
|
position: values.position,
|
||||||
|
workExperience: values.workExperience,
|
||||||
|
address: values.address,
|
||||||
|
phoneNumber: values.phoneNumber,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
queryClient.invalidateQueries({ queryKey: ["users"] });
|
queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||||
notifications.show({
|
notifications.show({
|
||||||
message: `The ser is ${formType === "create" ? "created" : "edited"}`,
|
message: `The ser is ${formType === "tambah" ? "created" : "edited"}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate({ search: {} });
|
navigate({ search: {} });
|
||||||
|
|
@ -198,20 +218,18 @@ export default function UserFormModal() {
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
type: "text",
|
type: "text",
|
||||||
readOnly: true,
|
label: "Nama",
|
||||||
variant: "filled",
|
|
||||||
...form.getInputProps("id"),
|
|
||||||
hidden: !form.values.id,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
label: "Name",
|
|
||||||
...form.getInputProps("name"),
|
...form.getInputProps("name"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "text",
|
type: "text",
|
||||||
label: "Username",
|
label: "Jabatan",
|
||||||
...form.getInputProps("username"),
|
...form.getInputProps("position"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
label: "Pengalaman Kerja",
|
||||||
|
...form.getInputProps("workExperience"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "text",
|
type: "text",
|
||||||
|
|
@ -219,11 +237,21 @@ export default function UserFormModal() {
|
||||||
...form.getInputProps("email"),
|
...form.getInputProps("email"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "password",
|
type: "text",
|
||||||
label: "Password",
|
label: "Instansi/Perusahaan",
|
||||||
hidden: formType !== "create",
|
...form.getInputProps("companyName"),
|
||||||
...form.getInputProps("password"),
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
label: "Alamat",
|
||||||
|
...form.getInputProps("address"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
label: "Nomor Telepon",
|
||||||
|
...form.getInputProps("phoneNumber"),
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: "multi-select",
|
type: "multi-select",
|
||||||
label: "Roles",
|
label: "Roles",
|
||||||
|
|
@ -236,6 +264,17 @@ export default function UserFormModal() {
|
||||||
})),
|
})),
|
||||||
error: form.errors.roles,
|
error: form.errors.roles,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
label: "Username",
|
||||||
|
...form.getInputProps("username"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "password",
|
||||||
|
label: "Password",
|
||||||
|
hidden: formType !== "tambah",
|
||||||
|
...form.getInputProps("password"),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
|
@ -246,7 +285,7 @@ export default function UserFormModal() {
|
||||||
onClick={() => navigate({ search: {} })}
|
onClick={() => navigate({ search: {} })}
|
||||||
disabled={mutation.isPending}
|
disabled={mutation.isPending}
|
||||||
>
|
>
|
||||||
Close
|
Tutup
|
||||||
</Button>
|
</Button>
|
||||||
{formType !== "detail" && (
|
{formType !== "detail" && (
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -255,7 +294,7 @@ export default function UserFormModal() {
|
||||||
type="submit"
|
type="submit"
|
||||||
loading={mutation.isPending}
|
loading={mutation.isPending}
|
||||||
>
|
>
|
||||||
Save
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
|
||||||
|
|
@ -34,26 +34,26 @@ export const getUserByIdQueryOptions = (userId: string | undefined) =>
|
||||||
});
|
});
|
||||||
|
|
||||||
export const createUser = async (
|
export const createUser = async (
|
||||||
form: InferRequestType<typeof client.users.$post>["form"]
|
json: InferRequestType<typeof client.users.$post>["json"]
|
||||||
) => {
|
) => {
|
||||||
return await fetchRPC(
|
return await fetchRPC(
|
||||||
client.users.$post({
|
client.users.$post({
|
||||||
form,
|
json,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateUser = async (
|
export const updateUser = async (
|
||||||
form: InferRequestType<(typeof client.users)[":id"]["$patch"]>["form"] & {
|
json: InferRequestType<(typeof client.users)[":id"]["$patch"]>["json"] & {
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
return await fetchRPC(
|
return await fetchRPC(
|
||||||
client.users[":id"].$patch({
|
client.users[":id"].$patch({
|
||||||
param: {
|
param: {
|
||||||
id: form.id,
|
id: json.id,
|
||||||
},
|
},
|
||||||
form,
|
json,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { createColumnHelper } from "@tanstack/react-table";
|
import { createColumnHelper } from "@tanstack/react-table";
|
||||||
import { Badge, Flex, Group, Avatar, Text, Anchor } from "@mantine/core";
|
|
||||||
import { TbEye, TbPencil, TbTrash } from "react-icons/tb";
|
import { TbEye, TbPencil, TbTrash } from "react-icons/tb";
|
||||||
import { CrudPermission } from "@/types";
|
import { CrudPermission } from "@/types";
|
||||||
import stringToColorHex from "@/utils/stringToColorHex";
|
import stringToColorHex from "@/utils/stringToColorHex";
|
||||||
|
|
@ -7,6 +6,8 @@ import createActionButtons from "@/utils/createActionButton";
|
||||||
import client from "@/honoClient";
|
import client from "@/honoClient";
|
||||||
import { InferResponseType } from "hono";
|
import { InferResponseType } from "hono";
|
||||||
import { Link } from "@tanstack/react-router";
|
import { Link } from "@tanstack/react-router";
|
||||||
|
import { Badge } from "@/shadcn/components/ui/badge";
|
||||||
|
import { Avatar } from "@/shadcn/components/ui/avatar";
|
||||||
|
|
||||||
interface ColumnOptions {
|
interface ColumnOptions {
|
||||||
permissions: Partial<CrudPermission>;
|
permissions: Partial<CrudPermission>;
|
||||||
|
|
@ -29,31 +30,28 @@ const createColumns = (options: ColumnOptions) => {
|
||||||
columnHelper.accessor("name", {
|
columnHelper.accessor("name", {
|
||||||
header: "Name",
|
header: "Name",
|
||||||
cell: (props) => (
|
cell: (props) => (
|
||||||
<Group>
|
<div className="items-center justify-center gap-2">
|
||||||
<Avatar
|
<Avatar
|
||||||
color={stringToColorHex(props.row.original.id)}
|
style={{ backgroundColor: stringToColorHex(props.row.original.id), width: '26px', height: '26px' }}
|
||||||
// src={props.row.original.photoUrl}
|
// src={props.row.original.photoUrl}
|
||||||
size={26}
|
|
||||||
>
|
>
|
||||||
{props.getValue()?.[0].toUpperCase()}
|
{props.getValue()?.[0].toUpperCase()}
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<Text size="sm" fw={500}>
|
<span className="text-sm font-medium">
|
||||||
{props.getValue()}
|
{props.getValue()}
|
||||||
</Text>
|
</span>
|
||||||
</Group>
|
</div>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
columnHelper.accessor("email", {
|
columnHelper.accessor("email", {
|
||||||
header: "Email",
|
header: "Email",
|
||||||
cell: (props) => (
|
cell: (props) => (
|
||||||
<Anchor
|
<Link
|
||||||
to={`mailto:${props.getValue()}`}
|
href={`mailto:${props.getValue()}`}
|
||||||
size="sm"
|
>
|
||||||
component={Link}
|
|
||||||
>
|
|
||||||
{props.getValue()}
|
{props.getValue()}
|
||||||
</Anchor>
|
</Link>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
@ -66,7 +64,7 @@ const createColumns = (options: ColumnOptions) => {
|
||||||
id: "status",
|
id: "status",
|
||||||
header: "Status",
|
header: "Status",
|
||||||
cell: (props) => (
|
cell: (props) => (
|
||||||
<Badge color={props.row.original.isEnabled ? "green" : "gray"}>
|
<Badge variant={props.row.original.isEnabled ? "default" : "secondary"}>
|
||||||
{props.row.original.isEnabled ? "Active" : "Inactive"}
|
{props.row.original.isEnabled ? "Active" : "Inactive"}
|
||||||
</Badge>
|
</Badge>
|
||||||
),
|
),
|
||||||
|
|
@ -80,7 +78,7 @@ const createColumns = (options: ColumnOptions) => {
|
||||||
className: "w-fit",
|
className: "w-fit",
|
||||||
},
|
},
|
||||||
cell: (props) => (
|
cell: (props) => (
|
||||||
<Flex gap="xs">
|
<div className="gap-8">
|
||||||
{createActionButtons([
|
{createActionButtons([
|
||||||
{
|
{
|
||||||
label: "Detail",
|
label: "Detail",
|
||||||
|
|
@ -104,7 +102,7 @@ const createColumns = (options: ColumnOptions) => {
|
||||||
icon: <TbTrash />,
|
icon: <TbTrash />,
|
||||||
},
|
},
|
||||||
])}
|
])}
|
||||||
</Flex>
|
</div>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,68 +1,65 @@
|
||||||
import { AppShell } from "@mantine/core";
|
|
||||||
import { Navigate, Outlet, createFileRoute } from "@tanstack/react-router";
|
import { Navigate, Outlet, createFileRoute } from "@tanstack/react-router";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
|
||||||
import AppHeader from "../components/AppHeader";
|
import AppHeader from "../components/AppHeader";
|
||||||
import AppNavbar from "../components/AppNavbar";
|
import AppNavbar from "../components/AppNavbar";
|
||||||
import useAuth from "@/hooks/useAuth";
|
import useAuth from "@/hooks/useAuth";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import fetchRPC from "@/utils/fetchRPC";
|
import fetchRPC from "@/utils/fetchRPC";
|
||||||
import client from "@/honoClient";
|
import client from "@/honoClient";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_dashboardLayout")({
|
export const Route = createFileRoute("/_dashboardLayout")({
|
||||||
component: DashboardLayout,
|
component: DashboardLayout,
|
||||||
|
|
||||||
// beforeLoad: ({ location }) => {
|
// beforeLoad: ({ location }) => {
|
||||||
// if (true) {
|
// if (true) {
|
||||||
// throw redirect({
|
// throw redirect({
|
||||||
// to: "/login",
|
// to: "/login",
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
});
|
});
|
||||||
|
|
||||||
function DashboardLayout() {
|
function DashboardLayout() {
|
||||||
const { isAuthenticated, saveAuthData } = useAuth();
|
const { isAuthenticated, saveAuthData } = useAuth();
|
||||||
|
|
||||||
useQuery({
|
useQuery({
|
||||||
queryKey: ["my-profile"],
|
queryKey: ["my-profile"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const response = await fetchRPC(client.auth["my-profile"].$get());
|
const response = await fetchRPC(client.auth["my-profile"].$get());
|
||||||
|
|
||||||
saveAuthData({
|
saveAuthData({
|
||||||
id: response.id,
|
id: response.id,
|
||||||
name: response.name,
|
name: response.name,
|
||||||
permissions: response.permissions,
|
permissions: response.permissions,
|
||||||
});
|
});
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
enabled: isAuthenticated,
|
enabled: isAuthenticated,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [openNavbar, { toggle }] = useDisclosure(false);
|
const [openNavbar, setNavbarOpen] = useState(true);
|
||||||
|
const toggle = () => {
|
||||||
|
setNavbarOpen(!openNavbar);
|
||||||
|
};
|
||||||
|
|
||||||
return isAuthenticated ? (
|
return isAuthenticated ? (
|
||||||
<AppShell
|
<div className="flex flex-col w-full h-screen overflow-hidden">
|
||||||
padding="md"
|
{/* Header */}
|
||||||
header={{ height: 70 }}
|
<AppHeader toggle={toggle} openNavbar={openNavbar} />
|
||||||
navbar={{
|
|
||||||
width: 300,
|
|
||||||
breakpoint: "sm",
|
|
||||||
collapsed: { mobile: !openNavbar },
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<AppHeader openNavbar={openNavbar} toggle={toggle} />
|
|
||||||
|
|
||||||
<AppNavbar />
|
{/* Main Content Area */}
|
||||||
|
<div className="flex h-full w-screen overflow-hidden">
|
||||||
|
{/* Sidebar */}
|
||||||
|
<AppNavbar />
|
||||||
|
|
||||||
<AppShell.Main
|
{/* Main Content */}
|
||||||
className="bg-slate-100"
|
<main className="relative w-full mt-16 p-6 bg-white overflow-auto">
|
||||||
styles={{ main: { backgroundColor: "rgb(241 245 249)" } }}
|
<Outlet />
|
||||||
>
|
</main>
|
||||||
<Outlet />
|
</div>
|
||||||
</AppShell.Main>
|
</div>
|
||||||
</AppShell>
|
) : (
|
||||||
) : (
|
<Navigate to="/login" />
|
||||||
<Navigate to="/login" />
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,17 @@ const columnHelper = createColumnHelper<DataType>();
|
||||||
export default function UsersPage() {
|
export default function UsersPage() {
|
||||||
return (
|
return (
|
||||||
<PageTemplate
|
<PageTemplate
|
||||||
title="Users"
|
title="Manajemen Pengguna"
|
||||||
queryOptions={userQueryOptions}
|
queryOptions={userQueryOptions}
|
||||||
modals={[<UserFormModal />, <UserDeleteModal />]}
|
modals={[<UserFormModal />, <UserDeleteModal />]}
|
||||||
columnDefs={[
|
columnDefs={[
|
||||||
columnHelper.display({
|
columnHelper.display({
|
||||||
header: "#",
|
header: "No",
|
||||||
cell: (props) => props.row.index + 1,
|
cell: (props) => props.row.index + 1,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
columnHelper.display({
|
columnHelper.display({
|
||||||
header: "Name",
|
header: "Nama",
|
||||||
cell: (props) => props.row.original.name,
|
cell: (props) => props.row.original.name,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
@ -38,19 +38,28 @@ export default function UsersPage() {
|
||||||
header: "Username",
|
header: "Username",
|
||||||
cell: (props) => props.row.original.username,
|
cell: (props) => props.row.original.username,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
columnHelper.display({
|
columnHelper.display({
|
||||||
header: "Status",
|
header: "Email",
|
||||||
cell: (props) =>
|
cell: (props) => props.row.original.email,
|
||||||
props.row.original.isEnabled ? (
|
}),
|
||||||
<Badge color="green">Active</Badge>
|
columnHelper.display({
|
||||||
) : (
|
header: "Perusahaan",
|
||||||
<Badge color="red">Inactive</Badge>
|
cell: (props) => props.row.original.company,
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
columnHelper.display({
|
columnHelper.display({
|
||||||
header: "Actions",
|
header: "Roles",
|
||||||
|
cell: (props) => {
|
||||||
|
const roles = props.row.original.roles; // Get array of roles from data
|
||||||
|
if (roles && roles.length > 0) {
|
||||||
|
return roles.map(role => role.name).join(", ");
|
||||||
|
}
|
||||||
|
return <div>-</div>;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
columnHelper.display({
|
||||||
|
header: "Aksi",
|
||||||
cell: (props) => (
|
cell: (props) => (
|
||||||
<Flex gap="xs">
|
<Flex gap="xs">
|
||||||
{createActionButtons([
|
{createActionButtons([
|
||||||
|
|
@ -62,14 +71,14 @@ export default function UsersPage() {
|
||||||
icon: <TbEye />,
|
icon: <TbEye />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Edit",
|
label: "Ubah",
|
||||||
permission: true,
|
permission: true,
|
||||||
action: `?edit=${props.row.original.id}`,
|
action: `?edit=${props.row.original.id}`,
|
||||||
color: "orange",
|
color: "orange",
|
||||||
icon: <TbPencil />,
|
icon: <TbPencil />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Delete",
|
label: "Hapus",
|
||||||
permission: true,
|
permission: true,
|
||||||
action: `?delete=${props.row.original.id}`,
|
action: `?delete=${props.row.original.id}`,
|
||||||
color: "red",
|
color: "red",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||||
import { TbArrowNarrowRight } from "react-icons/tb";
|
import { TbArrowNarrowRight } from "react-icons/tb";
|
||||||
import { IoIosArrowUp } from "react-icons/io";
|
import { IoIosArrowUp } from "react-icons/io";
|
||||||
import { HiOutlineGlobeAlt } from "react-icons/hi";
|
import { HiOutlineGlobeAlt } from "react-icons/hi";
|
||||||
import { useForm, Control, FieldError } from "react-hook-form";
|
import { useForm, Control, FieldError } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
@ -87,11 +87,11 @@ const CustomDropdownMenu: React.FC<DropdownProps> = ({
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button className="bg-transparent text-gray-800 w-full justify-between text-xs hover:bg-blue-100">
|
<Button className="bg-transparent text-gray-800 w-full justify-between text-xs hover:bg-blue-100">
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<HiOutlineGlobeAlt className="h-3 w-3" />
|
<HiOutlineGlobeAlt className="h-3 w-3" />
|
||||||
{selectedOption || "Select an option"}
|
{selectedOption || "Select an option"}
|
||||||
</div>
|
</div>
|
||||||
<IoIosArrowUp className="h-3 w-3 ml-auto" />
|
<IoIosArrowUp className="h-3 w-3 ml-auto" />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
|
|
@ -159,33 +159,30 @@ export function ForgotPasswordForm() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col lg:flex-row min-h-screen w-screen overflow-hidden">
|
<div className="flex flex-col lg:flex-row min-h-screen w-screen overflow-hidden">
|
||||||
<div
|
<div className="absolute inset-0 flex z-0 overflow-hidden">
|
||||||
className="flex w-screen h-screen items-start lg:items-center justify-center lg:justify-end absolute -top-56 lg:top-0 lg:overflow-hidden"
|
<div className="relative h-[50vw] md:h-screen z-0">
|
||||||
>
|
<div className="-translate-y-[calc(50vw+2rem)] md:translate-y-0 w-full md:-translate-x-[calc(10vh-60vw)]">
|
||||||
<div className="flex absolute border border-slate-300 rounded-2xl w-[455px] h-[455px] lg:w-[650px] lg:h-[650px] items-center justify-center -rotate-[15deg]">
|
<span className="absolute scale-[25%] -rotate-12 w-[100vw] h-[100vw] md:w-[100vh] md:h-[100vh] border border-gray-800 flex rounded-xl"></span>
|
||||||
<div className="flex absolute border border-slate-400 rounded-2xl w-2/3 h-2/3 lg:w-4/5 lg:h-4/5 items-center justify-center">
|
<span className="absolute scale-50 -rotate-12 w-[100vw] h-[100vw] md:w-[100vh] md:h-[100vh] border border-gray-400 flex rounded-xl"></span>
|
||||||
<div className="flex absolute border border-slate-500 rounded-2xl w-3/5 h-3/5 lg:w-3/4 lg:h-3/4 items-center justify-center">
|
<span className="absolute scale-75 -rotate-12 w-[100vw] h-[100vw] md:w-[100vh] md:h-[100vh] border border-gray-300 flex rounded-xl"></span>
|
||||||
<div className="hidden lg:flex absolute border border-slate-600 rounded-2xl w-2/3 h-2/3">
|
<span className="absolute scale-100 -rotate-12 w-[100vw] h-[100vw] md:w-[100vh] md:h-[100vh] border border-gray-200 flex rounded-xl"></span>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col min-h-screen p-7 bg-transparent justify-between z-20">
|
<div className="relative flex flex-col min-h-screen p-7 bg-transparent justify-between z-10">
|
||||||
{/* Top */}
|
{/* Top */}
|
||||||
<div className="flex items-center font-bold">Amati</div>
|
<div className="flex items-center font-bold">Amati</div>
|
||||||
|
|
||||||
{/* Center */}
|
{/* Center */}
|
||||||
<div className="flex flex-col h-full w-full bg-transparent justify-center lg:px-28">
|
<div className="flex flex-col h-full w-full xl:ml-32 2xl:ml-72 bg-transparent justify-center lg:px-28">
|
||||||
<div className="flex flex-col w-full gap-y-1 pb-12 justify-between lg:justify-end">
|
<div className="flex flex-col w-full gap-y-1 pb-12 justify-between lg:justify-end">
|
||||||
<h1
|
<h1
|
||||||
className="text-4xl font-bold"
|
className="text-4xl font-bold text-black"
|
||||||
style={{ color: "#000000" }}
|
|
||||||
>
|
>
|
||||||
Forgot Password
|
Forgot Password
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-sm">
|
<p className="text-sm text-muted-foreground">
|
||||||
No worries, we'll send you reset instructions
|
No worries, we'll send you reset instructions
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -207,19 +204,14 @@ export function ForgotPasswordForm() {
|
||||||
<div className="flex flex-col justify-between gap-9">
|
<div className="flex flex-col justify-between gap-9">
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
style={{
|
className="flex items-center justify-between shadow-xl w-full text-white bg-[--primary-color]"
|
||||||
backgroundColor: "#2555FF",
|
|
||||||
color: "white",
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
className="flex items-center justify-between shadow-xl"
|
|
||||||
>
|
>
|
||||||
<span className="flex">Request Reset</span>
|
<span className="flex">Request Reset</span>
|
||||||
<TbArrowNarrowRight className="h-5 w-5" />
|
<TbArrowNarrowRight className="h-5 w-5" />
|
||||||
</Button>
|
</Button>
|
||||||
<a
|
<a
|
||||||
href="/login"
|
href="/login"
|
||||||
className="text-xs text-blue-500 hover:underline font-bold"
|
className="text-xs text-blue-500 hover:underline font-bold w-fit"
|
||||||
>
|
>
|
||||||
Back to login
|
Back to login
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -231,8 +223,8 @@ export function ForgotPasswordForm() {
|
||||||
{/* Bottom */}
|
{/* Bottom */}
|
||||||
<div className="flex items-center justify-center lg:justify-start w-56 h-8 mx-auto lg:mx-0 bg-muted rounded-md">
|
<div className="flex items-center justify-center lg:justify-start w-56 h-8 mx-auto lg:mx-0 bg-muted rounded-md">
|
||||||
<CustomDropdownMenu
|
<CustomDropdownMenu
|
||||||
onSelect={handleSelect}
|
onSelect={handleSelect}
|
||||||
defaultOption="English (United States)"
|
defaultOption="English (United States)"
|
||||||
listOption={["English (United States)", "Indonesia"]}
|
listOption={["English (United States)", "Indonesia"]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,11 @@ const CustomDropdownMenu: React.FC<DropdownProps> = ({
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button className="bg-transparent text-gray-800 w-full justify-between text-xs hover:bg-blue-100">
|
<Button className="bg-transparent text-gray-800 w-full justify-between text-xs hover:bg-blue-100">
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<HiOutlineGlobeAlt className="h-3 w-3" />
|
<HiOutlineGlobeAlt className="h-3 w-3" />
|
||||||
{selectedOption || "Select an option"}
|
{selectedOption || "Select an option"}
|
||||||
</div>
|
</div>
|
||||||
<IoIosArrowUp className="h-3 w-3 ml-auto" />
|
<IoIosArrowUp className="h-3 w-3 ml-auto" />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
|
|
@ -142,7 +142,7 @@ export function ResetPasswordForm() {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const tokenFromURL = urlParams.get("token");
|
const tokenFromURL = urlParams.get("token");
|
||||||
setToken(tokenFromURL);
|
setToken(tokenFromURL);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Function to handle form submission
|
// Function to handle form submission
|
||||||
const onSubmit = async (values: FormSchema) => {
|
const onSubmit = async (values: FormSchema) => {
|
||||||
|
|
@ -195,33 +195,30 @@ export function ResetPasswordForm() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col lg:flex-row min-h-screen w-screen overflow-hidden">
|
<div className="flex flex-col lg:flex-row min-h-screen w-screen overflow-hidden">
|
||||||
<div
|
<div className="absolute inset-0 flex z-0 overflow-hidden">
|
||||||
className="flex w-screen h-screen items-start lg:items-center justify-center lg:justify-end absolute -top-56 lg:top-0 lg:overflow-hidden"
|
<div className="relative h-[50vw] md:h-screen z-0">
|
||||||
>
|
<div className="-translate-y-[calc(50vw+2rem)] md:translate-y-0 w-full md:-translate-x-[calc(10vh-60vw)]">
|
||||||
<div className="flex absolute border border-slate-200 rounded-2xl w-[455px] h-[455px] lg:w-[650px] lg:h-[650px] items-center justify-center -rotate-[15deg]">
|
<span className="absolute scale-[25%] -rotate-12 w-[100vw] h-[100vw] md:w-[100vh] md:h-[100vh] border border-gray-800 flex rounded-xl"></span>
|
||||||
<div className="flex absolute border border-slate-300 rounded-2xl w-2/3 h-2/3 lg:w-4/5 lg:h-4/5 items-center justify-center">
|
<span className="absolute scale-50 -rotate-12 w-[100vw] h-[100vw] md:w-[100vh] md:h-[100vh] border border-gray-400 flex rounded-xl"></span>
|
||||||
<div className="flex absolute border border-slate-400 rounded-2xl w-3/5 h-3/5 lg:w-3/4 lg:h-3/4 items-center justify-center">
|
<span className="absolute scale-75 -rotate-12 w-[100vw] h-[100vw] md:w-[100vh] md:h-[100vh] border border-gray-300 flex rounded-xl"></span>
|
||||||
<div className="hidden lg:flex absolute border border-slate-500 rounded-2xl w-2/3 h-2/3">
|
<span className="absolute scale-100 -rotate-12 w-[100vw] h-[100vw] md:w-[100vh] md:h-[100vh] border border-gray-200 flex rounded-xl"></span>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col min-h-screen p-7 bg-transparent justify-between z-20">
|
<div className="relative flex flex-col min-h-screen p-7 bg-transparent justify-between z-10">
|
||||||
{/* Top */}
|
{/* Top */}
|
||||||
<div className="flex items-center font-bold">Amati</div>
|
<div className="flex items-center font-bold">Amati</div>
|
||||||
|
|
||||||
{/* Center */}
|
{/* Center */}
|
||||||
<div className="flex flex-col h-full w-full bg-transparent justify-center lg:px-28">
|
<div className="flex flex-col h-full w-full xl:ml-32 2xl:ml-72 bg-transparent justify-center lg:px-28">
|
||||||
<div className="flex flex-col w-full gap-y-1 pb-12 justify-between lg:justify-end">
|
<div className="flex flex-col w-full gap-y-1 pb-12 justify-between lg:justify-end">
|
||||||
<h1
|
<h1
|
||||||
className="text-4xl font-bold"
|
className="text-4xl font-bold text-black"
|
||||||
style={{ color: "#000000" }}
|
|
||||||
>
|
>
|
||||||
Change Password
|
Change Password
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-sm">Enter your new password</p>
|
<p className="text-sm text-muted-foreground">Enter your new password</p>
|
||||||
</div>
|
</div>
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
|
|
@ -249,19 +246,14 @@ export function ResetPasswordForm() {
|
||||||
<div className="flex flex-col justify-between gap-9">
|
<div className="flex flex-col justify-between gap-9">
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
style={{
|
className="flex items-center justify-between shadow-xl w-full text-white bg-[--primary-color]"
|
||||||
backgroundColor: "#2555FF",
|
|
||||||
color: "white",
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
className="flex items-center justify-between shadow-xl"
|
|
||||||
>
|
>
|
||||||
<span className="flex">Submit</span>
|
<span className="flex">Submit</span>
|
||||||
<TbArrowNarrowRight className="h-5 w-5" />
|
<TbArrowNarrowRight className="h-5 w-5" />
|
||||||
</Button>
|
</Button>
|
||||||
<a
|
<a
|
||||||
href="/login"
|
href="/login"
|
||||||
className="text-xs text-blue-500 hover:underline font-bold"
|
className="text-xs text-blue-500 hover:underline font-bold w-fit"
|
||||||
>
|
>
|
||||||
Back to login
|
Back to login
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -272,8 +264,8 @@ export function ResetPasswordForm() {
|
||||||
|
|
||||||
<div className="flex items-center justify-center lg:justify-start w-56 h-8 mx-auto lg:mx-0 bg-muted rounded-md">
|
<div className="flex items-center justify-center lg:justify-start w-56 h-8 mx-auto lg:mx-0 bg-muted rounded-md">
|
||||||
<CustomDropdownMenu
|
<CustomDropdownMenu
|
||||||
onSelect={handleSelect}
|
onSelect={handleSelect}
|
||||||
defaultOption="English (United States)"
|
defaultOption="English (United States)"
|
||||||
listOption={["English (United States)", "Indonesia"]}
|
listOption={["English (United States)", "Indonesia"]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import useAuth from "@/hooks/useAuth";
|
import useAuth from "@/hooks/useAuth";
|
||||||
import { TbArrowNarrowRight } from "react-icons/tb";
|
import { TbArrowNarrowRight } from "react-icons/tb";
|
||||||
|
import logo from "@/assets/logos/amati-logo.png";
|
||||||
|
|
||||||
export const Route = createLazyFileRoute("/login/")({
|
export const Route = createLazyFileRoute("/login/")({
|
||||||
component: LoginPage,
|
component: LoginPage,
|
||||||
|
|
@ -30,8 +31,8 @@ type FormSchema = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
username: z.string().min(1, "This field is required"),
|
username: z.string().min(1, "Kolom ini wajib diisi"),
|
||||||
password: z.string().min(1, "This field is required"),
|
password: z.string().min(1, "Kolom ini wajib diisi"),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
|
|
@ -97,94 +98,100 @@ export default function LoginPage() {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className="flex flex-col w-screen h-screen 3xl:max-w-screen-2xl 3xl:mx-auto 3xl:px-4 overflow-hidden">
|
||||||
className="flex items-center justify-center bg-contain bg-top lg:bg-right
|
{/* Navbar */}
|
||||||
bg-no-repeat bg-[url('../src/assets/backgrounds/backgroundLoginMobile.png')]
|
<nav className="flex w-full bg-transparent px-8 py-7 justify-between">
|
||||||
lg:bg-[url('../src/assets/backgrounds/backgroundLogin.png')]"
|
<div className="flex">
|
||||||
>
|
<img src="../src/assets/logos/amati-logo.png" alt="Amati Logo" className="h-4 object-contain" />
|
||||||
<div className="absolute top-[1.688rem] left-[1.875rem] text-base font-bold leading-[1.21rem]">
|
</div>
|
||||||
Amati
|
</nav>
|
||||||
|
|
||||||
|
{/* Background shapes */}
|
||||||
|
<div className="absolute inset-0 flex -z-20 overflow-hidden">
|
||||||
|
<div className="relative h-[50vw] lg:h-screen z-0">
|
||||||
|
<div className="-translate-y-[calc(40vw+2rem)] lg:translate-y-0 w-full lg:-translate-x-[calc(10vh-60vw)]">
|
||||||
|
<span className="absolute scale-50 lg:scale-50 -rotate-12 w-[100vw] h-[100vw] lg:w-[100vh] lg:h-[100vh] border border-gray-800 flex rounded-3xl"></span>
|
||||||
|
<span className="absolute scale-[85%] lg:scale-[70%] -rotate-12 w-[100vw] h-[100vw] lg:w-[100vh] lg:h-[100vh] border border-gray-400 flex rounded-3xl"></span>
|
||||||
|
<span className="absolute scale-[120%] lg:scale-90 -rotate-12 w-[100vw] h-[100vw] lg:w-[100vh] lg:h-[100vh] border border-gray-300 flex rounded-3xl"></span>
|
||||||
|
<span className="absolute scale-150 lg:scale-110 -rotate-12 w-[100vw] h-[100vw] lg:w-[100vh] lg:h-[100vh] border border-gray-200 hidden lg:flex rounded-3xl"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-screen h-screen flex ml-0 lg:ml-[7.063rem] justify-center lg:justify-start items-center">
|
|
||||||
<Card className="w-[19.125rem] sm:w-[26.063rem] lg:w-[29.5rem] h-auto bg-transparent border-none">
|
{/* Sign In form */}
|
||||||
<h1 className="mb-2 text-[2.625rem] font-bold leading-[3.177rem] tracking-tightest">Sign In</h1>
|
<div className="flex w-full min-h-screen ml-0 lg:ml-28 3xl:ml-40 -mt-16 justify-center lg:justify-start items-center">
|
||||||
<p className="text-sm mb-10 leading-[1.059rem]">
|
<Card className="w-full sm:w-3/5 lg:w-2/6 px-8 sm:p-0 h-auto bg-transparent border-none shadow-none">
|
||||||
New to this app?{' '}
|
<h1 className="mb-2 text-4xl font-bold leading-10 tracking-tighter">Sign In</h1>
|
||||||
<a
|
<p className="text-sm mb-10 leading-4 text-muted-foreground">
|
||||||
href="/register"
|
Baru mengenal aplikasi ini?{' '}
|
||||||
className="text-blue-500 font-bold hover:text-blue-800"
|
<a href="/register" className="text-blue-600 font-bold hover:text-blue-800">
|
||||||
>
|
Daftar sekarang
|
||||||
Register now
|
</a>
|
||||||
|
</p>
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={form.handleSubmit(handleSubmit)}>
|
||||||
|
<div className="space-y-5">
|
||||||
|
{errorMessage && (
|
||||||
|
<Alert variant="destructive">
|
||||||
|
<p>{errorMessage}</p>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
<FormField
|
||||||
|
name="username"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="text-sm">
|
||||||
|
<FormLabel className="font-semibold leading-4">Email/Username</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="eg; user@mail.com"
|
||||||
|
disabled={loginMutation.isPending}
|
||||||
|
className={form.formState.errors.username ? "border-red-500" : ""}
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
name="password"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="text-sm">
|
||||||
|
<FormLabel className="font-semibold leading-4">Kata sandi</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
type="password"
|
||||||
|
placeholder="*****"
|
||||||
|
disabled={loginMutation.isPending}
|
||||||
|
className={form.formState.errors.password ? "border-red-500" : ""}
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<p className="text-sm">
|
||||||
|
<a href="/forgot-password" className="text-blue-600 font-bold hover:text-blue-800 leading-4">
|
||||||
|
Lupa kata sandi?
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<Form {...form}>
|
</div>
|
||||||
<form onSubmit={form.handleSubmit(handleSubmit)}>
|
<div className="flex mt-10">
|
||||||
<div className="space-y-5">
|
<Button
|
||||||
{errorMessage && (
|
type="submit"
|
||||||
<Alert variant="destructive">
|
disabled={loginMutation.isPending}
|
||||||
<p>{errorMessage}</p>
|
variant="default"
|
||||||
</Alert>
|
className="flex w-full justify-between bg-blue-600 text-white hover:bg-blue-700"
|
||||||
)}
|
>
|
||||||
<FormField
|
<span className="leading-5">Sign In</span>
|
||||||
name="username"
|
<TbArrowNarrowRight className="h-5 w-5" />
|
||||||
render={({ field }) => (
|
</Button>
|
||||||
<FormItem className="text-sm">
|
</div>
|
||||||
<FormLabel className="font-semibold leading-[1.059rem]">Email/Username</FormLabel>
|
</form>
|
||||||
<FormControl>
|
</Form>
|
||||||
<Input
|
|
||||||
placeholder="eg; user@mail.com"
|
|
||||||
disabled={loginMutation.isPending}
|
|
||||||
className={form.formState.errors.username ? "border-red-500" : ""}
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
name="password"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="text-sm">
|
|
||||||
<FormLabel className="font-semibold leading-[1.059rem]">Password</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
type="password"
|
|
||||||
placeholder="*****"
|
|
||||||
disabled={loginMutation.isPending}
|
|
||||||
className={form.formState.errors.password ? "border-red-500" : ""}
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<p className="text-sm">
|
|
||||||
<a
|
|
||||||
href="/forgot-password"
|
|
||||||
className="text-blue-500 font-bold hover:text-blue-800 leading-[1.059rem]"
|
|
||||||
>
|
|
||||||
Forgot Password?
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="flex justify-between mt-10">
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
disabled={loginMutation.isPending}
|
|
||||||
variant="default"
|
|
||||||
className="w-full flex items-center justify-center space-x-[13.125rem] sm:space-x-[20rem]
|
|
||||||
lg:space-x-[23.125rem] bg-[#2555FF] text-white hover:bg-[#1e4ae0]"
|
|
||||||
>
|
|
||||||
<span className="leading-[1.25rem]">Sign In</span>
|
|
||||||
<TbArrowNarrowRight className="h-5 w-5" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
50
apps/frontend/src/shadcn/components/ui/avatar.tsx
Normal file
50
apps/frontend/src/shadcn/components/ui/avatar.tsx
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Avatar = React.forwardRef<
|
||||||
|
React.ElementRef<typeof AvatarPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<AvatarPrimitive.Root
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
Avatar.displayName = AvatarPrimitive.Root.displayName
|
||||||
|
|
||||||
|
const AvatarImage = React.forwardRef<
|
||||||
|
React.ElementRef<typeof AvatarPrimitive.Image>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<AvatarPrimitive.Image
|
||||||
|
ref={ref}
|
||||||
|
className={cn("aspect-square h-full w-full", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
AvatarImage.displayName = AvatarPrimitive.Image.displayName
|
||||||
|
|
||||||
|
const AvatarFallback = React.forwardRef<
|
||||||
|
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<AvatarPrimitive.Fallback
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
|
||||||
|
|
||||||
|
export { Avatar, AvatarImage, AvatarFallback }
|
||||||
36
apps/frontend/src/shadcn/components/ui/badge.tsx
Normal file
36
apps/frontend/src/shadcn/components/ui/badge.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import * as React from "react"
|
||||||
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const badgeVariants = cva(
|
||||||
|
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
default:
|
||||||
|
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
||||||
|
secondary:
|
||||||
|
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||||
|
destructive:
|
||||||
|
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
||||||
|
outline: "text-foreground",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "default",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export interface BadgeProps
|
||||||
|
extends React.HTMLAttributes<HTMLDivElement>,
|
||||||
|
VariantProps<typeof badgeVariants> {}
|
||||||
|
|
||||||
|
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||||
|
return (
|
||||||
|
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Badge, badgeVariants }
|
||||||
115
apps/frontend/src/shadcn/components/ui/breadcrumb.tsx
Normal file
115
apps/frontend/src/shadcn/components/ui/breadcrumb.tsx
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
import * as React from "react"
|
||||||
|
import { Slot } from "@radix-ui/react-slot"
|
||||||
|
import { ChevronRight, MoreHorizontal } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Breadcrumb = React.forwardRef<
|
||||||
|
HTMLElement,
|
||||||
|
React.ComponentPropsWithoutRef<"nav"> & {
|
||||||
|
separator?: React.ReactNode
|
||||||
|
}
|
||||||
|
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />)
|
||||||
|
Breadcrumb.displayName = "Breadcrumb"
|
||||||
|
|
||||||
|
const BreadcrumbList = React.forwardRef<
|
||||||
|
HTMLOListElement,
|
||||||
|
React.ComponentPropsWithoutRef<"ol">
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<ol
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
BreadcrumbList.displayName = "BreadcrumbList"
|
||||||
|
|
||||||
|
const BreadcrumbItem = React.forwardRef<
|
||||||
|
HTMLLIElement,
|
||||||
|
React.ComponentPropsWithoutRef<"li">
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<li
|
||||||
|
ref={ref}
|
||||||
|
className={cn("inline-flex items-center gap-1.5", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
BreadcrumbItem.displayName = "BreadcrumbItem"
|
||||||
|
|
||||||
|
const BreadcrumbLink = React.forwardRef<
|
||||||
|
HTMLAnchorElement,
|
||||||
|
React.ComponentPropsWithoutRef<"a"> & {
|
||||||
|
asChild?: boolean
|
||||||
|
}
|
||||||
|
>(({ asChild, className, ...props }, ref) => {
|
||||||
|
const Comp = asChild ? Slot : "a"
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Comp
|
||||||
|
ref={ref}
|
||||||
|
className={cn("transition-colors hover:text-foreground", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
BreadcrumbLink.displayName = "BreadcrumbLink"
|
||||||
|
|
||||||
|
const BreadcrumbPage = React.forwardRef<
|
||||||
|
HTMLSpanElement,
|
||||||
|
React.ComponentPropsWithoutRef<"span">
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<span
|
||||||
|
ref={ref}
|
||||||
|
role="link"
|
||||||
|
aria-disabled="true"
|
||||||
|
aria-current="page"
|
||||||
|
className={cn("font-normal text-foreground", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
BreadcrumbPage.displayName = "BreadcrumbPage"
|
||||||
|
|
||||||
|
const BreadcrumbSeparator = ({
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"li">) => (
|
||||||
|
<li
|
||||||
|
role="presentation"
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn("[&>svg]:size-3.5", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children ?? <ChevronRight />}
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
BreadcrumbSeparator.displayName = "BreadcrumbSeparator"
|
||||||
|
|
||||||
|
const BreadcrumbEllipsis = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"span">) => (
|
||||||
|
<span
|
||||||
|
role="presentation"
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<MoreHorizontal className="h-4 w-4" />
|
||||||
|
<span className="sr-only">More</span>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis"
|
||||||
|
|
||||||
|
export {
|
||||||
|
Breadcrumb,
|
||||||
|
BreadcrumbList,
|
||||||
|
BreadcrumbItem,
|
||||||
|
BreadcrumbLink,
|
||||||
|
BreadcrumbPage,
|
||||||
|
BreadcrumbSeparator,
|
||||||
|
BreadcrumbEllipsis,
|
||||||
|
}
|
||||||
122
apps/frontend/src/shadcn/components/ui/dialog.tsx
Normal file
122
apps/frontend/src/shadcn/components/ui/dialog.tsx
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
||||||
|
import { X } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Dialog = DialogPrimitive.Root
|
||||||
|
|
||||||
|
const DialogTrigger = DialogPrimitive.Trigger
|
||||||
|
|
||||||
|
const DialogPortal = DialogPrimitive.Portal
|
||||||
|
|
||||||
|
const DialogClose = DialogPrimitive.Close
|
||||||
|
|
||||||
|
const DialogOverlay = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Overlay
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
||||||
|
|
||||||
|
const DialogContent = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<DialogPortal>
|
||||||
|
<DialogOverlay />
|
||||||
|
<DialogPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||||
|
<X className="h-4 w-4" />
|
||||||
|
<span className="sr-only">Close</span>
|
||||||
|
</DialogPrimitive.Close>
|
||||||
|
</DialogPrimitive.Content>
|
||||||
|
</DialogPortal>
|
||||||
|
))
|
||||||
|
DialogContent.displayName = DialogPrimitive.Content.displayName
|
||||||
|
|
||||||
|
const DialogHeader = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col space-y-1.5 text-center sm:text-left",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
DialogHeader.displayName = "DialogHeader"
|
||||||
|
|
||||||
|
const DialogFooter = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
DialogFooter.displayName = "DialogFooter"
|
||||||
|
|
||||||
|
const DialogTitle = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Title>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Title
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"text-lg font-semibold leading-none tracking-tight",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
||||||
|
|
||||||
|
const DialogDescription = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Description>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Description
|
||||||
|
ref={ref}
|
||||||
|
className={cn("text-sm text-muted-foreground", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
||||||
|
|
||||||
|
export {
|
||||||
|
Dialog,
|
||||||
|
DialogPortal,
|
||||||
|
DialogOverlay,
|
||||||
|
DialogClose,
|
||||||
|
DialogTrigger,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogFooter,
|
||||||
|
DialogTitle,
|
||||||
|
DialogDescription,
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
"use client"
|
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
||||||
import { Check, ChevronRight, Circle } from "lucide-react"
|
import { Check, ChevronRight, Circle } from "lucide-react"
|
||||||
|
|
|
||||||
117
apps/frontend/src/shadcn/components/ui/pagination.tsx
Normal file
117
apps/frontend/src/shadcn/components/ui/pagination.tsx
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
import * as React from "react"
|
||||||
|
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
import { ButtonProps, buttonVariants } from "@/shadcn/components/ui/button"
|
||||||
|
|
||||||
|
const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
|
||||||
|
<nav
|
||||||
|
role="navigation"
|
||||||
|
aria-label="pagination"
|
||||||
|
className={cn("mx-auto flex w-full justify-center", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
Pagination.displayName = "Pagination"
|
||||||
|
|
||||||
|
const PaginationContent = React.forwardRef<
|
||||||
|
HTMLUListElement,
|
||||||
|
React.ComponentProps<"ul">
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<ul
|
||||||
|
ref={ref}
|
||||||
|
className={cn("flex flex-row items-center gap-1", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
PaginationContent.displayName = "PaginationContent"
|
||||||
|
|
||||||
|
const PaginationItem = React.forwardRef<
|
||||||
|
HTMLLIElement,
|
||||||
|
React.ComponentProps<"li">
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<li ref={ref} className={cn("", className)} {...props} />
|
||||||
|
))
|
||||||
|
PaginationItem.displayName = "PaginationItem"
|
||||||
|
|
||||||
|
type PaginationLinkProps = {
|
||||||
|
isActive?: boolean
|
||||||
|
} & Pick<ButtonProps, "size"> &
|
||||||
|
React.ComponentProps<"a">
|
||||||
|
|
||||||
|
const PaginationLink = ({
|
||||||
|
className,
|
||||||
|
isActive,
|
||||||
|
size = "icon",
|
||||||
|
...props
|
||||||
|
}: PaginationLinkProps) => (
|
||||||
|
<a
|
||||||
|
aria-current={isActive ? "page" : undefined}
|
||||||
|
className={cn(
|
||||||
|
buttonVariants({
|
||||||
|
variant: isActive ? "outline" : "ghost",
|
||||||
|
size,
|
||||||
|
}),
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
PaginationLink.displayName = "PaginationLink"
|
||||||
|
|
||||||
|
const PaginationPrevious = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof PaginationLink>) => (
|
||||||
|
<PaginationLink
|
||||||
|
aria-label="Go to previous page"
|
||||||
|
size="default"
|
||||||
|
className={cn("gap-1 pl-2.5", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ChevronLeft className="h-4 w-4" />
|
||||||
|
<span>Previous</span>
|
||||||
|
</PaginationLink>
|
||||||
|
)
|
||||||
|
PaginationPrevious.displayName = "PaginationPrevious"
|
||||||
|
|
||||||
|
const PaginationNext = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof PaginationLink>) => (
|
||||||
|
<PaginationLink
|
||||||
|
aria-label="Go to next page"
|
||||||
|
size="default"
|
||||||
|
className={cn("gap-1 pr-2.5", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<span>Next</span>
|
||||||
|
<ChevronRight className="h-4 w-4" />
|
||||||
|
</PaginationLink>
|
||||||
|
)
|
||||||
|
PaginationNext.displayName = "PaginationNext"
|
||||||
|
|
||||||
|
const PaginationEllipsis = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"span">) => (
|
||||||
|
<span
|
||||||
|
aria-hidden
|
||||||
|
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<MoreHorizontal className="h-4 w-4" />
|
||||||
|
<span className="sr-only">More pages</span>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
PaginationEllipsis.displayName = "PaginationEllipsis"
|
||||||
|
|
||||||
|
export {
|
||||||
|
Pagination,
|
||||||
|
PaginationContent,
|
||||||
|
PaginationEllipsis,
|
||||||
|
PaginationItem,
|
||||||
|
PaginationLink,
|
||||||
|
PaginationNext,
|
||||||
|
PaginationPrevious,
|
||||||
|
}
|
||||||
44
apps/frontend/src/shadcn/components/ui/radio-group.tsx
Normal file
44
apps/frontend/src/shadcn/components/ui/radio-group.tsx
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
||||||
|
import { Circle } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const RadioGroup = React.forwardRef<
|
||||||
|
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
||||||
|
>(({ className, ...props }, ref) => {
|
||||||
|
return (
|
||||||
|
<RadioGroupPrimitive.Root
|
||||||
|
className={cn("grid gap-2", className)}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
|
||||||
|
|
||||||
|
const RadioGroupItem = React.forwardRef<
|
||||||
|
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
||||||
|
>(({ className, ...props }, ref) => {
|
||||||
|
return (
|
||||||
|
<RadioGroupPrimitive.Item
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
||||||
|
<Circle className="h-2.5 w-2.5 fill-current text-current" />
|
||||||
|
</RadioGroupPrimitive.Indicator>
|
||||||
|
</RadioGroupPrimitive.Item>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
|
||||||
|
|
||||||
|
export { RadioGroup, RadioGroupItem }
|
||||||
48
apps/frontend/src/shadcn/components/ui/scroll-area.tsx
Normal file
48
apps/frontend/src/shadcn/components/ui/scroll-area.tsx
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const ScrollArea = React.forwardRef<
|
||||||
|
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<ScrollAreaPrimitive.Root
|
||||||
|
ref={ref}
|
||||||
|
className={cn("relative overflow-hidden", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
||||||
|
{children}
|
||||||
|
</ScrollAreaPrimitive.Viewport>
|
||||||
|
<ScrollBar />
|
||||||
|
<ScrollAreaPrimitive.Corner />
|
||||||
|
</ScrollAreaPrimitive.Root>
|
||||||
|
))
|
||||||
|
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
|
||||||
|
|
||||||
|
const ScrollBar = React.forwardRef<
|
||||||
|
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
>(({ className, orientation = "vertical", ...props }, ref) => (
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||||
|
ref={ref}
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"flex touch-none select-none transition-colors",
|
||||||
|
orientation === "vertical" &&
|
||||||
|
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
||||||
|
orientation === "horizontal" &&
|
||||||
|
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
||||||
|
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
))
|
||||||
|
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
|
||||||
|
|
||||||
|
export { ScrollArea, ScrollBar }
|
||||||
160
apps/frontend/src/shadcn/components/ui/select.tsx
Normal file
160
apps/frontend/src/shadcn/components/ui/select.tsx
Normal file
|
|
@ -0,0 +1,160 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as SelectPrimitive from "@radix-ui/react-select"
|
||||||
|
import { Check, ChevronDown, ChevronUp } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Select = SelectPrimitive.Root
|
||||||
|
|
||||||
|
const SelectGroup = SelectPrimitive.Group
|
||||||
|
|
||||||
|
const SelectValue = SelectPrimitive.Value
|
||||||
|
|
||||||
|
const SelectTrigger = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Trigger
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
<SelectPrimitive.Icon asChild>
|
||||||
|
<ChevronDown className="h-4 w-4 opacity-50" />
|
||||||
|
</SelectPrimitive.Icon>
|
||||||
|
</SelectPrimitive.Trigger>
|
||||||
|
))
|
||||||
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
|
||||||
|
|
||||||
|
const SelectScrollUpButton = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.ScrollUpButton
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"flex cursor-default items-center justify-center py-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ChevronUp className="h-4 w-4" />
|
||||||
|
</SelectPrimitive.ScrollUpButton>
|
||||||
|
))
|
||||||
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
|
||||||
|
|
||||||
|
const SelectScrollDownButton = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.ScrollDownButton
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"flex cursor-default items-center justify-center py-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ChevronDown className="h-4 w-4" />
|
||||||
|
</SelectPrimitive.ScrollDownButton>
|
||||||
|
))
|
||||||
|
SelectScrollDownButton.displayName =
|
||||||
|
SelectPrimitive.ScrollDownButton.displayName
|
||||||
|
|
||||||
|
const SelectContent = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
||||||
|
>(({ className, children, position = "popper", ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Portal>
|
||||||
|
<SelectPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||||
|
position === "popper" &&
|
||||||
|
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
position={position}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<SelectScrollUpButton />
|
||||||
|
<SelectPrimitive.Viewport
|
||||||
|
className={cn(
|
||||||
|
"p-1",
|
||||||
|
position === "popper" &&
|
||||||
|
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</SelectPrimitive.Viewport>
|
||||||
|
<SelectScrollDownButton />
|
||||||
|
</SelectPrimitive.Content>
|
||||||
|
</SelectPrimitive.Portal>
|
||||||
|
))
|
||||||
|
SelectContent.displayName = SelectPrimitive.Content.displayName
|
||||||
|
|
||||||
|
const SelectLabel = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Label>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Label
|
||||||
|
ref={ref}
|
||||||
|
className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
SelectLabel.displayName = SelectPrimitive.Label.displayName
|
||||||
|
|
||||||
|
const SelectItem = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Item>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Item
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||||
|
<SelectPrimitive.ItemIndicator>
|
||||||
|
<Check className="h-4 w-4" />
|
||||||
|
</SelectPrimitive.ItemIndicator>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
||||||
|
</SelectPrimitive.Item>
|
||||||
|
))
|
||||||
|
SelectItem.displayName = SelectPrimitive.Item.displayName
|
||||||
|
|
||||||
|
const SelectSeparator = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Separator>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Separator
|
||||||
|
ref={ref}
|
||||||
|
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
|
||||||
|
|
||||||
|
export {
|
||||||
|
Select,
|
||||||
|
SelectGroup,
|
||||||
|
SelectValue,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectContent,
|
||||||
|
SelectLabel,
|
||||||
|
SelectItem,
|
||||||
|
SelectSeparator,
|
||||||
|
SelectScrollUpButton,
|
||||||
|
SelectScrollDownButton,
|
||||||
|
}
|
||||||
117
apps/frontend/src/shadcn/components/ui/table.tsx
Normal file
117
apps/frontend/src/shadcn/components/ui/table.tsx
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
import * as React from "react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Table = React.forwardRef<
|
||||||
|
HTMLTableElement,
|
||||||
|
React.HTMLAttributes<HTMLTableElement>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<div className="relative w-full overflow-auto">
|
||||||
|
<table
|
||||||
|
ref={ref}
|
||||||
|
className={cn("w-full caption-bottom text-sm", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
Table.displayName = "Table"
|
||||||
|
|
||||||
|
const TableHeader = React.forwardRef<
|
||||||
|
HTMLTableSectionElement,
|
||||||
|
React.HTMLAttributes<HTMLTableSectionElement>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
|
||||||
|
))
|
||||||
|
TableHeader.displayName = "TableHeader"
|
||||||
|
|
||||||
|
const TableBody = React.forwardRef<
|
||||||
|
HTMLTableSectionElement,
|
||||||
|
React.HTMLAttributes<HTMLTableSectionElement>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<tbody
|
||||||
|
ref={ref}
|
||||||
|
className={cn("[&_tr:last-child]:border-0", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
TableBody.displayName = "TableBody"
|
||||||
|
|
||||||
|
const TableFooter = React.forwardRef<
|
||||||
|
HTMLTableSectionElement,
|
||||||
|
React.HTMLAttributes<HTMLTableSectionElement>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<tfoot
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
TableFooter.displayName = "TableFooter"
|
||||||
|
|
||||||
|
const TableRow = React.forwardRef<
|
||||||
|
HTMLTableRowElement,
|
||||||
|
React.HTMLAttributes<HTMLTableRowElement>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<tr
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
TableRow.displayName = "TableRow"
|
||||||
|
|
||||||
|
const TableHead = React.forwardRef<
|
||||||
|
HTMLTableCellElement,
|
||||||
|
React.ThHTMLAttributes<HTMLTableCellElement>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<th
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
TableHead.displayName = "TableHead"
|
||||||
|
|
||||||
|
const TableCell = React.forwardRef<
|
||||||
|
HTMLTableCellElement,
|
||||||
|
React.TdHTMLAttributes<HTMLTableCellElement>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<td
|
||||||
|
ref={ref}
|
||||||
|
className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
TableCell.displayName = "TableCell"
|
||||||
|
|
||||||
|
const TableCaption = React.forwardRef<
|
||||||
|
HTMLTableCaptionElement,
|
||||||
|
React.HTMLAttributes<HTMLTableCaptionElement>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<caption
|
||||||
|
ref={ref}
|
||||||
|
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
TableCaption.displayName = "TableCaption"
|
||||||
|
|
||||||
|
export {
|
||||||
|
Table,
|
||||||
|
TableHeader,
|
||||||
|
TableBody,
|
||||||
|
TableFooter,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
TableCell,
|
||||||
|
TableCaption,
|
||||||
|
}
|
||||||
24
apps/frontend/src/shadcn/components/ui/textarea.tsx
Normal file
24
apps/frontend/src/shadcn/components/ui/textarea.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import * as React from "react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
export interface TextareaProps
|
||||||
|
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
|
||||||
|
|
||||||
|
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||||
|
({ className, ...props }, ref) => {
|
||||||
|
return (
|
||||||
|
<textarea
|
||||||
|
className={cn(
|
||||||
|
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Textarea.displayName = "Textarea"
|
||||||
|
|
||||||
|
export { Textarea }
|
||||||
|
|
@ -72,15 +72,13 @@ module.exports = {
|
||||||
"accordion-up": "accordion-up 0.2s ease-out",
|
"accordion-up": "accordion-up 0.2s ease-out",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
letterSpacing: {
|
screens: {
|
||||||
tightest: '-.075em',
|
'sm': '640px',
|
||||||
tighter: '-.05em',
|
'md': '768px',
|
||||||
tight: '-.025em',
|
'lg': '1024px',
|
||||||
normal: '0',
|
'xl': '1280px',
|
||||||
wide: '.025em',
|
'2xl': '1536px',
|
||||||
wider: '.05em',
|
'3xl': '1980px',
|
||||||
widest: '.1em',
|
|
||||||
widest: '.25em',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [require("tailwindcss-animate")],
|
plugins: [require("tailwindcss-animate")],
|
||||||
|
|
|
||||||
214
pnpm-lock.yaml
214
pnpm-lock.yaml
|
|
@ -111,15 +111,30 @@ importers:
|
||||||
'@mantine/notifications':
|
'@mantine/notifications':
|
||||||
specifier: ^7.10.2
|
specifier: ^7.10.2
|
||||||
version: 7.10.2(@mantine/core@7.10.2(@mantine/hooks@7.10.2(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.10.2(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
version: 7.10.2(@mantine/core@7.10.2(@mantine/hooks@7.10.2(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.10.2(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-avatar':
|
||||||
|
specifier: ^1.1.0
|
||||||
|
version: 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
'@radix-ui/react-checkbox':
|
'@radix-ui/react-checkbox':
|
||||||
specifier: ^1.1.1
|
specifier: ^1.1.1
|
||||||
version: 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
version: 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-dialog':
|
||||||
|
specifier: ^1.1.1
|
||||||
|
version: 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
'@radix-ui/react-dropdown-menu':
|
'@radix-ui/react-dropdown-menu':
|
||||||
specifier: ^2.1.1
|
specifier: ^2.1.1
|
||||||
version: 2.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
version: 2.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
'@radix-ui/react-label':
|
'@radix-ui/react-label':
|
||||||
specifier: ^2.1.0
|
specifier: ^2.1.0
|
||||||
version: 2.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
version: 2.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-radio-group':
|
||||||
|
specifier: ^1.2.0
|
||||||
|
version: 1.2.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-scroll-area':
|
||||||
|
specifier: ^1.1.0
|
||||||
|
version: 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-select':
|
||||||
|
specifier: ^2.1.1
|
||||||
|
version: 2.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
'@radix-ui/react-slot':
|
'@radix-ui/react-slot':
|
||||||
specifier: ^1.1.0
|
specifier: ^1.1.0
|
||||||
version: 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
version: 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
|
@ -1459,6 +1474,9 @@ packages:
|
||||||
resolution: {integrity: sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==}
|
resolution: {integrity: sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==}
|
||||||
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
||||||
|
|
||||||
|
'@radix-ui/number@1.1.0':
|
||||||
|
resolution: {integrity: sha512-V3gRzhVNU1ldS5XhAPTom1fOIo4ccrjjJgmE+LI2h/WaFpHmx0MQApT+KZHnx8abG6Avtfcz4WoEciMnpFT3HQ==}
|
||||||
|
|
||||||
'@radix-ui/primitive@1.1.0':
|
'@radix-ui/primitive@1.1.0':
|
||||||
resolution: {integrity: sha512-4Z8dn6Upk0qk4P74xBhZ6Hd/w0mPEzOOLxy4xiPXOXqjF7jZS0VAKk7/x/H6FyY2zCkYJqePf1G5KmkmNJ4RBA==}
|
resolution: {integrity: sha512-4Z8dn6Upk0qk4P74xBhZ6Hd/w0mPEzOOLxy4xiPXOXqjF7jZS0VAKk7/x/H6FyY2zCkYJqePf1G5KmkmNJ4RBA==}
|
||||||
|
|
||||||
|
|
@ -1475,6 +1493,19 @@ packages:
|
||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@radix-ui/react-avatar@1.1.0':
|
||||||
|
resolution: {integrity: sha512-Q/PbuSMk/vyAd/UoIShVGZ7StHHeRFYU7wXmi5GV+8cLXflZAEpHL/F697H1klrzxKXNtZ97vWiC0q3RKUH8UA==}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/react': '*'
|
||||||
|
'@types/react-dom': '*'
|
||||||
|
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
'@types/react-dom':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@radix-ui/react-checkbox@1.1.1':
|
'@radix-ui/react-checkbox@1.1.1':
|
||||||
resolution: {integrity: sha512-0i/EKJ222Afa1FE0C6pNJxDq1itzcl3HChE9DwskA4th4KRse8ojx8a1nVcOjwJdbpDLcz7uol77yYnQNMHdKw==}
|
resolution: {integrity: sha512-0i/EKJ222Afa1FE0C6pNJxDq1itzcl3HChE9DwskA4th4KRse8ojx8a1nVcOjwJdbpDLcz7uol77yYnQNMHdKw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
|
@ -1519,6 +1550,19 @@ packages:
|
||||||
'@types/react':
|
'@types/react':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@radix-ui/react-dialog@1.1.1':
|
||||||
|
resolution: {integrity: sha512-zysS+iU4YP3STKNS6USvFVqI4qqx8EpiwmT5TuCApVEBca+eRCbONi4EgzfNSuVnOXvC5UPHHMjs8RXO6DH9Bg==}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/react': '*'
|
||||||
|
'@types/react-dom': '*'
|
||||||
|
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
'@types/react-dom':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@radix-ui/react-direction@1.1.0':
|
'@radix-ui/react-direction@1.1.0':
|
||||||
resolution: {integrity: sha512-BUuBvgThEiAXh2DWu93XsT+a3aWrGqolGlqqw5VU1kG7p/ZH2cuDlM1sRLNnY3QcBS69UIz2mcKhMxDsdewhjg==}
|
resolution: {integrity: sha512-BUuBvgThEiAXh2DWu93XsT+a3aWrGqolGlqqw5VU1kG7p/ZH2cuDlM1sRLNnY3QcBS69UIz2mcKhMxDsdewhjg==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
|
@ -1663,6 +1707,19 @@ packages:
|
||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@radix-ui/react-radio-group@1.2.0':
|
||||||
|
resolution: {integrity: sha512-yv+oiLaicYMBpqgfpSPw6q+RyXlLdIpQWDHZbUKURxe+nEh53hFXPPlfhfQQtYkS5MMK/5IWIa76SksleQZSzw==}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/react': '*'
|
||||||
|
'@types/react-dom': '*'
|
||||||
|
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
'@types/react-dom':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@radix-ui/react-roving-focus@1.1.0':
|
'@radix-ui/react-roving-focus@1.1.0':
|
||||||
resolution: {integrity: sha512-EA6AMGeq9AEeQDeSH0aZgG198qkfHSbvWTf1HvoDmOB5bBG/qTxjYMWUKMnYiV6J/iP/J8MEFSuB2zRU2n7ODA==}
|
resolution: {integrity: sha512-EA6AMGeq9AEeQDeSH0aZgG198qkfHSbvWTf1HvoDmOB5bBG/qTxjYMWUKMnYiV6J/iP/J8MEFSuB2zRU2n7ODA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
|
@ -1676,6 +1733,32 @@ packages:
|
||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@radix-ui/react-scroll-area@1.1.0':
|
||||||
|
resolution: {integrity: sha512-9ArIZ9HWhsrfqS765h+GZuLoxaRHD/j0ZWOWilsCvYTpYJp8XwCqNG7Dt9Nu/TItKOdgLGkOPCodQvDc+UMwYg==}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/react': '*'
|
||||||
|
'@types/react-dom': '*'
|
||||||
|
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
'@types/react-dom':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@radix-ui/react-select@2.1.1':
|
||||||
|
resolution: {integrity: sha512-8iRDfyLtzxlprOo9IicnzvpsO1wNCkuwzzCM+Z5Rb5tNOpCdMvcc2AkzX0Fz+Tz9v6NJ5B/7EEgyZveo4FBRfQ==}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/react': '*'
|
||||||
|
'@types/react-dom': '*'
|
||||||
|
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
'@types/react-dom':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@radix-ui/react-slot@1.1.0':
|
'@radix-ui/react-slot@1.1.0':
|
||||||
resolution: {integrity: sha512-FUCf5XMfmW4dtYl69pdS4DbxKy8nj4M7SafBgPllysxmdachynNflAdp/gCsnYWNDnge6tI9onzMp5ARYc1KNw==}
|
resolution: {integrity: sha512-FUCf5XMfmW4dtYl69pdS4DbxKy8nj4M7SafBgPllysxmdachynNflAdp/gCsnYWNDnge6tI9onzMp5ARYc1KNw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
|
@ -1748,6 +1831,19 @@ packages:
|
||||||
'@types/react':
|
'@types/react':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@radix-ui/react-visually-hidden@1.1.0':
|
||||||
|
resolution: {integrity: sha512-N8MDZqtgCgG5S3aV60INAB475osJousYpZ4cTJ2cFbMpdHS5Y6loLTH8LPtkj2QN0x93J30HT/M3qJXM0+lyeQ==}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/react': '*'
|
||||||
|
'@types/react-dom': '*'
|
||||||
|
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
'@types/react-dom':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@radix-ui/rect@1.1.0':
|
'@radix-ui/rect@1.1.0':
|
||||||
resolution: {integrity: sha512-A9+lCBZoaMJlVKcRBz2YByCG+Cp2t6nAnMnNba+XiWxnj6r4JUFqfsgwocMBZU9LPtdxC6wB56ySYpc7LQIoJg==}
|
resolution: {integrity: sha512-A9+lCBZoaMJlVKcRBz2YByCG+Cp2t6nAnMnNba+XiWxnj6r4JUFqfsgwocMBZU9LPtdxC6wB56ySYpc7LQIoJg==}
|
||||||
|
|
||||||
|
|
@ -5265,9 +5361,6 @@ packages:
|
||||||
tslib@1.14.1:
|
tslib@1.14.1:
|
||||||
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
|
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
|
||||||
|
|
||||||
tslib@2.6.2:
|
|
||||||
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
|
|
||||||
|
|
||||||
tslib@2.6.3:
|
tslib@2.6.3:
|
||||||
resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==}
|
resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==}
|
||||||
|
|
||||||
|
|
@ -6807,6 +6900,8 @@ snapshots:
|
||||||
|
|
||||||
'@pkgr/core@0.1.1': {}
|
'@pkgr/core@0.1.1': {}
|
||||||
|
|
||||||
|
'@radix-ui/number@1.1.0': {}
|
||||||
|
|
||||||
'@radix-ui/primitive@1.1.0': {}
|
'@radix-ui/primitive@1.1.0': {}
|
||||||
|
|
||||||
'@radix-ui/react-arrow@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
'@radix-ui/react-arrow@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
|
|
@ -6818,6 +6913,18 @@ snapshots:
|
||||||
'@types/react': 18.3.3
|
'@types/react': 18.3.3
|
||||||
'@types/react-dom': 18.3.0
|
'@types/react-dom': 18.3.0
|
||||||
|
|
||||||
|
'@radix-ui/react-avatar@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/react-context': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-callback-ref': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-layout-effect': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
react: 18.3.1
|
||||||
|
react-dom: 18.3.1(react@18.3.1)
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/react': 18.3.3
|
||||||
|
'@types/react-dom': 18.3.0
|
||||||
|
|
||||||
'@radix-ui/react-checkbox@1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
'@radix-ui/react-checkbox@1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@radix-ui/primitive': 1.1.0
|
'@radix-ui/primitive': 1.1.0
|
||||||
|
|
@ -6858,6 +6965,28 @@ snapshots:
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@types/react': 18.3.3
|
'@types/react': 18.3.3
|
||||||
|
|
||||||
|
'@radix-ui/react-dialog@1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/primitive': 1.1.0
|
||||||
|
'@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-context': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-dismissable-layer': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-focus-guards': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-focus-scope': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-id': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-portal': 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-presence': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-slot': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-controllable-state': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
aria-hidden: 1.2.4
|
||||||
|
react: 18.3.1
|
||||||
|
react-dom: 18.3.1(react@18.3.1)
|
||||||
|
react-remove-scroll: 2.5.7(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/react': 18.3.3
|
||||||
|
'@types/react-dom': 18.3.0
|
||||||
|
|
||||||
'@radix-ui/react-direction@1.1.0(@types/react@18.3.3)(react@18.3.1)':
|
'@radix-ui/react-direction@1.1.0(@types/react@18.3.3)(react@18.3.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 18.3.1
|
react: 18.3.1
|
||||||
|
|
@ -6998,6 +7127,24 @@ snapshots:
|
||||||
'@types/react': 18.3.3
|
'@types/react': 18.3.3
|
||||||
'@types/react-dom': 18.3.0
|
'@types/react-dom': 18.3.0
|
||||||
|
|
||||||
|
'@radix-ui/react-radio-group@1.2.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/primitive': 1.1.0
|
||||||
|
'@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-context': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-direction': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-presence': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-roving-focus': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-controllable-state': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-previous': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-size': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
react: 18.3.1
|
||||||
|
react-dom: 18.3.1(react@18.3.1)
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/react': 18.3.3
|
||||||
|
'@types/react-dom': 18.3.0
|
||||||
|
|
||||||
'@radix-ui/react-roving-focus@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
'@radix-ui/react-roving-focus@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@radix-ui/primitive': 1.1.0
|
'@radix-ui/primitive': 1.1.0
|
||||||
|
|
@ -7015,6 +7162,52 @@ snapshots:
|
||||||
'@types/react': 18.3.3
|
'@types/react': 18.3.3
|
||||||
'@types/react-dom': 18.3.0
|
'@types/react-dom': 18.3.0
|
||||||
|
|
||||||
|
'@radix-ui/react-scroll-area@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/number': 1.1.0
|
||||||
|
'@radix-ui/primitive': 1.1.0
|
||||||
|
'@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-context': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-direction': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-presence': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-callback-ref': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-layout-effect': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
react: 18.3.1
|
||||||
|
react-dom: 18.3.1(react@18.3.1)
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/react': 18.3.3
|
||||||
|
'@types/react-dom': 18.3.0
|
||||||
|
|
||||||
|
'@radix-ui/react-select@2.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/number': 1.1.0
|
||||||
|
'@radix-ui/primitive': 1.1.0
|
||||||
|
'@radix-ui/react-collection': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-context': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-direction': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-dismissable-layer': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-focus-guards': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-focus-scope': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-id': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-popper': 1.2.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-portal': 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
'@radix-ui/react-slot': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-callback-ref': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-controllable-state': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-layout-effect': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-use-previous': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
'@radix-ui/react-visually-hidden': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
aria-hidden: 1.2.4
|
||||||
|
react: 18.3.1
|
||||||
|
react-dom: 18.3.1(react@18.3.1)
|
||||||
|
react-remove-scroll: 2.5.7(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/react': 18.3.3
|
||||||
|
'@types/react-dom': 18.3.0
|
||||||
|
|
||||||
'@radix-ui/react-slot@1.1.0(@types/react@18.3.3)(react@18.3.1)':
|
'@radix-ui/react-slot@1.1.0(@types/react@18.3.3)(react@18.3.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
'@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||||
|
|
@ -7068,6 +7261,15 @@ snapshots:
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@types/react': 18.3.3
|
'@types/react': 18.3.3
|
||||||
|
|
||||||
|
'@radix-ui/react-visually-hidden@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
react: 18.3.1
|
||||||
|
react-dom: 18.3.1(react@18.3.1)
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/react': 18.3.3
|
||||||
|
'@types/react-dom': 18.3.0
|
||||||
|
|
||||||
'@radix-ui/rect@1.1.0': {}
|
'@radix-ui/rect@1.1.0': {}
|
||||||
|
|
||||||
'@rollup/rollup-android-arm-eabi@4.18.0':
|
'@rollup/rollup-android-arm-eabi@4.18.0':
|
||||||
|
|
@ -10921,7 +11123,7 @@ snapshots:
|
||||||
|
|
||||||
rxjs@7.8.1:
|
rxjs@7.8.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.6.2
|
tslib: 2.6.3
|
||||||
|
|
||||||
safe-array-concat@1.1.2:
|
safe-array-concat@1.1.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
@ -11222,7 +11424,7 @@ snapshots:
|
||||||
synckit@0.9.0:
|
synckit@0.9.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@pkgr/core': 0.1.1
|
'@pkgr/core': 0.1.1
|
||||||
tslib: 2.6.2
|
tslib: 2.6.3
|
||||||
|
|
||||||
tabbable@6.2.0: {}
|
tabbable@6.2.0: {}
|
||||||
|
|
||||||
|
|
@ -11374,8 +11576,6 @@ snapshots:
|
||||||
|
|
||||||
tslib@1.14.1: {}
|
tslib@1.14.1: {}
|
||||||
|
|
||||||
tslib@2.6.2: {}
|
|
||||||
|
|
||||||
tslib@2.6.3: {}
|
tslib@2.6.3: {}
|
||||||
|
|
||||||
tsutils@3.21.0(typescript@5.4.5):
|
tsutils@3.21.0(typescript@5.4.5):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user