Pull Request branch dev-clone to main #1
|
|
@ -47,6 +47,15 @@ const permissionsData = [
|
|||
{
|
||||
code: "questions.restore",
|
||||
},
|
||||
{
|
||||
code :"assessmentRequestManagement.readAll",
|
||||
},
|
||||
{
|
||||
code: "assessmentRequestManagement.update",
|
||||
},
|
||||
{
|
||||
code :"assessmentRequestManagement.read",
|
||||
},
|
||||
{
|
||||
code: "managementAspect.readAll",
|
||||
},
|
||||
|
|
@ -104,6 +113,18 @@ const permissionsData = [
|
|||
{
|
||||
code: "assessments.updateAnswer",
|
||||
},
|
||||
{
|
||||
code: "assessments.readAverageSubAspect",
|
||||
},
|
||||
{
|
||||
code: "assessments.readAverageAllSubAspects",
|
||||
},
|
||||
{
|
||||
code: "assessments.readAverageAspect",
|
||||
},
|
||||
{
|
||||
code: "assessments.readAverageAllAspects",
|
||||
},
|
||||
] as const;
|
||||
|
||||
export type SpecificPermissionCode = (typeof permissionsData)[number]["code"];
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const sidebarMenus: SidebarMenu[] = [
|
|||
link: "/dashboard",
|
||||
},
|
||||
{
|
||||
label: "Users",
|
||||
label: "Manajemen Pengguna",
|
||||
icon: { tb: "TbUsers" },
|
||||
allowedPermissions: ["permissions.read"],
|
||||
link: "/users",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { relations } from "drizzle-orm";
|
|||
import { respondents } from "./respondents";
|
||||
import { users } from "./users";
|
||||
|
||||
const statusEnum = pgEnum("status", ["menunggu konfirmasi", "disetujui", "ditolak", "selesai"]);
|
||||
const statusEnum = pgEnum("status", ["menunggu konfirmasi", "diterima", "ditolak", "selesai"]);
|
||||
|
||||
export const assessments = pgTable("assessments", {
|
||||
id: varchar("id", { length: 50 })
|
||||
|
|
@ -17,6 +17,8 @@ export const assessments = pgTable("assessments", {
|
|||
validatedBy: varchar("validatedBy"),
|
||||
validatedAt: timestamp("validatedAt", { mode: "date" }),
|
||||
createdAt: timestamp("createdAt", { mode: "date" }).defaultNow(),
|
||||
|
||||
|
||||
});
|
||||
// Query Tools in PosgreSQL
|
||||
// CREATE TYPE status AS ENUM ('menunggu konfirmasi', 'disetujui', 'ditolak', 'selesai');
|
||||
// CREATE TYPE status AS ENUM ('menunggu konfirmasi', 'diterima', 'ditolak', 'selesai');
|
||||
|
|
@ -15,7 +15,7 @@ export const respondents = pgTable("respondents", {
|
|||
phoneNumber: varchar("phoneNumber", { length: 13 }).notNull(),
|
||||
createdAt: timestamp("createdAt", { mode: "date" }).defaultNow(),
|
||||
updatedAt: timestamp("updatedAt", { mode: "date" }).defaultNow(),
|
||||
deletedAt: timestamp("deletetAt", { mode: "date" }),
|
||||
deletedAt: timestamp("deletedAt", { mode: "date" }),
|
||||
});
|
||||
|
||||
export const respondentsRelations = relations(respondents, ({ one }) => ({
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import assessmentResultRoute from "./routes/assessmentResult/route";
|
|||
import assessmentRequestRoute from "./routes/assessmentRequest/route";
|
||||
import forgotPasswordRoutes from "./routes/forgotPassword/route";
|
||||
import assessmentsRoute from "./routes/assessments/route";
|
||||
import assessmentsRequestManagementRoutes from "./routes/assessmentRequestManagement/route";
|
||||
|
||||
configDotenv();
|
||||
|
||||
|
|
@ -92,11 +93,13 @@ const routes = app
|
|||
.route("/assessmentRequest", assessmentRequestRoute)
|
||||
.route("/forgot-password", forgotPasswordRoutes)
|
||||
.route("/assessments", assessmentsRoute)
|
||||
.route("/assessmentRequestManagement",assessmentsRequestManagementRoutes)
|
||||
.onError((err, c) => {
|
||||
if (err instanceof DashboardError) {
|
||||
return c.json(
|
||||
{
|
||||
message: err.message,
|
||||
|
||||
errorCode: err.errorCode,
|
||||
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(
|
||||
'/average-score/sub-aspects/:subAspectId/assessments/:assessmentId',
|
||||
// checkPermission("assessments.readAssessmentScore"),
|
||||
checkPermission("assessments.readAverageSubAspect"),
|
||||
async (c) => {
|
||||
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(
|
||||
'/average-score/sub-aspects/assessments/:assessmentId',
|
||||
// checkPermission("assessments.readAssessmentScore"),
|
||||
checkPermission("assessments.readAverageAllSubAspects"),
|
||||
async (c) => {
|
||||
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(
|
||||
"/average-score/aspects/:aspectId/assessments/:assessmentId",
|
||||
checkPermission("assessments.readAverageAspect"),
|
||||
async (c) => {
|
||||
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(
|
||||
'/average-score/aspects/assessments/:assessmentId',
|
||||
// checkPermission("assessments.readAssessmentScore"),
|
||||
checkPermission("assessments.readAverageAllAspects"),
|
||||
async (c) => {
|
||||
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 { questions } from "../../drizzle/schema/questions";
|
||||
import { z } from "zod";
|
||||
import db from "../../drizzle";
|
||||
import { aspects } from "../../drizzle/schema/aspects";
|
||||
|
|
@ -33,14 +33,16 @@ export const aspectFormSchema = z.object({
|
|||
.optional(),
|
||||
});
|
||||
|
||||
export const aspectUpdateSchema = aspectFormSchema.extend({
|
||||
subAspects: z.string().optional().or(z.literal("")),
|
||||
});
|
||||
|
||||
// Schema for creating and updating subAspects
|
||||
export const subAspectFormSchema = z.object({
|
||||
id: z.string(),
|
||||
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({});
|
||||
|
|
@ -79,17 +81,12 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
const { includeTrashed, page, limit, q } = c.req.valid("query");
|
||||
|
||||
const totalCountQuery = includeTrashed
|
||||
? sql<number>`(SELECT count(*) FROM ${aspects})`
|
||||
: sql<number>`(SELECT count(*) FROM ${aspects} WHERE ${aspects.deletedAt} IS NULL)`;
|
||||
? sql<number>`(SELECT count(DISTINCT ${aspects.id}) FROM ${aspects})`
|
||||
: sql<number>`(SELECT count(DISTINCT ${aspects.id}) FROM ${aspects} WHERE ${aspects.deletedAt} IS NULL)`;
|
||||
|
||||
const result = await db
|
||||
const aspectIdsQuery = await db
|
||||
.select({
|
||||
id: aspects.id,
|
||||
name: aspects.name,
|
||||
createdAt: aspects.createdAt,
|
||||
updatedAt: aspects.updatedAt,
|
||||
...(includeTrashed ? { deletedAt: aspects.deletedAt } : {}),
|
||||
fullCount: totalCountQuery,
|
||||
})
|
||||
.from(aspects)
|
||||
.where(
|
||||
|
|
@ -101,8 +98,82 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
.offset(page * limit)
|
||||
.limit(limit);
|
||||
|
||||
const aspectIds = aspectIdsQuery.map(a => a.id);
|
||||
|
||||
if (aspectIds.length === 0) {
|
||||
return c.json({
|
||||
data: result.map((d) => ({ ...d, fullCount: undefined })),
|
||||
data: [],
|
||||
_metadata: {
|
||||
currentPage: page,
|
||||
totalPages: 0,
|
||||
totalItems: 0,
|
||||
perPage: limit,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Main query to get aspects, sub-aspects, and number of questions
|
||||
const result = await db
|
||||
.select({
|
||||
id: aspects.id,
|
||||
name: aspects.name,
|
||||
createdAt: aspects.createdAt,
|
||||
updatedAt: aspects.updatedAt,
|
||||
...(includeTrashed ? { deletedAt: aspects.deletedAt } : {}),
|
||||
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)
|
||||
.leftJoin(subAspects, eq(subAspects.aspectId, aspects.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),
|
||||
|
|
@ -143,27 +214,33 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
subAspect: {
|
||||
name: subAspects.name,
|
||||
id: subAspects.id,
|
||||
questionCount: sql`COUNT(${questions.id})`.as("questionCount"),
|
||||
},
|
||||
})
|
||||
.from(aspects)
|
||||
.leftJoin(subAspects, eq(aspects.id, subAspects.aspectId))
|
||||
.where(and(eq(aspects.id, aspectId), !includeTrashed ? isNull(aspects.deletedAt) : undefined));
|
||||
.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);
|
||||
|
||||
if (!queryResult.length)
|
||||
throw forbidden({
|
||||
throw notFound({
|
||||
message: "The aspect does not exist",
|
||||
});
|
||||
|
||||
const subAspectsList = queryResult.reduce((prev, curr) => {
|
||||
if (!curr.subAspect) return prev;
|
||||
prev.set(curr.subAspect.id, curr.subAspect.name);
|
||||
prev.set(curr.subAspect.id, {
|
||||
name: curr.subAspect.name,
|
||||
questionCount: Number(curr.subAspect.questionCount),
|
||||
});
|
||||
return prev;
|
||||
}, new Map<string, string>()); // Map<id, name>
|
||||
}, new Map<string, { name: string; questionCount: number }>());
|
||||
|
||||
const aspectData = {
|
||||
...queryResult[0],
|
||||
subAspect: undefined,
|
||||
subAspects: Array.from(subAspectsList, ([id, name]) => ({ id, name })),
|
||||
subAspects: Array.from(subAspectsList, ([id, { name, questionCount }]) => ({ id, name, questionCount })),
|
||||
};
|
||||
|
||||
return c.json(aspectData);
|
||||
|
|
@ -177,18 +254,26 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
async (c) => {
|
||||
const aspectData = c.req.valid("json");
|
||||
|
||||
// Validation to check if the aspect name already exists
|
||||
// Check if aspect name already exists and is not deleted
|
||||
const existingAspect = await db
|
||||
.select()
|
||||
.from(aspects)
|
||||
.where(eq(aspects.name, aspectData.name));
|
||||
.where(
|
||||
and(
|
||||
eq(aspects.name, aspectData.name),
|
||||
isNull(aspects.deletedAt)
|
||||
)
|
||||
);
|
||||
|
||||
if (existingAspect.length > 0) {
|
||||
throw forbidden({
|
||||
message: "Aspect name already exists",
|
||||
});
|
||||
// Return an error if the 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
|
||||
.insert(aspects)
|
||||
.values({
|
||||
|
|
@ -196,14 +281,17 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
})
|
||||
.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) {
|
||||
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) {
|
||||
await db.insert(subAspects).values(
|
||||
subAspectsArray.map((subAspect) => ({
|
||||
aspectId: aspect[0].id,
|
||||
aspectId,
|
||||
name: subAspect,
|
||||
}))
|
||||
);
|
||||
|
|
@ -212,7 +300,7 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
|
||||
return c.json(
|
||||
{
|
||||
message: "Aspect created successfully",
|
||||
message: "Aspect and sub aspects created successfully",
|
||||
},
|
||||
201
|
||||
);
|
||||
|
|
@ -228,7 +316,7 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
const aspectId = c.req.param("id");
|
||||
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
|
||||
.select()
|
||||
.from(aspects)
|
||||
|
|
@ -241,11 +329,12 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
);
|
||||
|
||||
if (existingAspect.length > 0) {
|
||||
throw forbidden({
|
||||
throw notFound({
|
||||
message: "Aspect name already exists",
|
||||
});
|
||||
}
|
||||
|
||||
// Check if the aspect in question exists
|
||||
const aspect = await db
|
||||
.select()
|
||||
.from(aspects)
|
||||
|
|
@ -253,32 +342,76 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
|
||||
if (!aspect[0]) throw notFound();
|
||||
|
||||
// Update aspect name
|
||||
await db
|
||||
.update(aspects)
|
||||
.set({
|
||||
...aspectData,
|
||||
name: aspectData.name,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(aspects.id, aspectId));
|
||||
|
||||
//Update for Sub-Aspects
|
||||
// if (aspectData.subAspects) {
|
||||
// const subAspectsArray = JSON.parse(aspectData.subAspects) as string[];
|
||||
// Get new sub aspect data from request
|
||||
const newSubAspects = aspectData.subAspects || [];
|
||||
|
||||
// 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) {
|
||||
// await db.insert(subAspects).values(
|
||||
// subAspectsArray.map((subAspect) => ({
|
||||
// aspectId: aspectId,
|
||||
// name: subAspect,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
const currentSubAspectMap = new Map(currentSubAspects.map(sub => [sub.id, sub.name]));
|
||||
|
||||
// Sub aspects to be removed
|
||||
const subAspectsToDelete = currentSubAspects
|
||||
.filter(sub => !newSubAspects.some(newSub => newSub.id === sub.id))
|
||||
.map(sub => sub.id);
|
||||
|
||||
// Delete sub aspects that do not exist in the new data
|
||||
if (subAspectsToDelete.length) {
|
||||
await db
|
||||
.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({
|
||||
name: subAspect.name,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(
|
||||
and(
|
||||
eq(subAspects.id, subAspect.id),
|
||||
eq(subAspects.aspectId, aspectId)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Add if new sub aspect
|
||||
await db
|
||||
.insert(subAspects)
|
||||
.values({
|
||||
id: subAspect.id,
|
||||
aspectId,
|
||||
name: subAspect.name,
|
||||
createdAt: new Date(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return c.json({
|
||||
message: "Aspect updated successfully",
|
||||
message: "Aspect and sub aspects updated successfully",
|
||||
});
|
||||
}
|
||||
)
|
||||
|
|
@ -287,17 +420,10 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
.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";
|
||||
|
||||
// Check if aspect exists before deleting
|
||||
const aspect = await db
|
||||
.select()
|
||||
.from(aspects)
|
||||
|
|
@ -308,6 +434,7 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
message: "The aspect is not found",
|
||||
});
|
||||
|
||||
// Update deletedAt column on aspect (soft delete)
|
||||
await db
|
||||
.update(aspects)
|
||||
.set({
|
||||
|
|
@ -315,8 +442,16 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
})
|
||||
.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 deleted successfully",
|
||||
message: "Aspect and sub aspects soft deleted successfully",
|
||||
});
|
||||
}
|
||||
)
|
||||
|
|
@ -328,165 +463,32 @@ const managementAspectRoute = new Hono<HonoEnv>()
|
|||
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();
|
||||
if (!aspect) {
|
||||
throw notFound({
|
||||
message: "The aspect is not found",
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure the aspect has been deleted (there is deletedAt)
|
||||
if (!aspect.deletedAt) {
|
||||
throw forbidden({
|
||||
throw notFound({
|
||||
message: "The aspect is not deleted",
|
||||
});
|
||||
}
|
||||
|
||||
// Restore aspects (remove deletedAt mark)
|
||||
await db.update(aspects).set({ deletedAt: null }).where(eq(aspects.id, aspectId));
|
||||
|
||||
// Restore all related sub aspects that have also been deleted (if any)
|
||||
await db.update(subAspects).set({ deletedAt: null }).where(eq(subAspects.aspectId, aspectId));
|
||||
|
||||
return c.json({
|
||||
message: "Aspect restored successfully",
|
||||
message: "Aspect and sub aspects restored successfully",
|
||||
});
|
||||
}
|
||||
)
|
||||
|
||||
// Get sub aspects by aspect ID
|
||||
.get(
|
||||
"/subAspects/:aspectId",
|
||||
checkPermission("managementAspect.readAll"),
|
||||
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
|
||||
.post(
|
||||
"/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
|
||||
const existingSubAspect = await db
|
||||
.select()
|
||||
.from(subAspects)
|
||||
.where(
|
||||
and(
|
||||
eq(subAspects.name, subAspectData.name),
|
||||
eq(subAspects.aspectId, subAspectData.aspectId)));
|
||||
|
||||
if (existingSubAspect.length > 0) {
|
||||
throw forbidden({ message: "Nama Sub Aspek sudah tersedia!" });
|
||||
}
|
||||
|
||||
const [aspect] = await db
|
||||
.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 { z } from "zod";
|
||||
|
|
@ -12,30 +12,21 @@ import HonoEnv from "../../types/HonoEnv";
|
|||
import requestValidator from "../../utils/requestValidator";
|
||||
import authInfo from "../../middlewares/authInfo";
|
||||
import checkPermission from "../../middlewares/checkPermission";
|
||||
import { respondents } from "../../drizzle/schema/respondents";
|
||||
import { forbidden, notFound } from "../../errors/DashboardError";
|
||||
|
||||
export const userFormSchema = z.object({
|
||||
name: z.string().min(1).max(255),
|
||||
username: z.string().min(1).max(255),
|
||||
email: z.string().email().optional().or(z.literal("")),
|
||||
password: z.string().min(6),
|
||||
name: z.string().min(1, "Name is required").max(255),
|
||||
username: z.string().min(1, "Username is required").max(255),
|
||||
email: z.string().min(1, "Email is required").email().optional().or(z.literal("")),
|
||||
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"),
|
||||
roles: z
|
||||
.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(),
|
||||
roles: z.array(z.string().min(1, "Role is required")),
|
||||
});
|
||||
|
||||
export const userUpdateSchema = userFormSchema.extend({
|
||||
|
|
@ -51,6 +42,8 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
* - includeTrashed: boolean (default: false)\
|
||||
* - withMetadata: boolean
|
||||
*/
|
||||
|
||||
// Get all users with search
|
||||
.get(
|
||||
"/",
|
||||
checkPermission("users.readAll"),
|
||||
|
|
@ -66,17 +59,69 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
.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(1),
|
||||
q: z.string().default(""),
|
||||
limit: z.coerce.number().int().min(1).max(1000).default(10),
|
||||
q: z.string().default(""), // Keyword search
|
||||
})
|
||||
),
|
||||
async (c) => {
|
||||
const { includeTrashed, page, limit, q } = c.req.valid("query");
|
||||
|
||||
const totalCountQuery = includeTrashed
|
||||
? sql<number>`(SELECT count(*) FROM ${users})`
|
||||
: sql<number>`(SELECT count(*) FROM ${users} WHERE ${users.deletedAt} IS NULL)`;
|
||||
// Query to count total data without duplicates
|
||||
const totalCountQuery = db
|
||||
.select({
|
||||
count: sql<number>`count(distinct ${users.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(
|
||||
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}%`), // Search by email
|
||||
ilike(respondents.companyName, `%${q}%`), // Search by companyName (from respondents)
|
||||
ilike(rolesSchema.name, `%${q}%`) // Search by role name (from rolesSchema)
|
||||
)
|
||||
: undefined
|
||||
)
|
||||
);
|
||||
|
||||
// Get the total count result from the query
|
||||
const totalCountResult = await totalCountQuery;
|
||||
const totalCount = totalCountResult[0]?.count || 0;
|
||||
|
||||
// Query to get unique user IDs based on pagination (Sub Query)
|
||||
const userIdsQuery = db
|
||||
.select({
|
||||
id: users.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(
|
||||
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,
|
||||
|
|
@ -87,38 +132,78 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
createdAt: users.createdAt,
|
||||
updatedAt: users.updatedAt,
|
||||
...(includeTrashed ? { deletedAt: users.deletedAt } : {}),
|
||||
fullCount: totalCountQuery,
|
||||
company: respondents.companyName,
|
||||
role: {
|
||||
name: rolesSchema.name,
|
||||
id: rolesSchema.id,
|
||||
},
|
||||
})
|
||||
.from(users)
|
||||
.where(
|
||||
and(
|
||||
includeTrashed ? undefined : isNull(users.deletedAt),
|
||||
q
|
||||
? or(
|
||||
ilike(users.name, q),
|
||||
ilike(users.username, q),
|
||||
ilike(users.email, q),
|
||||
eq(users.id, q)
|
||||
)
|
||||
: undefined
|
||||
)
|
||||
)
|
||||
.offset(page * limit)
|
||||
.limit(limit);
|
||||
.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: result.map((d) => ({ ...d, fullCount: undefined })),
|
||||
data: groupedData,
|
||||
_metadata: {
|
||||
currentPage: page,
|
||||
totalPages: Math.ceil(
|
||||
(Number(result[0]?.fullCount) ?? 0) / limit
|
||||
),
|
||||
totalItems: Number(result[0]?.fullCount) ?? 0,
|
||||
totalPages: Math.ceil(totalCount / limit),
|
||||
totalItems: totalCount,
|
||||
perPage: limit,
|
||||
},
|
||||
});
|
||||
}
|
||||
)
|
||||
|
||||
//get user by id
|
||||
.get(
|
||||
"/:id",
|
||||
|
|
@ -139,7 +224,12 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
.select({
|
||||
id: users.id,
|
||||
name: users.name,
|
||||
position: respondents.position,
|
||||
workExperience: respondents.workExperience,
|
||||
email: users.email,
|
||||
companyName: respondents.companyName,
|
||||
address: respondents.address,
|
||||
phoneNumber: respondents.phoneNumber,
|
||||
username: users.username,
|
||||
isEnabled: users.isEnabled,
|
||||
createdAt: users.createdAt,
|
||||
|
|
@ -151,6 +241,7 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
},
|
||||
})
|
||||
.from(users)
|
||||
.leftJoin(respondents, eq(users.id, respondents.userId))
|
||||
.leftJoin(rolesToUsers, eq(users.id, rolesToUsers.userId))
|
||||
.leftJoin(rolesSchema, eq(rolesToUsers.roleId, rolesSchema.id))
|
||||
.where(
|
||||
|
|
@ -161,9 +252,9 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
);
|
||||
|
||||
if (!queryResult.length)
|
||||
throw new HTTPException(404, {
|
||||
throw notFound({
|
||||
message : "The user does not exists",
|
||||
});
|
||||
})
|
||||
|
||||
const roles = queryResult.reduce((prev, curr) => {
|
||||
if (!curr.role) return prev;
|
||||
|
|
@ -180,38 +271,121 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
return c.json(userData);
|
||||
}
|
||||
)
|
||||
|
||||
//create user
|
||||
.post(
|
||||
"/",
|
||||
checkPermission("users.create"),
|
||||
requestValidator("form", userFormSchema),
|
||||
requestValidator("json", userFormSchema),
|
||||
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
|
||||
const conditions = [];
|
||||
if (userData.email) {
|
||||
conditions.push(eq(users.email, userData.email));
|
||||
}
|
||||
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: await hashPassword(userData.password),
|
||||
isEnabled: userData.isEnabled.toLowerCase() === "true",
|
||||
password: hashedPassword,
|
||||
isEnabled: userData.isEnabled?.toLowerCase() === "true" || true,
|
||||
})
|
||||
.returning();
|
||||
.returning()
|
||||
.catch(() => {
|
||||
throw forbidden({
|
||||
message: "Error creating user",
|
||||
})
|
||||
});
|
||||
|
||||
if (userData.roles) {
|
||||
const roles = JSON.parse(userData.roles) as string[];
|
||||
console.log(roles);
|
||||
// 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,
|
||||
});
|
||||
});
|
||||
|
||||
if (roles.length) {
|
||||
await db.insert(rolesToUsers).values(
|
||||
roles.map((role) => ({
|
||||
userId: user[0].id,
|
||||
roleId: role,
|
||||
}))
|
||||
);
|
||||
// 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(
|
||||
{
|
||||
|
|
@ -226,10 +400,32 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
.patch(
|
||||
"/:id",
|
||||
checkPermission("users.update"),
|
||||
requestValidator("form", userUpdateSchema),
|
||||
requestValidator("json", userUpdateSchema),
|
||||
async (c) => {
|
||||
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
|
||||
.select()
|
||||
|
|
@ -238,7 +434,10 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
|
||||
if (!user[0]) return c.notFound();
|
||||
|
||||
await db
|
||||
// Start transaction to update both user and respondent
|
||||
await db.transaction(async (trx) => {
|
||||
// Update user
|
||||
await trx
|
||||
.update(users)
|
||||
.set({
|
||||
...userData,
|
||||
|
|
@ -250,6 +449,56 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
})
|
||||
.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({
|
||||
message: "User updated successfully",
|
||||
});
|
||||
|
|
@ -273,6 +522,7 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
const skipTrash =
|
||||
c.req.valid("form").skipTrash.toLowerCase() === "true";
|
||||
|
||||
// Check if the user exists
|
||||
const user = await db
|
||||
.select()
|
||||
.from(users)
|
||||
|
|
@ -283,17 +533,20 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
)
|
||||
);
|
||||
|
||||
// Throw error if the user does not exist
|
||||
if (!user[0])
|
||||
throw new HTTPException(404, {
|
||||
throw notFound ({
|
||||
message: "The user is not found",
|
||||
});
|
||||
|
||||
// Throw error if the user is trying to delete themselves
|
||||
if (user[0].id === currentUserId) {
|
||||
throw new HTTPException(400, {
|
||||
throw forbidden ({
|
||||
message: "You cannot delete yourself",
|
||||
});
|
||||
}
|
||||
|
||||
// Delete or soft delete user
|
||||
if (skipTrash) {
|
||||
await db.delete(users).where(eq(users.id, userId));
|
||||
} else {
|
||||
|
|
@ -311,21 +564,27 @@ const usersRoute = new Hono<HonoEnv>()
|
|||
)
|
||||
|
||||
//undo delete
|
||||
.patch("/restore/:id", checkPermission("users.restore"), async (c) => {
|
||||
.patch(
|
||||
"/restore/:id",
|
||||
checkPermission("users.restore"),
|
||||
async (c) => {
|
||||
const userId = c.req.param("id");
|
||||
|
||||
// Check if the user exists
|
||||
const user = (
|
||||
await db.select().from(users).where(eq(users.id, userId))
|
||||
)[0];
|
||||
|
||||
if (!user) return c.notFound();
|
||||
|
||||
// Throw error if the user is not deleted
|
||||
if (!user.deletedAt) {
|
||||
throw new HTTPException(400, {
|
||||
throw forbidden({
|
||||
message: "The user is not deleted",
|
||||
});
|
||||
}
|
||||
|
||||
// Restore user
|
||||
await db
|
||||
.update(users)
|
||||
.set({ deletedAt: null })
|
||||
|
|
|
|||
|
|
@ -16,9 +16,14 @@
|
|||
"@mantine/form": "^7.10.2",
|
||||
"@mantine/hooks": "^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-dialog": "^1.1.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
||||
"@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",
|
||||
"@tanstack/react-query": "^5.45.0",
|
||||
"@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 {
|
||||
AppShell,
|
||||
Avatar,
|
||||
Burger,
|
||||
Group,
|
||||
Menu,
|
||||
UnstyledButton,
|
||||
Text,
|
||||
rem,
|
||||
} from "@mantine/core";
|
||||
import logo from "@/assets/logos/logo.png";
|
||||
import logo from "@/assets/logos/amati-logo.png";
|
||||
import cx from "clsx";
|
||||
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 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 { useAuth } from "@/modules/auth/contexts/AuthContext";
|
||||
// import UserMenuItem from "./UserMenuItem";
|
||||
|
|
@ -24,73 +17,73 @@ interface Props {
|
|||
toggle: () => void;
|
||||
}
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
name: string;
|
||||
permissions: string[];
|
||||
photoProfile?: string;
|
||||
}
|
||||
|
||||
// const mockUserData = {
|
||||
// name: "Fulan bin Fulanah",
|
||||
// email: "janspoon@fighter.dev",
|
||||
// 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 { user } = useAuth();
|
||||
const { user }: { user: User | null } = useAuth();
|
||||
|
||||
// const userMenus = getUserMenus().map((item, i) => (
|
||||
// <UserMenuItem item={item} key={i} />
|
||||
// ));
|
||||
|
||||
return (
|
||||
<AppShell.Header>
|
||||
<Group h="100%" px="md" justify="space-between">
|
||||
<Burger
|
||||
opened={props.openNavbar}
|
||||
onClick={props.toggle}
|
||||
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
|
||||
<header className="fixed top-0 left-0 w-full h-16 bg-white z-50 border">
|
||||
<div className="flex h-full justify-between w-full items-center">
|
||||
<Button
|
||||
onClick={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"
|
||||
>
|
||||
<Menu.Target>
|
||||
<UnstyledButton
|
||||
<IoMdMenu />
|
||||
</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, {
|
||||
[classNames.userActive]: userMenuOpened,
|
||||
})}
|
||||
>
|
||||
<Group gap={7}>
|
||||
<Avatar
|
||||
// src={user?.photoProfile}
|
||||
// alt={user?.name}
|
||||
radius="xl"
|
||||
size={30}
|
||||
/>
|
||||
<Text fw={500} size="sm" lh={1} mr={3}>
|
||||
{/* {user?.name} */}
|
||||
{user?.name ?? "Anonymous"}
|
||||
</Text>
|
||||
<TbChevronDown
|
||||
style={{ width: rem(12), height: rem(12) }}
|
||||
strokeWidth={1.5}
|
||||
/>
|
||||
</Group>
|
||||
</UnstyledButton>
|
||||
</Menu.Target>
|
||||
<div className="flex items-center">
|
||||
<Avatar>
|
||||
{user?.photoProfile ? (
|
||||
<AvatarImage src={user.photoProfile} />
|
||||
) : (
|
||||
<AvatarFallback>{user?.name?.charAt(0) ?? "A"}</AvatarFallback>
|
||||
)}
|
||||
</Avatar>
|
||||
</div>
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<Menu.Dropdown>
|
||||
<Menu.Item component={Link} to="/logout">
|
||||
Logout
|
||||
</Menu.Item>
|
||||
|
||||
{/* {userMenus} */}
|
||||
</Menu.Dropdown>
|
||||
</Menu>
|
||||
</Group>
|
||||
</AppShell.Header>
|
||||
<DropdownMenuContent
|
||||
align="end"
|
||||
className="transition-all duration-200 z-50 border bg-white w-64"
|
||||
>
|
||||
<DropdownMenuItem asChild>
|
||||
<Link to="/logout">Logout</Link>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import { AppShell, ScrollArea } from "@mantine/core";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import client from "../honoClient";
|
||||
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 { useAuth } from "@/modules/auth/contexts/AuthContext";
|
||||
|
|
@ -15,30 +18,70 @@ import MenuItem from "./NavbarMenuItem";
|
|||
export default function AppNavbar() {
|
||||
// const {user} = useAuth();
|
||||
|
||||
const { pathname } = useLocation();
|
||||
|
||||
const [isSidebarOpen, setSidebarOpen] = useState(true);
|
||||
const toggleSidebar = () => {
|
||||
setSidebarOpen(!isSidebarOpen);
|
||||
};
|
||||
|
||||
const { data } = useQuery({
|
||||
queryKey: ["sidebarData"],
|
||||
queryFn: async () => {
|
||||
const res = await client.dashboard.getSidebarItems.$get();
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
console.error("Error:", res.status, res.statusText);
|
||||
|
||||
//TODO: Handle error properly
|
||||
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 (
|
||||
<AppShell.Navbar p="md">
|
||||
<ScrollArea style={{ flex: "1" }}>
|
||||
{data?.map((menu, i) => <MenuItem menu={menu} key={i} />)}
|
||||
{/* {user?.sidebarMenus.map((menu, i) => (
|
||||
<MenuItem menu={menu} key={i} />
|
||||
)) ?? null} */}
|
||||
<>
|
||||
<div>
|
||||
{/* Header */}
|
||||
<AppHeader toggle={toggleSidebar} openNavbar={isSidebarOpen} />
|
||||
|
||||
{/* Sidebar */}
|
||||
<div
|
||||
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>
|
||||
</AppShell.Navbar>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
import { Table, Center, ScrollArea } from "@mantine/core";
|
||||
import { Table as ReactTable, flexRender } from "@tanstack/react-table";
|
||||
import { ScrollArea } from "@/shadcn/components/ui/scroll-area";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/shadcn/components/ui/table";
|
||||
import { flexRender, Table as ReactTable } from "@tanstack/react-table";
|
||||
|
||||
interface Props<TData> {
|
||||
table: ReactTable<TData>;
|
||||
|
|
@ -7,22 +15,15 @@ interface Props<TData> {
|
|||
|
||||
export default function DashboardTable<T>({ table }: Props<T>) {
|
||||
return (
|
||||
<ScrollArea.Autosize>
|
||||
<Table
|
||||
verticalSpacing="xs"
|
||||
horizontalSpacing="xs"
|
||||
striped
|
||||
highlightOnHover
|
||||
withColumnBorders
|
||||
withRowBorders
|
||||
>
|
||||
{/* Thead */}
|
||||
<Table.Thead>
|
||||
<div className="w-full max-w-full overflow-x-auto border rounded-lg">
|
||||
<Table className="min-w-full divide-y divide-muted-foreground bg-white">
|
||||
<TableHeader>
|
||||
{table.getHeaderGroups().map((headerGroup) => (
|
||||
<Table.Tr key={headerGroup.id}>
|
||||
<TableRow key={headerGroup.id}>
|
||||
{headerGroup.headers.map((header) => (
|
||||
<Table.Th
|
||||
<TableHead
|
||||
key={header.id}
|
||||
className="px-6 py-3 text-left text-sm font-medium text-muted-foreground"
|
||||
style={{
|
||||
maxWidth: `${header.column.columnDef.maxSize}px`,
|
||||
width: `${header.getSize()}`,
|
||||
|
|
@ -30,45 +31,39 @@ export default function DashboardTable<T>({ table }: Props<T>) {
|
|||
>
|
||||
{header.isPlaceholder
|
||||
? null
|
||||
: flexRender(
|
||||
header.column.columnDef.header,
|
||||
header.getContext()
|
||||
)}
|
||||
</Table.Th>
|
||||
: flexRender(header.column.columnDef.header, header.getContext())}
|
||||
</TableHead>
|
||||
))}
|
||||
</Table.Tr>
|
||||
</TableRow>
|
||||
))}
|
||||
</Table.Thead>
|
||||
</TableHeader>
|
||||
|
||||
{/* Tbody */}
|
||||
<Table.Tbody>
|
||||
<TableBody>
|
||||
{table.getRowModel().rows.length > 0 ? (
|
||||
table.getRowModel().rows.map((row) => (
|
||||
<Table.Tr key={row.id}>
|
||||
<TableRow key={row.id}>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
<Table.Td
|
||||
<TableCell
|
||||
key={cell.id}
|
||||
className="px-6 py-4 whitespace-nowrap text-sm text-black"
|
||||
style={{
|
||||
maxWidth: `${cell.column.columnDef.maxSize}px`,
|
||||
}}
|
||||
>
|
||||
{flexRender(
|
||||
cell.column.columnDef.cell,
|
||||
cell.getContext()
|
||||
)}
|
||||
</Table.Td>
|
||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||
</TableCell>
|
||||
))}
|
||||
</Table.Tr>
|
||||
</TableRow>
|
||||
))
|
||||
) : (
|
||||
<Table.Tr>
|
||||
<Table.Td colSpan={table.getAllColumns().length}>
|
||||
<Center>- No Data -</Center>
|
||||
</Table.Td>
|
||||
</Table.Tr>
|
||||
<TableRow>
|
||||
<TableCell colSpan={table.getAllColumns().length} className="px-6 py-4 text-center text-sm text-gray-500">
|
||||
- No Data -
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</Table.Tbody>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</ScrollArea.Autosize>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import { Text } from "@mantine/core";
|
||||
|
||||
import classNames from "./styles/navbarChildMenu.module.css";
|
||||
import { SidebarMenu } from "backend/types";
|
||||
|
||||
|
|
@ -22,13 +20,10 @@ export default function ChildMenu(props: Props) {
|
|||
: `/${props.item.link}`;
|
||||
|
||||
return (
|
||||
<Text<"a">
|
||||
component="a"
|
||||
className={classNames.link}
|
||||
href={`${linkPath}`}
|
||||
fw={props.active ? "bold" : "normal"}
|
||||
<a href={`${linkPath}`}
|
||||
className={`${props.active ? "font-bold" : "font-normal"} ${classNames.link} text-blue-600 hover:underline`}
|
||||
>
|
||||
{props.item.label}
|
||||
</Text>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,6 @@
|
|||
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 classNames from "./styles/navbarMenuItem.module.css";
|
||||
// import classNames from "./styles/navbarMenuItem.module.css";
|
||||
// import dashboardConfig from "../dashboard.config";
|
||||
// import { usePathname } from "next/navigation";
|
||||
// import areURLsSame from "@/utils/areUrlSame";
|
||||
|
|
@ -19,9 +8,14 @@ import classNames from "./styles/navbarMenuItem.module.css";
|
|||
import { SidebarMenu } from "backend/types";
|
||||
import ChildMenu from "./NavbarChildMenu";
|
||||
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 {
|
||||
menu: SidebarMenu;
|
||||
isActive: boolean;
|
||||
onClick: (link: string) => void;
|
||||
}
|
||||
|
||||
//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.
|
||||
* @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 pathname = usePathname();
|
||||
|
|
@ -50,6 +44,13 @@ export default function MenuItem({ menu }: Props) {
|
|||
setOpened((prev) => !prev);
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
onClick(menu.link ?? "");
|
||||
if (!hasChildren) {
|
||||
toggleOpenMenu();
|
||||
}
|
||||
};
|
||||
|
||||
// Mapping children menu items if available
|
||||
const subItems = (hasChildren ? menu.children! : []).map((child, index) => (
|
||||
<ChildMenu key={index} item={child} active={false} />
|
||||
|
|
@ -69,43 +70,41 @@ export default function MenuItem({ menu }: Props) {
|
|||
return (
|
||||
<>
|
||||
{/* Main Menu Item */}
|
||||
<UnstyledButton<typeof Link | "button">
|
||||
onClick={toggleOpenMenu}
|
||||
className={`${classNames.control} py-2`}
|
||||
to={menu.link}
|
||||
component={menu.link ? Link : "button"}
|
||||
<Button
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
"w-full p-2 rounded-md justify-between focus:outline-none",
|
||||
isActive ? "bg-black text-white" : "text-black"
|
||||
)}
|
||||
onClick={handleClick}
|
||||
asChild
|
||||
>
|
||||
<Group justify="space-between" gap={0}>
|
||||
{/* Icon and Label */}
|
||||
<Box style={{ display: "flex", alignItems: "center" }}>
|
||||
<ThemeIcon variant="light" size={30} color={menu.color}>
|
||||
<Icon style={{ width: rem(18), height: rem(18) }} />
|
||||
</ThemeIcon>
|
||||
|
||||
<Box ml="md" fw={500}>
|
||||
{menu.label}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Chevron Icon for collapsible items */}
|
||||
<Link to={menu.link ?? "#"}>
|
||||
<div className="flex items-center">
|
||||
{/* Icon */}
|
||||
<span className="mr-3">
|
||||
<Icon className="w-4 h-4" />
|
||||
</span>
|
||||
{/* Label */}
|
||||
<span className="text-xs font-bold">{menu.label}</span>
|
||||
</div>
|
||||
{/* Chevron Icon */}
|
||||
{hasChildren && (
|
||||
<TbChevronRight
|
||||
strokeWidth={1.5}
|
||||
style={{
|
||||
width: rem(16),
|
||||
height: rem(16),
|
||||
transform: opened
|
||||
? "rotate(-90deg)"
|
||||
: "rotate(90deg)",
|
||||
}}
|
||||
className={classNames.chevron}
|
||||
<ChevronRightIcon
|
||||
className={`w-4 h-4 transition-transform ${
|
||||
opened ? "rotate-90" : "rotate-0"
|
||||
}`}
|
||||
/>
|
||||
)}
|
||||
</Group>
|
||||
</UnstyledButton>
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
{/* 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 */
|
||||
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 { TbPlus, TbSearch } from "react-icons/tb";
|
||||
import DashboardTable from "./DashboardTable";
|
||||
|
|
@ -25,7 +13,25 @@ import {
|
|||
keepPreviousData,
|
||||
useQuery,
|
||||
} 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>> = {
|
||||
data: Array<T>;
|
||||
|
|
@ -70,24 +76,32 @@ const createCreateButton = (
|
|||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
property: Props<any, any, any>["createButton"] = true
|
||||
) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const addQuery = () => {
|
||||
navigate({ to: `${window.location.pathname}`, search: { create: true } });
|
||||
}
|
||||
|
||||
if (property === true) {
|
||||
return (
|
||||
<Button
|
||||
leftSection={<TbPlus />}
|
||||
component={Link}
|
||||
search={{ create: true }}
|
||||
className="gap-2"
|
||||
variant={"outline"}
|
||||
onClick={addQuery}
|
||||
>
|
||||
Create New
|
||||
Tambah Data
|
||||
<TbPlus />
|
||||
</Button>
|
||||
);
|
||||
} else if (typeof property === "string") {
|
||||
return (
|
||||
<Button
|
||||
leftSection={<TbPlus />}
|
||||
component={Link}
|
||||
search={{ create: true }}
|
||||
className="gap-2"
|
||||
variant={"outline"}
|
||||
onClick={addQuery}
|
||||
>
|
||||
{property}
|
||||
<TbPlus />
|
||||
</Button>
|
||||
);
|
||||
} 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.
|
||||
|
||||
|
|
@ -113,14 +230,14 @@ export default function PageTemplate<
|
|||
q: "",
|
||||
});
|
||||
|
||||
// const [deboucedSearchQuery] = useDebouncedValue(filterOptions.q, 500);
|
||||
const [debouncedSearchQuery] = useDebouncedValue(filterOptions.q, 500);
|
||||
|
||||
const query = useQuery({
|
||||
...(typeof props.queryOptions === "function"
|
||||
? props.queryOptions(
|
||||
filterOptions.page,
|
||||
filterOptions.limit,
|
||||
filterOptions.q
|
||||
debouncedSearchQuery
|
||||
)
|
||||
: props.queryOptions),
|
||||
placeholderData: keepPreviousData,
|
||||
|
|
@ -131,7 +248,11 @@ export default function PageTemplate<
|
|||
columns: props.columnDefs,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
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.
|
||||
*/
|
||||
const handleSearchQueryChange = useDebouncedCallback((value: string) => {
|
||||
const handleSearchQueryChange = (value: string) => {
|
||||
setFilterOptions((prev) => ({
|
||||
page: 0,
|
||||
limit: prev.limit,
|
||||
q: value,
|
||||
}));
|
||||
}, 500);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles the change in page number.
|
||||
|
|
@ -155,75 +276,85 @@ export default function PageTemplate<
|
|||
*/
|
||||
const handlePageChange = (page: number) => {
|
||||
setFilterOptions((prev) => ({
|
||||
page: page - 1,
|
||||
page: page - 1, // Adjust for zero-based index
|
||||
limit: prev.limit,
|
||||
q: prev.q,
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
<Title order={1}>{props.title}</Title>
|
||||
<Card>
|
||||
{/* Top Section */}
|
||||
<Flex justify="flex-end">
|
||||
{createCreateButton(props.createButton)}
|
||||
</Flex>
|
||||
|
||||
<div className="flex flex-col space-y-4">
|
||||
<p className="text-2xl font-bold">{props.title}</p>
|
||||
<Card className="p-4 border-hidden">
|
||||
{/* Table Functionality */}
|
||||
<div className="flex flex-col">
|
||||
{/* Search */}
|
||||
<div className="flex pb-4">
|
||||
<TextInput
|
||||
leftSection={<TbSearch />}
|
||||
{/* Search and Create Button */}
|
||||
<div className="flex flex-col md:flex-row lg:flex-row pb-4 justify-between gap-4">
|
||||
<div className="relative w-full">
|
||||
<TbSearch className="absolute top-1/2 left-3 transform -translate-y-1/2 text-muted-foreground pointer-events-none" />
|
||||
<Input
|
||||
id="search"
|
||||
name="search"
|
||||
className="w-full max-w-xs pl-10"
|
||||
value={filterOptions.q}
|
||||
onChange={(e) =>
|
||||
handleSearchQueryChange(e.target.value)
|
||||
}
|
||||
placeholder="Search..."
|
||||
onChange={(e) => handleSearchQueryChange(e.target.value)}
|
||||
placeholder="Pencarian..."
|
||||
/>
|
||||
</div>
|
||||
<div className="flex">
|
||||
{createCreateButton(props.createButton)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Table */}
|
||||
<DashboardTable table={table} />
|
||||
|
||||
{/* Pagination */}
|
||||
{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">
|
||||
<div className="flex flex-row lg:flex-col items-center w-fit gap-2">
|
||||
<span className="block text-sm font-medium text-muted-foreground whitespace-nowrap">Per Halaman</span>
|
||||
<Select
|
||||
label="Per Page"
|
||||
data={["5", "10", "50", "100", "500", "1000"]}
|
||||
allowDeselect={false}
|
||||
defaultValue="10"
|
||||
searchValue={filterOptions.limit.toString()}
|
||||
onChange={(value) =>
|
||||
onValueChange={(value) =>
|
||||
setFilterOptions((prev) => ({
|
||||
page: prev.page,
|
||||
limit: parseInt(value ?? "10"),
|
||||
q: prev.q,
|
||||
}))
|
||||
}
|
||||
checkIconPosition="right"
|
||||
className="w-20"
|
||||
/>
|
||||
<Pagination
|
||||
value={filterOptions.page + 1}
|
||||
total={query.data._metadata.totalPages}
|
||||
defaultValue="10"
|
||||
>
|
||||
<SelectTrigger className="w-fit p-4 gap-4">
|
||||
<SelectValue placeholder="Per Page" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="5">5</SelectItem>
|
||||
<SelectItem value="10">10</SelectItem>
|
||||
<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}
|
||||
/>
|
||||
<Text c="dimmed" size="sm">
|
||||
Showing {query.data.data.length} of{" "}
|
||||
{query.data._metadata.totalItems}
|
||||
</Text>
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-sm text-muted-foreground whitespace-nowrap">
|
||||
Menampilkan {query.data.data.length} dari {query.data._metadata.totalItems}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* The Modals */}
|
||||
{props.modals?.map((modal, index) => (
|
||||
<React.Fragment key={index}>{modal}</React.Fragment>
|
||||
))}
|
||||
</Card>
|
||||
</Stack>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,5 +69,5 @@
|
|||
}
|
||||
|
||||
:root {
|
||||
--primary-color: #2555FF;
|
||||
--primary-color: #2555FF
|
||||
}
|
||||
|
|
@ -63,14 +63,14 @@ export default function UserDeleteModal() {
|
|||
<Modal
|
||||
opened={isModalOpen}
|
||||
onClose={() => navigate({ search: {} })}
|
||||
title={`Delete confirmation`}
|
||||
title={`Konfirmasi Hapus`}
|
||||
>
|
||||
<Text size="sm">
|
||||
Are you sure you want to delete user{" "}
|
||||
Apakah Anda yakin ingin menghapus pengguna{" "}
|
||||
<Text span fw={700}>
|
||||
{userQuery.data?.name}
|
||||
</Text>
|
||||
? This action is irreversible.
|
||||
? Tindakan ini tidak dapat diubah.
|
||||
</Text>
|
||||
|
||||
{/* {errorMessage && <Alert color="red">{errorMessage}</Alert>} */}
|
||||
|
|
@ -81,7 +81,7 @@ export default function UserDeleteModal() {
|
|||
onClick={() => navigate({ search: {} })}
|
||||
disabled={mutation.isPending}
|
||||
>
|
||||
Cancel
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
variant="subtle"
|
||||
|
|
@ -91,7 +91,7 @@ export default function UserDeleteModal() {
|
|||
loading={mutation.isPending}
|
||||
onClick={() => mutation.mutate({ id: userId })}
|
||||
>
|
||||
Delete User
|
||||
Hapus Pengguna
|
||||
</Button>
|
||||
</Flex>
|
||||
</Modal>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export default function UserFormModal() {
|
|||
const detailId = searchParams.detail;
|
||||
const editId = searchParams.edit;
|
||||
|
||||
const formType = detailId ? "detail" : editId ? "edit" : "create";
|
||||
const formType = detailId ? "detail" : editId ? "ubah" : "tambah";
|
||||
|
||||
/**
|
||||
* CHANGE FOLLOWING:
|
||||
|
|
@ -51,7 +51,7 @@ export default function UserFormModal() {
|
|||
const userQuery = useQuery(getUserByIdQueryOptions(dataId));
|
||||
|
||||
const modalTitle =
|
||||
formType.charAt(0).toUpperCase() + formType.slice(1) + " User";
|
||||
formType.charAt(0).toUpperCase() + formType.slice(1) + " Pengguna";
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
|
|
@ -62,6 +62,11 @@ export default function UserFormModal() {
|
|||
photoProfileUrl: "",
|
||||
password: "",
|
||||
roles: [] as string[],
|
||||
companyName: "",
|
||||
position: "",
|
||||
workExperience: "",
|
||||
address: "",
|
||||
phoneNumber: "",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -81,6 +86,11 @@ export default function UserFormModal() {
|
|||
username: data.username,
|
||||
password: "",
|
||||
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({});
|
||||
|
|
@ -91,11 +101,11 @@ export default function UserFormModal() {
|
|||
mutationKey: ["usersMutation"],
|
||||
mutationFn: async (
|
||||
options:
|
||||
| { action: "edit"; data: Parameters<typeof updateUser>[0] }
|
||||
| { action: "create"; data: Parameters<typeof createUser>[0] }
|
||||
| { action: "ubah"; data: Parameters<typeof updateUser>[0] }
|
||||
| { action: "tambah"; data: Parameters<typeof createUser>[0] }
|
||||
) => {
|
||||
console.log("called");
|
||||
return options.action === "edit"
|
||||
return options.action === "ubah"
|
||||
? await updateUser(options.data)
|
||||
: await createUser(options.data);
|
||||
},
|
||||
|
|
@ -120,16 +130,21 @@ export default function UserFormModal() {
|
|||
if (formType === "detail") return;
|
||||
|
||||
//TODO: OPtimize this code
|
||||
if (formType === "create") {
|
||||
if (formType === "tambah") {
|
||||
await mutation.mutateAsync({
|
||||
action: formType,
|
||||
data: {
|
||||
email: values.email,
|
||||
name: values.name,
|
||||
password: values.password,
|
||||
roles: JSON.stringify(values.roles),
|
||||
roles: values.roles,
|
||||
isEnabled: "true",
|
||||
username: values.username,
|
||||
companyName: values.email,
|
||||
position: values.position,
|
||||
workExperience: values.workExperience,
|
||||
address: values.address,
|
||||
phoneNumber: values.phoneNumber,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
|
@ -140,15 +155,20 @@ export default function UserFormModal() {
|
|||
email: values.email,
|
||||
name: values.name,
|
||||
password: values.password,
|
||||
roles: JSON.stringify(values.roles),
|
||||
roles: values.roles,
|
||||
isEnabled: "true",
|
||||
username: values.username,
|
||||
companyName: values.companyName,
|
||||
position: values.position,
|
||||
workExperience: values.workExperience,
|
||||
address: values.address,
|
||||
phoneNumber: values.phoneNumber,
|
||||
},
|
||||
});
|
||||
}
|
||||
queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||
notifications.show({
|
||||
message: `The ser is ${formType === "create" ? "created" : "edited"}`,
|
||||
message: `The ser is ${formType === "tambah" ? "created" : "edited"}`,
|
||||
});
|
||||
|
||||
navigate({ search: {} });
|
||||
|
|
@ -198,20 +218,18 @@ export default function UserFormModal() {
|
|||
inputs: [
|
||||
{
|
||||
type: "text",
|
||||
readOnly: true,
|
||||
variant: "filled",
|
||||
...form.getInputProps("id"),
|
||||
hidden: !form.values.id,
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Name",
|
||||
label: "Nama",
|
||||
...form.getInputProps("name"),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Username",
|
||||
...form.getInputProps("username"),
|
||||
label: "Jabatan",
|
||||
...form.getInputProps("position"),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Pengalaman Kerja",
|
||||
...form.getInputProps("workExperience"),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
|
|
@ -219,11 +237,21 @@ export default function UserFormModal() {
|
|||
...form.getInputProps("email"),
|
||||
},
|
||||
{
|
||||
type: "password",
|
||||
label: "Password",
|
||||
hidden: formType !== "create",
|
||||
...form.getInputProps("password"),
|
||||
type: "text",
|
||||
label: "Instansi/Perusahaan",
|
||||
...form.getInputProps("companyName"),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Alamat",
|
||||
...form.getInputProps("address"),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Nomor Telepon",
|
||||
...form.getInputProps("phoneNumber"),
|
||||
},
|
||||
|
||||
{
|
||||
type: "multi-select",
|
||||
label: "Roles",
|
||||
|
|
@ -236,6 +264,17 @@ export default function UserFormModal() {
|
|||
})),
|
||||
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: {} })}
|
||||
disabled={mutation.isPending}
|
||||
>
|
||||
Close
|
||||
Tutup
|
||||
</Button>
|
||||
{formType !== "detail" && (
|
||||
<Button
|
||||
|
|
@ -255,7 +294,7 @@ export default function UserFormModal() {
|
|||
type="submit"
|
||||
loading={mutation.isPending}
|
||||
>
|
||||
Save
|
||||
Simpan
|
||||
</Button>
|
||||
)}
|
||||
</Flex>
|
||||
|
|
|
|||
|
|
@ -34,26 +34,26 @@ export const getUserByIdQueryOptions = (userId: string | undefined) =>
|
|||
});
|
||||
|
||||
export const createUser = async (
|
||||
form: InferRequestType<typeof client.users.$post>["form"]
|
||||
json: InferRequestType<typeof client.users.$post>["json"]
|
||||
) => {
|
||||
return await fetchRPC(
|
||||
client.users.$post({
|
||||
form,
|
||||
json,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
export const updateUser = async (
|
||||
form: InferRequestType<(typeof client.users)[":id"]["$patch"]>["form"] & {
|
||||
json: InferRequestType<(typeof client.users)[":id"]["$patch"]>["json"] & {
|
||||
id: string;
|
||||
}
|
||||
) => {
|
||||
return await fetchRPC(
|
||||
client.users[":id"].$patch({
|
||||
param: {
|
||||
id: form.id,
|
||||
id: json.id,
|
||||
},
|
||||
form,
|
||||
json,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
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 { CrudPermission } from "@/types";
|
||||
import stringToColorHex from "@/utils/stringToColorHex";
|
||||
|
|
@ -7,6 +6,8 @@ import createActionButtons from "@/utils/createActionButton";
|
|||
import client from "@/honoClient";
|
||||
import { InferResponseType } from "hono";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { Badge } from "@/shadcn/components/ui/badge";
|
||||
import { Avatar } from "@/shadcn/components/ui/avatar";
|
||||
|
||||
interface ColumnOptions {
|
||||
permissions: Partial<CrudPermission>;
|
||||
|
|
@ -29,31 +30,28 @@ const createColumns = (options: ColumnOptions) => {
|
|||
columnHelper.accessor("name", {
|
||||
header: "Name",
|
||||
cell: (props) => (
|
||||
<Group>
|
||||
<div className="items-center justify-center gap-2">
|
||||
<Avatar
|
||||
color={stringToColorHex(props.row.original.id)}
|
||||
style={{ backgroundColor: stringToColorHex(props.row.original.id), width: '26px', height: '26px' }}
|
||||
// src={props.row.original.photoUrl}
|
||||
size={26}
|
||||
>
|
||||
{props.getValue()?.[0].toUpperCase()}
|
||||
</Avatar>
|
||||
<Text size="sm" fw={500}>
|
||||
<span className="text-sm font-medium">
|
||||
{props.getValue()}
|
||||
</Text>
|
||||
</Group>
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
}),
|
||||
|
||||
columnHelper.accessor("email", {
|
||||
header: "Email",
|
||||
cell: (props) => (
|
||||
<Anchor
|
||||
to={`mailto:${props.getValue()}`}
|
||||
size="sm"
|
||||
component={Link}
|
||||
<Link
|
||||
href={`mailto:${props.getValue()}`}
|
||||
>
|
||||
{props.getValue()}
|
||||
</Anchor>
|
||||
</Link>
|
||||
),
|
||||
}),
|
||||
|
||||
|
|
@ -66,7 +64,7 @@ const createColumns = (options: ColumnOptions) => {
|
|||
id: "status",
|
||||
header: "Status",
|
||||
cell: (props) => (
|
||||
<Badge color={props.row.original.isEnabled ? "green" : "gray"}>
|
||||
<Badge variant={props.row.original.isEnabled ? "default" : "secondary"}>
|
||||
{props.row.original.isEnabled ? "Active" : "Inactive"}
|
||||
</Badge>
|
||||
),
|
||||
|
|
@ -80,7 +78,7 @@ const createColumns = (options: ColumnOptions) => {
|
|||
className: "w-fit",
|
||||
},
|
||||
cell: (props) => (
|
||||
<Flex gap="xs">
|
||||
<div className="gap-8">
|
||||
{createActionButtons([
|
||||
{
|
||||
label: "Detail",
|
||||
|
|
@ -104,7 +102,7 @@ const createColumns = (options: ColumnOptions) => {
|
|||
icon: <TbTrash />,
|
||||
},
|
||||
])}
|
||||
</Flex>
|
||||
</div>
|
||||
),
|
||||
}),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ import { Route as DashboardLayoutDashboardIndexImport } from './routes/_dashboar
|
|||
const IndexLazyImport = createFileRoute('/')()
|
||||
const LogoutIndexLazyImport = createFileRoute('/logout/')()
|
||||
const LoginIndexLazyImport = createFileRoute('/login/')()
|
||||
const ForgotPasswordIndexLazyImport = createFileRoute('/forgot-password/')()
|
||||
const ForgotPasswordVerifyLazyImport = createFileRoute(
|
||||
'/forgot-password/verify',
|
||||
)()
|
||||
|
||||
// Create/Update Routes
|
||||
|
||||
|
|
@ -46,6 +50,20 @@ const LoginIndexLazyRoute = LoginIndexLazyImport.update({
|
|||
getParentRoute: () => rootRoute,
|
||||
} as any).lazy(() => import('./routes/login/index.lazy').then((d) => d.Route))
|
||||
|
||||
const ForgotPasswordIndexLazyRoute = ForgotPasswordIndexLazyImport.update({
|
||||
path: '/forgot-password/',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any).lazy(() =>
|
||||
import('./routes/forgot-password/index.lazy').then((d) => d.Route),
|
||||
)
|
||||
|
||||
const ForgotPasswordVerifyLazyRoute = ForgotPasswordVerifyLazyImport.update({
|
||||
path: '/forgot-password/verify',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any).lazy(() =>
|
||||
import('./routes/forgot-password/verify.lazy').then((d) => d.Route),
|
||||
)
|
||||
|
||||
const DashboardLayoutUsersIndexRoute = DashboardLayoutUsersIndexImport.update({
|
||||
path: '/users/',
|
||||
getParentRoute: () => DashboardLayoutRoute,
|
||||
|
|
@ -83,6 +101,20 @@ declare module '@tanstack/react-router' {
|
|||
preLoaderRoute: typeof DashboardLayoutImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/forgot-password/verify': {
|
||||
id: '/forgot-password/verify'
|
||||
path: '/forgot-password/verify'
|
||||
fullPath: '/forgot-password/verify'
|
||||
preLoaderRoute: typeof ForgotPasswordVerifyLazyImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/forgot-password/': {
|
||||
id: '/forgot-password/'
|
||||
path: '/forgot-password'
|
||||
fullPath: '/forgot-password'
|
||||
preLoaderRoute: typeof ForgotPasswordIndexLazyImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/login/': {
|
||||
id: '/login/'
|
||||
path: '/login'
|
||||
|
|
@ -130,6 +162,8 @@ export const routeTree = rootRoute.addChildren({
|
|||
DashboardLayoutTimetableIndexRoute,
|
||||
DashboardLayoutUsersIndexRoute,
|
||||
}),
|
||||
ForgotPasswordVerifyLazyRoute,
|
||||
ForgotPasswordIndexLazyRoute,
|
||||
LoginIndexLazyRoute,
|
||||
LogoutIndexLazyRoute,
|
||||
})
|
||||
|
|
@ -144,6 +178,8 @@ export const routeTree = rootRoute.addChildren({
|
|||
"children": [
|
||||
"/",
|
||||
"/_dashboardLayout",
|
||||
"/forgot-password/verify",
|
||||
"/forgot-password/",
|
||||
"/login/",
|
||||
"/logout/"
|
||||
]
|
||||
|
|
@ -159,6 +195,12 @@ export const routeTree = rootRoute.addChildren({
|
|||
"/_dashboardLayout/users/"
|
||||
]
|
||||
},
|
||||
"/forgot-password/verify": {
|
||||
"filePath": "forgot-password/verify.lazy.tsx"
|
||||
},
|
||||
"/forgot-password/": {
|
||||
"filePath": "forgot-password/index.lazy.tsx"
|
||||
},
|
||||
"/login/": {
|
||||
"filePath": "login/index.lazy.tsx"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
import { AppShell } from "@mantine/core";
|
||||
import { Navigate, Outlet, createFileRoute } from "@tanstack/react-router";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import AppHeader from "../components/AppHeader";
|
||||
import AppNavbar from "../components/AppNavbar";
|
||||
import useAuth from "@/hooks/useAuth";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import fetchRPC from "@/utils/fetchRPC";
|
||||
import client from "@/honoClient";
|
||||
import { useState } from "react";
|
||||
|
||||
export const Route = createFileRoute("/_dashboardLayout")({
|
||||
component: DashboardLayout,
|
||||
|
|
@ -39,29 +38,27 @@ function DashboardLayout() {
|
|||
enabled: isAuthenticated,
|
||||
});
|
||||
|
||||
const [openNavbar, { toggle }] = useDisclosure(false);
|
||||
const [openNavbar, setNavbarOpen] = useState(true);
|
||||
const toggle = () => {
|
||||
setNavbarOpen(!openNavbar);
|
||||
};
|
||||
|
||||
return isAuthenticated ? (
|
||||
<AppShell
|
||||
padding="md"
|
||||
header={{ height: 70 }}
|
||||
navbar={{
|
||||
width: 300,
|
||||
breakpoint: "sm",
|
||||
collapsed: { mobile: !openNavbar },
|
||||
}}
|
||||
>
|
||||
<AppHeader openNavbar={openNavbar} toggle={toggle} />
|
||||
<div className="flex flex-col w-full h-screen overflow-hidden">
|
||||
{/* Header */}
|
||||
<AppHeader toggle={toggle} openNavbar={openNavbar} />
|
||||
|
||||
{/* Main Content Area */}
|
||||
<div className="flex h-full w-screen overflow-hidden">
|
||||
{/* Sidebar */}
|
||||
<AppNavbar />
|
||||
|
||||
<AppShell.Main
|
||||
className="bg-slate-100"
|
||||
styles={{ main: { backgroundColor: "rgb(241 245 249)" } }}
|
||||
>
|
||||
{/* Main Content */}
|
||||
<main className="relative w-full mt-16 p-6 bg-white overflow-auto">
|
||||
<Outlet />
|
||||
</AppShell.Main>
|
||||
</AppShell>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<Navigate to="/login" />
|
||||
);
|
||||
|
|
|
|||
|
|
@ -20,17 +20,17 @@ const columnHelper = createColumnHelper<DataType>();
|
|||
export default function UsersPage() {
|
||||
return (
|
||||
<PageTemplate
|
||||
title="Users"
|
||||
title="Manajemen Pengguna"
|
||||
queryOptions={userQueryOptions}
|
||||
modals={[<UserFormModal />, <UserDeleteModal />]}
|
||||
columnDefs={[
|
||||
columnHelper.display({
|
||||
header: "#",
|
||||
header: "No",
|
||||
cell: (props) => props.row.index + 1,
|
||||
}),
|
||||
|
||||
columnHelper.display({
|
||||
header: "Name",
|
||||
header: "Nama",
|
||||
cell: (props) => props.row.original.name,
|
||||
}),
|
||||
|
||||
|
|
@ -38,19 +38,28 @@ export default function UsersPage() {
|
|||
header: "Username",
|
||||
cell: (props) => props.row.original.username,
|
||||
}),
|
||||
|
||||
columnHelper.display({
|
||||
header: "Status",
|
||||
cell: (props) =>
|
||||
props.row.original.isEnabled ? (
|
||||
<Badge color="green">Active</Badge>
|
||||
) : (
|
||||
<Badge color="red">Inactive</Badge>
|
||||
),
|
||||
header: "Email",
|
||||
cell: (props) => props.row.original.email,
|
||||
}),
|
||||
columnHelper.display({
|
||||
header: "Perusahaan",
|
||||
cell: (props) => props.row.original.company,
|
||||
}),
|
||||
|
||||
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) => (
|
||||
<Flex gap="xs">
|
||||
{createActionButtons([
|
||||
|
|
@ -62,14 +71,14 @@ export default function UsersPage() {
|
|||
icon: <TbEye />,
|
||||
},
|
||||
{
|
||||
label: "Edit",
|
||||
label: "Ubah",
|
||||
permission: true,
|
||||
action: `?edit=${props.row.original.id}`,
|
||||
color: "orange",
|
||||
icon: <TbPencil />,
|
||||
},
|
||||
{
|
||||
label: "Delete",
|
||||
label: "Hapus",
|
||||
permission: true,
|
||||
action: `?delete=${props.row.original.id}`,
|
||||
color: "red",
|
||||
|
|
|
|||
|
|
@ -159,33 +159,30 @@ export function ForgotPasswordForm() {
|
|||
|
||||
return (
|
||||
<div className="flex flex-col lg:flex-row min-h-screen w-screen overflow-hidden">
|
||||
<div
|
||||
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="flex absolute border border-slate-300 rounded-2xl w-[455px] h-[455px] lg:w-[650px] lg:h-[650px] items-center justify-center -rotate-[15deg]">
|
||||
<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">
|
||||
<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">
|
||||
<div className="hidden lg:flex absolute border border-slate-600 rounded-2xl w-2/3 h-2/3">
|
||||
</div>
|
||||
</div>
|
||||
<div className="absolute inset-0 flex z-0 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)]">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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 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 */}
|
||||
<div className="flex items-center font-bold">Amati</div>
|
||||
|
||||
{/* 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">
|
||||
<h1
|
||||
className="text-4xl font-bold"
|
||||
style={{ color: "#000000" }}
|
||||
className="text-4xl font-bold text-black"
|
||||
>
|
||||
Forgot Password
|
||||
</h1>
|
||||
<p className="text-sm">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
No worries, we'll send you reset instructions
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -207,19 +204,14 @@ export function ForgotPasswordForm() {
|
|||
<div className="flex flex-col justify-between gap-9">
|
||||
<Button
|
||||
type="submit"
|
||||
style={{
|
||||
backgroundColor: "#2555FF",
|
||||
color: "white",
|
||||
width: "100%",
|
||||
}}
|
||||
className="flex items-center justify-between shadow-xl"
|
||||
className="flex items-center justify-between shadow-xl w-full text-white bg-[--primary-color]"
|
||||
>
|
||||
<span className="flex">Request Reset</span>
|
||||
<TbArrowNarrowRight className="h-5 w-5" />
|
||||
</Button>
|
||||
<a
|
||||
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
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -195,33 +195,30 @@ export function ResetPasswordForm() {
|
|||
|
||||
return (
|
||||
<div className="flex flex-col lg:flex-row min-h-screen w-screen overflow-hidden">
|
||||
<div
|
||||
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="flex absolute border border-slate-200 rounded-2xl w-[455px] h-[455px] lg:w-[650px] lg:h-[650px] items-center justify-center -rotate-[15deg]">
|
||||
<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">
|
||||
<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">
|
||||
<div className="hidden lg:flex absolute border border-slate-500 rounded-2xl w-2/3 h-2/3">
|
||||
</div>
|
||||
</div>
|
||||
<div className="absolute inset-0 flex z-0 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)]">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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 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 */}
|
||||
<div className="flex items-center font-bold">Amati</div>
|
||||
|
||||
{/* 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">
|
||||
<h1
|
||||
className="text-4xl font-bold"
|
||||
style={{ color: "#000000" }}
|
||||
className="text-4xl font-bold text-black"
|
||||
>
|
||||
Change Password
|
||||
</h1>
|
||||
<p className="text-sm">Enter your new password</p>
|
||||
<p className="text-sm text-muted-foreground">Enter your new password</p>
|
||||
</div>
|
||||
<Form {...form}>
|
||||
<form
|
||||
|
|
@ -249,19 +246,14 @@ export function ResetPasswordForm() {
|
|||
<div className="flex flex-col justify-between gap-9">
|
||||
<Button
|
||||
type="submit"
|
||||
style={{
|
||||
backgroundColor: "#2555FF",
|
||||
color: "white",
|
||||
width: "100%",
|
||||
}}
|
||||
className="flex items-center justify-between shadow-xl"
|
||||
className="flex items-center justify-between shadow-xl w-full text-white bg-[--primary-color]"
|
||||
>
|
||||
<span className="flex">Submit</span>
|
||||
<TbArrowNarrowRight className="h-5 w-5" />
|
||||
</Button>
|
||||
<a
|
||||
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
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|||
import { useEffect, useState } from "react";
|
||||
import useAuth from "@/hooks/useAuth";
|
||||
import { TbArrowNarrowRight } from "react-icons/tb";
|
||||
import logo from "@/assets/logos/amati-logo.png";
|
||||
|
||||
export const Route = createLazyFileRoute("/login/")({
|
||||
component: LoginPage,
|
||||
|
|
@ -30,8 +31,8 @@ type FormSchema = {
|
|||
};
|
||||
|
||||
const formSchema = z.object({
|
||||
username: z.string().min(1, "This field is required"),
|
||||
password: z.string().min(1, "This field is required"),
|
||||
username: z.string().min(1, "Kolom ini wajib diisi"),
|
||||
password: z.string().min(1, "Kolom ini wajib diisi"),
|
||||
});
|
||||
|
||||
export default function LoginPage() {
|
||||
|
|
@ -97,24 +98,34 @@ export default function LoginPage() {
|
|||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex items-center justify-center bg-contain bg-top lg:bg-right
|
||||
bg-no-repeat bg-[url('../src/assets/backgrounds/backgroundLoginMobile.png')]
|
||||
lg:bg-[url('../src/assets/backgrounds/backgroundLogin.png')]"
|
||||
>
|
||||
<div className="absolute top-[1.688rem] left-[1.875rem] text-base font-bold leading-[1.21rem]">
|
||||
Amati
|
||||
<div className="flex flex-col w-screen h-screen 3xl:max-w-screen-2xl 3xl:mx-auto 3xl:px-4 overflow-hidden">
|
||||
{/* Navbar */}
|
||||
<nav className="flex w-full bg-transparent px-8 py-7 justify-between">
|
||||
<div className="flex">
|
||||
<img src="../src/assets/logos/amati-logo.png" alt="Amati Logo" className="h-4 object-contain" />
|
||||
</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">
|
||||
<h1 className="mb-2 text-[2.625rem] font-bold leading-[3.177rem] tracking-tightest">Sign In</h1>
|
||||
<p className="text-sm mb-10 leading-[1.059rem]">
|
||||
New to this app?{' '}
|
||||
<a
|
||||
href="/register"
|
||||
className="text-blue-500 font-bold hover:text-blue-800"
|
||||
>
|
||||
Register now
|
||||
</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>
|
||||
|
||||
{/* Sign In form */}
|
||||
<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">
|
||||
<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">
|
||||
<h1 className="mb-2 text-4xl font-bold leading-10 tracking-tighter">Sign In</h1>
|
||||
<p className="text-sm mb-10 leading-4 text-muted-foreground">
|
||||
Baru mengenal aplikasi ini?{' '}
|
||||
<a href="/register" className="text-blue-600 font-bold hover:text-blue-800">
|
||||
Daftar sekarang
|
||||
</a>
|
||||
</p>
|
||||
<Form {...form}>
|
||||
|
|
@ -129,7 +140,7 @@ export default function LoginPage() {
|
|||
name="username"
|
||||
render={({ field }) => (
|
||||
<FormItem className="text-sm">
|
||||
<FormLabel className="font-semibold leading-[1.059rem]">Email/Username</FormLabel>
|
||||
<FormLabel className="font-semibold leading-4">Email/Username</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder="eg; user@mail.com"
|
||||
|
|
@ -146,7 +157,7 @@ export default function LoginPage() {
|
|||
name="password"
|
||||
render={({ field }) => (
|
||||
<FormItem className="text-sm">
|
||||
<FormLabel className="font-semibold leading-[1.059rem]">Password</FormLabel>
|
||||
<FormLabel className="font-semibold leading-4">Kata sandi</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="password"
|
||||
|
|
@ -161,23 +172,19 @@ export default function LoginPage() {
|
|||
)}
|
||||
/>
|
||||
<p className="text-sm">
|
||||
<a
|
||||
href="/forgot-password"
|
||||
className="text-blue-500 font-bold hover:text-blue-800 leading-[1.059rem]"
|
||||
>
|
||||
Forgot Password?
|
||||
<a href="/forgot-password" className="text-blue-600 font-bold hover:text-blue-800 leading-4">
|
||||
Lupa kata sandi?
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex justify-between mt-10">
|
||||
<div className="flex 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]"
|
||||
className="flex w-full justify-between bg-blue-600 text-white hover:bg-blue-700"
|
||||
>
|
||||
<span className="leading-[1.25rem]">Sign In</span>
|
||||
<span className="leading-5">Sign In</span>
|
||||
<TbArrowNarrowRight className="h-5 w-5" />
|
||||
</Button>
|
||||
</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 DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
||||
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",
|
||||
},
|
||||
},
|
||||
letterSpacing: {
|
||||
tightest: '-.075em',
|
||||
tighter: '-.05em',
|
||||
tight: '-.025em',
|
||||
normal: '0',
|
||||
wide: '.025em',
|
||||
wider: '.05em',
|
||||
widest: '.1em',
|
||||
widest: '.25em',
|
||||
screens: {
|
||||
'sm': '640px',
|
||||
'md': '768px',
|
||||
'lg': '1024px',
|
||||
'xl': '1280px',
|
||||
'2xl': '1536px',
|
||||
'3xl': '1980px',
|
||||
},
|
||||
},
|
||||
plugins: [require("tailwindcss-animate")],
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export default defineConfig({
|
|||
plugins: [react(), TanStackRouterVite()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname,"/src"),
|
||||
"@": path.resolve(__dirname,"src"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
214
pnpm-lock.yaml
214
pnpm-lock.yaml
|
|
@ -111,15 +111,30 @@ importers:
|
|||
'@mantine/notifications':
|
||||
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)
|
||||
'@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':
|
||||
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-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':
|
||||
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-label':
|
||||
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)
|
||||
'@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':
|
||||
specifier: ^1.1.0
|
||||
version: 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||
|
|
@ -1459,6 +1474,9 @@ packages:
|
|||
resolution: {integrity: sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==}
|
||||
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':
|
||||
resolution: {integrity: sha512-4Z8dn6Upk0qk4P74xBhZ6Hd/w0mPEzOOLxy4xiPXOXqjF7jZS0VAKk7/x/H6FyY2zCkYJqePf1G5KmkmNJ4RBA==}
|
||||
|
||||
|
|
@ -1475,6 +1493,19 @@ packages:
|
|||
'@types/react-dom':
|
||||
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':
|
||||
resolution: {integrity: sha512-0i/EKJ222Afa1FE0C6pNJxDq1itzcl3HChE9DwskA4th4KRse8ojx8a1nVcOjwJdbpDLcz7uol77yYnQNMHdKw==}
|
||||
peerDependencies:
|
||||
|
|
@ -1519,6 +1550,19 @@ packages:
|
|||
'@types/react':
|
||||
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':
|
||||
resolution: {integrity: sha512-BUuBvgThEiAXh2DWu93XsT+a3aWrGqolGlqqw5VU1kG7p/ZH2cuDlM1sRLNnY3QcBS69UIz2mcKhMxDsdewhjg==}
|
||||
peerDependencies:
|
||||
|
|
@ -1663,6 +1707,19 @@ packages:
|
|||
'@types/react-dom':
|
||||
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':
|
||||
resolution: {integrity: sha512-EA6AMGeq9AEeQDeSH0aZgG198qkfHSbvWTf1HvoDmOB5bBG/qTxjYMWUKMnYiV6J/iP/J8MEFSuB2zRU2n7ODA==}
|
||||
peerDependencies:
|
||||
|
|
@ -1676,6 +1733,32 @@ packages:
|
|||
'@types/react-dom':
|
||||
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':
|
||||
resolution: {integrity: sha512-FUCf5XMfmW4dtYl69pdS4DbxKy8nj4M7SafBgPllysxmdachynNflAdp/gCsnYWNDnge6tI9onzMp5ARYc1KNw==}
|
||||
peerDependencies:
|
||||
|
|
@ -1748,6 +1831,19 @@ packages:
|
|||
'@types/react':
|
||||
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':
|
||||
resolution: {integrity: sha512-A9+lCBZoaMJlVKcRBz2YByCG+Cp2t6nAnMnNba+XiWxnj6r4JUFqfsgwocMBZU9LPtdxC6wB56ySYpc7LQIoJg==}
|
||||
|
||||
|
|
@ -5265,9 +5361,6 @@ packages:
|
|||
tslib@1.14.1:
|
||||
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
|
||||
|
||||
tslib@2.6.2:
|
||||
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
|
||||
|
||||
tslib@2.6.3:
|
||||
resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==}
|
||||
|
||||
|
|
@ -6807,6 +6900,8 @@ snapshots:
|
|||
|
||||
'@pkgr/core@0.1.1': {}
|
||||
|
||||
'@radix-ui/number@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)':
|
||||
|
|
@ -6818,6 +6913,18 @@ snapshots:
|
|||
'@types/react': 18.3.3
|
||||
'@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)':
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.1.0
|
||||
|
|
@ -6858,6 +6965,28 @@ snapshots:
|
|||
optionalDependencies:
|
||||
'@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)':
|
||||
dependencies:
|
||||
react: 18.3.1
|
||||
|
|
@ -6998,6 +7127,24 @@ snapshots:
|
|||
'@types/react': 18.3.3
|
||||
'@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)':
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.1.0
|
||||
|
|
@ -7015,6 +7162,52 @@ snapshots:
|
|||
'@types/react': 18.3.3
|
||||
'@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)':
|
||||
dependencies:
|
||||
'@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1)
|
||||
|
|
@ -7068,6 +7261,15 @@ snapshots:
|
|||
optionalDependencies:
|
||||
'@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': {}
|
||||
|
||||
'@rollup/rollup-android-arm-eabi@4.18.0':
|
||||
|
|
@ -10921,7 +11123,7 @@ snapshots:
|
|||
|
||||
rxjs@7.8.1:
|
||||
dependencies:
|
||||
tslib: 2.6.2
|
||||
tslib: 2.6.3
|
||||
|
||||
safe-array-concat@1.1.2:
|
||||
dependencies:
|
||||
|
|
@ -11222,7 +11424,7 @@ snapshots:
|
|||
synckit@0.9.0:
|
||||
dependencies:
|
||||
'@pkgr/core': 0.1.1
|
||||
tslib: 2.6.2
|
||||
tslib: 2.6.3
|
||||
|
||||
tabbable@6.2.0: {}
|
||||
|
||||
|
|
@ -11374,8 +11576,6 @@ snapshots:
|
|||
|
||||
tslib@1.14.1: {}
|
||||
|
||||
tslib@2.6.2: {}
|
||||
|
||||
tslib@2.6.3: {}
|
||||
|
||||
tsutils@3.21.0(typescript@5.4.5):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user