mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 13:55:45 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4beb3d4f91 |
@@ -45,6 +45,3 @@ next-env.d.ts
|
|||||||
|
|
||||||
# claude
|
# claude
|
||||||
.claude
|
.claude
|
||||||
|
|
||||||
# rtk
|
|
||||||
rtk.exe
|
|
||||||
|
|||||||
+25
-49
@@ -2,20 +2,9 @@ stages:
|
|||||||
- build
|
- build
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# ✅ Global defaults
|
|
||||||
# ==========================================================
|
|
||||||
default:
|
|
||||||
tags:
|
|
||||||
- server-development-biznet
|
|
||||||
interruptible: true
|
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# 🏗️ Build Template
|
|
||||||
# ==========================================================
|
|
||||||
.build_template: &build_template
|
.build_template: &build_template
|
||||||
stage: build
|
stage: build
|
||||||
image: public.ecr.aws/docker/library/node:20-alpine
|
image: node:20-alpine
|
||||||
cache:
|
cache:
|
||||||
key: npm-cache
|
key: npm-cache
|
||||||
paths:
|
paths:
|
||||||
@@ -50,13 +39,10 @@ default:
|
|||||||
- out/
|
- out/
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# 🚀 Deploy Template
|
|
||||||
# ==========================================================
|
|
||||||
.deploy_template: &deploy_template
|
.deploy_template: &deploy_template
|
||||||
stage: deploy
|
stage: deploy
|
||||||
image:
|
image:
|
||||||
name: public.ecr.aws/aws-cli/aws-cli:latest
|
name: amazon/aws-cli:latest
|
||||||
entrypoint: ['/bin/sh', '-c']
|
entrypoint: ['/bin/sh', '-c']
|
||||||
script:
|
script:
|
||||||
- set -e
|
- set -e
|
||||||
@@ -96,11 +82,11 @@ default:
|
|||||||
if [ "$STATUS" = "success" ]; then
|
if [ "$STATUS" = "success" ]; then
|
||||||
COLOR=3066993
|
COLOR=3066993
|
||||||
TITLE="✅ Deployment ${ENVIRONMENT_NAME} Succeeded"
|
TITLE="✅ Deployment ${ENVIRONMENT_NAME} Succeeded"
|
||||||
DESC="Deployment job on branch \${CI_COMMIT_REF_NAME}\ completed successfully."
|
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` completed successfully."
|
||||||
else
|
else
|
||||||
COLOR=15158332
|
COLOR=15158332
|
||||||
TITLE="❌ Deployment ${ENVIRONMENT_NAME} Failed"
|
TITLE="❌ Deployment ${ENVIRONMENT_NAME} Failed"
|
||||||
DESC="Deployment job on branch \${CI_COMMIT_REF_NAME}\ encountered issues."
|
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` encountered issues."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
jq -n \
|
jq -n \
|
||||||
@@ -128,9 +114,7 @@ default:
|
|||||||
|
|
||||||
curl -sS -H "Content-Type: application/json" -d @payload.json "$DISCORD_WEBHOOK_URL"
|
curl -sS -H "Content-Type: application/json" -d @payload.json "$DISCORD_WEBHOOK_URL"
|
||||||
|
|
||||||
# ==========================================================
|
# ====== DEVELOPMENT (Branch development) ======
|
||||||
# ==== DEVELOPMENT (Branch development) ======
|
|
||||||
# ==========================================================
|
|
||||||
build:dev:
|
build:dev:
|
||||||
<<: *build_template
|
<<: *build_template
|
||||||
rules:
|
rules:
|
||||||
@@ -156,9 +140,7 @@ deploy:dev:
|
|||||||
name: development
|
name: development
|
||||||
url: https://dev-lti-erp.mbugroup.id
|
url: https://dev-lti-erp.mbugroup.id
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# ====== STAGING (Branch staging) ======
|
# ====== STAGING (Branch staging) ======
|
||||||
# ==========================================================
|
|
||||||
build:staging:
|
build:staging:
|
||||||
<<: *build_template
|
<<: *build_template
|
||||||
rules:
|
rules:
|
||||||
@@ -183,31 +165,25 @@ deploy:staging:
|
|||||||
environment:
|
environment:
|
||||||
name: staging
|
name: staging
|
||||||
url: https://stg-lti-erp.mbugroup.id
|
url: https://stg-lti-erp.mbugroup.id
|
||||||
|
# ====== PRODUCTION ======
|
||||||
|
# build:production:
|
||||||
|
# <<: *build_template
|
||||||
|
# rules:
|
||||||
|
# # pilih salah satu: pakai branch master ATAU pakai tags rilis
|
||||||
|
# - if: '$CI_COMMIT_BRANCH == "master"'
|
||||||
|
# # - if: '$CI_COMMIT_TAG' # kalau mau rilis via tag, uncomment ini dan hapus baris di atas
|
||||||
|
# environment:
|
||||||
|
# name: production
|
||||||
|
|
||||||
# ==========================================================
|
# deploy:production:
|
||||||
# ====== STAGING (Branch production) ======
|
# <<: *deploy_template
|
||||||
# ==========================================================
|
# needs: ["build:production"]
|
||||||
build:production:
|
# rules:
|
||||||
<<: *build_template
|
# - if: '$CI_COMMIT_BRANCH == "master"'
|
||||||
rules:
|
# # - if: '$CI_COMMIT_TAG' # selaras dengan rule di build:production
|
||||||
- if: '$CI_COMMIT_BRANCH == "production"'
|
# variables:
|
||||||
environment:
|
# S3_BUCKET: "lti-erp.mbugroup.id"
|
||||||
name: staging
|
# CLOUDFRONT_DISTRIBUTION_ID: "ddfd"
|
||||||
variables:
|
# environment:
|
||||||
NEXT_PUBLIC_LTI_URL: 'https://lti-erp.mbugroup.id'
|
# name: production
|
||||||
NEXT_PUBLIC_SSO_LOGIN_URL: 'https://auth-erp.mbugroup.id'
|
|
||||||
NEXT_PUBLIC_API_BASE_URL: 'https://api-lti.mbugroup.id/api'
|
|
||||||
NEXT_PUBLIC_CLIENT_ID: 'Lumbung-Telur-Indonesia'
|
|
||||||
|
|
||||||
deploy:production:
|
|
||||||
<<: *deploy_template
|
|
||||||
needs: ['build:production']
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_BRANCH == "production"'
|
|
||||||
variables:
|
|
||||||
S3_BUCKET: 'production-lti-erp.mbugroup.id'
|
|
||||||
AWS_REGION: 'ap-southeast-3'
|
|
||||||
CLOUDFRONT_DISTRIBUTION_ID: 'E1SSLXKYYITASJ'
|
|
||||||
environment:
|
|
||||||
name: staging
|
|
||||||
url: https://lti-erp.mbugroup.id
|
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
npm run format
|
npm run format
|
||||||
npm run lint
|
npm run lint
|
||||||
npm run typecheck
|
npx tsc --noEmit
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
FROM public.ecr.aws/docker/library/node:20-alpine
|
FROM node:20-alpine
|
||||||
|
|
||||||
RUN apk add --no-cache git bash build-base curl
|
RUN apk add --no-cache git bash build-base curl
|
||||||
|
|
||||||
@@ -22,4 +22,4 @@ RUN mkdir -p .next/server/app/_next && \
|
|||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
CMD ["npx", "serve", ".next/server/app", "-l", "3000"]
|
CMD ["npx", "serve", ".next/server/app", "-l", "3000"]
|
||||||
Generated
+40
-4125
File diff suppressed because it is too large
Load Diff
+4
-20
@@ -7,46 +7,30 @@
|
|||||||
"build": "next build --turbopack",
|
"build": "next build --turbopack",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"typecheck": "next typegen && tsc --noEmit",
|
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write ."
|
||||||
"pre-commit": "npm run format && npm run lint && npm run typecheck && npm run build"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-pdf/renderer": "^4.3.1",
|
"@react-pdf/renderer": "^4.3.1",
|
||||||
"@tanstack/match-sorter-utils": "^8.19.4",
|
"@tanstack/match-sorter-utils": "^8.19.4",
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"axios": "^1.12.2",
|
"axios": "^1.12.2",
|
||||||
"class-variance-authority": "^0.7.1",
|
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cmdk": "^1.1.1",
|
|
||||||
"embla-carousel-react": "^8.6.0",
|
|
||||||
"exceljs": "^4.4.0",
|
|
||||||
"formik": "^2.4.6",
|
"formik": "^2.4.6",
|
||||||
"html-to-image": "^1.11.13",
|
|
||||||
"input-otp": "^1.4.2",
|
|
||||||
"jspdf": "^3.0.4",
|
"jspdf": "^3.0.4",
|
||||||
"jspdf-autotable": "^5.0.2",
|
"jspdf-autotable": "^5.0.2",
|
||||||
"lucide-react": "^0.562.0",
|
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"next": "15.5.9",
|
"next": "15.5.9",
|
||||||
"next-themes": "^0.4.6",
|
"react": "19.1.0",
|
||||||
"radix-ui": "^1.4.3",
|
|
||||||
"react": "^19.1.2",
|
|
||||||
"react-day-picker": "^9.11.1",
|
"react-day-picker": "^9.11.1",
|
||||||
"react-dom": "^19.1.2",
|
"react-dom": "19.1.0",
|
||||||
"react-dropzone": "^14.3.8",
|
"react-dropzone": "^14.3.8",
|
||||||
"react-hook-form": "^7.70.0",
|
|
||||||
"react-hot-toast": "^2.6.0",
|
"react-hot-toast": "^2.6.0",
|
||||||
"react-number-format": "^5.4.4",
|
"react-number-format": "^5.4.4",
|
||||||
"react-resizable-panels": "2.1.7",
|
|
||||||
"react-select": "^5.10.2",
|
"react-select": "^5.10.2",
|
||||||
"recharts": "^3.6.0",
|
|
||||||
"sonner": "^2.0.7",
|
|
||||||
"swr": "^2.3.6",
|
"swr": "^2.3.6",
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
"use-debounce": "^10.0.6",
|
"use-debounce": "^10.0.6",
|
||||||
"vaul": "^1.1.2",
|
|
||||||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
||||||
"yup": "^1.7.0",
|
"yup": "^1.7.0",
|
||||||
"zustand": "^5.0.8"
|
"zustand": "^5.0.8"
|
||||||
@@ -58,7 +42,7 @@
|
|||||||
"@types/node": "^20",
|
"@types/node": "^20",
|
||||||
"@types/react": "^19",
|
"@types/react": "^19",
|
||||||
"@types/react-dom": "^19",
|
"@types/react-dom": "^19",
|
||||||
"daisyui": "^5.5.14",
|
"daisyui": "^5.5.8",
|
||||||
"eslint": "^9",
|
"eslint": "^9",
|
||||||
"eslint-config-next": "^15.5.7",
|
"eslint-config-next": "^15.5.7",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
|
|||||||
@@ -3,34 +3,30 @@
|
|||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
import ClosingDetail from '@/components/pages/closing/ClosingDetailTabs';
|
import ClosingDetail from '@/components/pages/closing/ClosingDetail';
|
||||||
|
|
||||||
import { ClosingApi } from '@/services/api/closing';
|
import { ClosingApi } from '@/services/api/closing';
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { ProjectFlockApi } from '@/services/api/production/project-flock';
|
|
||||||
import { ProjectFlockKandangApi } from '@/services/api/production';
|
|
||||||
|
|
||||||
const ClosingDetailPage = () => {
|
const ClosingDetailPage = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
const closingId = searchParams.get('closingId');
|
const closingId = searchParams.get('closingId');
|
||||||
const kandangId = searchParams.get('kandangId'); // project flock kandang ID
|
|
||||||
|
|
||||||
const { data: closing, isLoading: isLoadingClosing } = useSWR(
|
const { data: closing, isLoading: isLoadingClosing } = useSWR(
|
||||||
closingId,
|
closingId,
|
||||||
(id: number) => ClosingApi.getGeneralInfo(id)
|
(id: number) => ClosingApi.getGeneralInfo(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
// WORKAROUND - get flock data from closing ID
|
const { data: salesData, isLoading: isLoadingSales } = useSWR(
|
||||||
const { data: projectData, isLoading: isLoadingProject } = useSWR(
|
closingId ? `sales-${closingId}` : null,
|
||||||
`flock-${closingId}`,
|
() => ClosingApi.getPenjualan(Number(closingId))
|
||||||
() => ProjectFlockApi.getSingle(Number(closingId))
|
|
||||||
);
|
);
|
||||||
// WORKAROUND - get kandang data from closing ID
|
|
||||||
const { data: kandangData, isLoading: isLoadingKandang } = useSWR(
|
const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR(
|
||||||
kandangId ? `kandang-${closingId}-${kandangId}` : null,
|
closingId ? `hpp-ekspedisi-${closingId}` : null,
|
||||||
() => ProjectFlockKandangApi.getSingle(Number(kandangId))
|
() => ClosingApi.getHppEkspedisi(Number(closingId))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!closingId) {
|
if (!closingId) {
|
||||||
@@ -48,7 +44,7 @@ const ClosingDetailPage = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isLoading = isLoadingClosing || isLoadingProject || isLoadingKandang;
|
const isLoading = isLoadingClosing || isLoadingSales || isLoadingHppEkspedisi;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full p-4 flex flex-row justify-center'>
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
@@ -58,11 +54,11 @@ const ClosingDetailPage = () => {
|
|||||||
<ClosingDetail
|
<ClosingDetail
|
||||||
id={Number(closingId)}
|
id={Number(closingId)}
|
||||||
initialValue={closing.data}
|
initialValue={closing.data}
|
||||||
projectData={
|
salesData={isResponseSuccess(salesData) ? salesData.data : undefined}
|
||||||
isResponseSuccess(projectData) ? projectData.data : undefined
|
hppExpeditionData={
|
||||||
}
|
isResponseSuccess(hppEkspedisiData)
|
||||||
kandangData={
|
? hppEkspedisiData.data
|
||||||
isResponseSuccess(kandangData) ? kandangData.data : undefined
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import ClosingsTable from '@/components/pages/closing/ClosingsTable';
|
|||||||
|
|
||||||
const Closing = () => {
|
const Closing = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-3'>
|
<section className='w-full p-4'>
|
||||||
<ClosingsTable />
|
<ClosingsTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import { DailyChecklistContent } from '@/figma-make/components/pages/daily-checklist/DailyChecklistContent';
|
|
||||||
|
|
||||||
const DailyChecklistPage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full'>
|
|
||||||
<DailyChecklistContent />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DailyChecklistPage;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { Dashboard as DashboardDailyChecklist } from '@/figma-make/components/pages/dashboard/Dashboard';
|
|
||||||
|
|
||||||
const DailyChecklistDashboardPage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full'>
|
|
||||||
<DashboardDailyChecklist />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DailyChecklistDashboardPage;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { DetailDailyChecklistContent } from '@/figma-make/components/pages/list-daily-checklist/detail/DetailDailyChecklistContent';
|
|
||||||
|
|
||||||
const ListDailyChecklistDetailPage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full'>
|
|
||||||
<DetailDailyChecklistContent />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ListDailyChecklistDetailPage;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { ListDailyChecklistContent } from '@/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent';
|
|
||||||
|
|
||||||
const ListDailyChecklistPage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full'>
|
|
||||||
<ListDailyChecklistContent />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ListDailyChecklistPage;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { MasterAktivitasContent } from '@/figma-make/components/pages/master-data/activity/MasterAktivitasContent';
|
|
||||||
|
|
||||||
const MasterAktivitasPage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full'>
|
|
||||||
<MasterAktivitasContent />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MasterAktivitasPage;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { MasterConfigurationContent } from '@/figma-make/components/pages/master-data/configuration/MasterConfigurationContent';
|
|
||||||
|
|
||||||
const MasterConfigurationPage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full'>
|
|
||||||
<MasterConfigurationContent />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MasterConfigurationPage;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { MasterEmployeeContent } from '@/figma-make/components/pages/master-data/employee/MasterEmployeeContent';
|
|
||||||
|
|
||||||
const MasterEmployeePage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full'>
|
|
||||||
<MasterEmployeeContent />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MasterEmployeePage;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { MasterKandangContent } from '@/figma-make/components/pages/master-data/kandang/MasterKandangContent';
|
|
||||||
|
|
||||||
const MasterKandangPage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full'>
|
|
||||||
<MasterKandangContent />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MasterKandangPage;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { DailyChecklistReportsContent } from '@/figma-make/components/pages/reports/DailyChecklistReportsContent';
|
|
||||||
|
|
||||||
const DailyChecklistReportsPage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full'>
|
|
||||||
<DailyChecklistReportsContent />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DailyChecklistReportsPage;
|
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import DashboardProduction from '@/components/pages/dashboard/DashboardProduction';
|
|
||||||
|
|
||||||
const Dashboard = () => {
|
const Dashboard = () => {
|
||||||
return <DashboardProduction />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<h1 className='text-3xl font-bold text-primary'>Dashboard</h1>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Dashboard;
|
export default Dashboard;
|
||||||
|
|||||||
@@ -38,11 +38,9 @@ const ExpenseEditPage = () => {
|
|||||||
!isLoadingExpense &&
|
!isLoadingExpense &&
|
||||||
isResponseSuccess(expense) &&
|
isResponseSuccess(expense) &&
|
||||||
expense.data.latest_approval.step_number !== 5 &&
|
expense.data.latest_approval.step_number !== 5 &&
|
||||||
expense.data.latest_approval.step_number !== 6 &&
|
|
||||||
(expense.data.latest_approval.step_number === 1 ||
|
(expense.data.latest_approval.step_number === 1 ||
|
||||||
expense.data.latest_approval.step_number === 2 ||
|
expense.data.latest_approval.step_number === 2 ||
|
||||||
expense.data.latest_approval.step_number === 3 ||
|
expense.data.latest_approval.step_number === 3);
|
||||||
expense.data.latest_approval.step_number === 4);
|
|
||||||
|
|
||||||
if (!isLoadingExpense && !isExpenseCanBeEdited) {
|
if (!isLoadingExpense && !isExpenseCanBeEdited) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import ExpensesTable from '@/components/pages/expense/ExpensesTable';
|
|||||||
|
|
||||||
const Expense = () => {
|
const Expense = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4 sm:p-0'>
|
<section className='w-full p-4'>
|
||||||
<ExpensesTable />
|
<ExpensesTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ const ExpenseRealizationEditPage = () => {
|
|||||||
!isLoadingExpense &&
|
!isLoadingExpense &&
|
||||||
isResponseSuccess(expense) &&
|
isResponseSuccess(expense) &&
|
||||||
expense.data.latest_approval.action !== 'REJECTED' &&
|
expense.data.latest_approval.action !== 'REJECTED' &&
|
||||||
(expense.data.latest_approval.step_number === 5 ||
|
(expense.data.latest_approval.step_number === 4 ||
|
||||||
expense.data.latest_approval.step_number === 6);
|
expense.data.latest_approval.step_number === 5);
|
||||||
|
|
||||||
if (!isLoadingExpense && !isExpenseRealizationCanBeEdited) {
|
if (!isLoadingExpense && !isExpenseRealizationCanBeEdited) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const ExpenseRealization = () => {
|
|||||||
const isExpenseCanBeRealized =
|
const isExpenseCanBeRealized =
|
||||||
isResponseSuccess(expense) &&
|
isResponseSuccess(expense) &&
|
||||||
expense.data.latest_approval.action !== 'REJECTED' &&
|
expense.data.latest_approval.action !== 'REJECTED' &&
|
||||||
expense.data.latest_approval.step_number === 4;
|
expense.data.latest_approval.step_number === 3;
|
||||||
|
|
||||||
if (isResponseSuccess(expense) && !isExpenseCanBeRealized) {
|
if (isResponseSuccess(expense) && !isExpenseCanBeRealized) {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import useSWR from 'swr';
|
|||||||
import { FinanceApi } from '@/services/api/finance';
|
import { FinanceApi } from '@/services/api/finance';
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import FormFinanceAdd from '@/components/pages/finance/add/FormFinanceAdd';
|
import FormFinanceAdd from '@/components/pages/finance/add/FormFinanceAdd';
|
||||||
|
import FormFinanceAddInitialBalance from '@/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance';
|
||||||
|
|
||||||
const EditFinanceTransactionPage = () => {
|
const EditFinanceTransactionPage = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import FinanceDetail from '@/components/pages/finance/FinanceDetail';
|
|||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import { FinanceApi } from '@/services/api/finance';
|
import { FinanceApi } from '@/services/api/finance';
|
||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
const FinanceDetailPage = () => {
|
const FinanceDetailPage = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -24,6 +24,8 @@ const FinanceDetailPage = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(finance);
|
||||||
|
|
||||||
// if (!finance || isResponseError(finance)) {
|
// if (!finance || isResponseError(finance)) {
|
||||||
// router.replace('/404');
|
// router.replace('/404');
|
||||||
// return;
|
// return;
|
||||||
|
|||||||
@@ -3,7 +3,12 @@
|
|||||||
import FinanceTable from '@/components/pages/finance/FinanceTable';
|
import FinanceTable from '@/components/pages/finance/FinanceTable';
|
||||||
|
|
||||||
const Finance = () => {
|
const Finance = () => {
|
||||||
return <FinanceTable />;
|
return (
|
||||||
|
<section className='size-full p-6'>
|
||||||
|
<div className='flex flex-row gap-4'></div>
|
||||||
|
<FinanceTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Finance;
|
export default Finance;
|
||||||
|
|||||||
+5
-13
@@ -1,8 +1,6 @@
|
|||||||
@import 'tailwindcss';
|
@import 'tailwindcss';
|
||||||
@plugin "daisyui";
|
@plugin "daisyui";
|
||||||
@import '../styles/tailwind.css';
|
|
||||||
@import '../styles/daisyui.css';
|
@import '../styles/daisyui.css';
|
||||||
@import '../figma-make/styles/theme.css';
|
|
||||||
|
|
||||||
@plugin "daisyui/theme" {
|
@plugin "daisyui/theme" {
|
||||||
name: 'lti';
|
name: 'lti';
|
||||||
@@ -30,16 +28,16 @@
|
|||||||
--color-base-100: oklch(100% 0 0); /* #ffffff */
|
--color-base-100: oklch(100% 0 0); /* #ffffff */
|
||||||
--color-base-200: oklch(97.2% 0 0); /* #f2f2f2 */
|
--color-base-200: oklch(97.2% 0 0); /* #f2f2f2 */
|
||||||
--color-base-300: oklch(93.1% 0.002 249.7); /* #e5e6e6 */
|
--color-base-300: oklch(93.1% 0.002 249.7); /* #e5e6e6 */
|
||||||
--color-base-content: #18181b;
|
--color-base-content: oklch(18.6% 0.024 257.7); /* #1f2937 */
|
||||||
|
|
||||||
/* Status/Utility Colors */
|
/* Status/Utility Colors */
|
||||||
--color-info: oklch(67.4% 0.176 238.9);
|
--color-info: oklch(67.4% 0.176 238.9);
|
||||||
--color-info-content: oklch(0% 0 0); /* #000000 */
|
--color-info-content: oklch(0% 0 0); /* #000000 */
|
||||||
--color-success: #00d390;
|
--color-success: oklch(62.3% 0.147 149);
|
||||||
--color-success-content: oklch(100% 0 0); /* #ffffff */
|
--color-success-content: oklch(100% 0 0); /* #ffffff */
|
||||||
--color-warning: #fcb700;
|
--color-warning: oklch(82.2% 0.165 91.9);
|
||||||
--color-warning-content: oklch(0% 0 0); /* #000000 */
|
--color-warning-content: oklch(0% 0 0); /* #000000 */
|
||||||
--color-error: #ff3a3a;
|
--color-error: oklch(61.8% 0.203 27.8);
|
||||||
--color-error-content: oklch(100% 0 0); /* #fffffff */
|
--color-error-content: oklch(100% 0 0); /* #fffffff */
|
||||||
|
|
||||||
--radius-selector: 0rem;
|
--radius-selector: 0rem;
|
||||||
@@ -53,23 +51,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--color-primary: #0069e0;
|
--color-primary: #1f74bf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@theme {
|
@theme {
|
||||||
--font-inter: var(--font-inter);
|
--font-inter: var(--font-inter);
|
||||||
--font-roboto: var(--font-roboto);
|
|
||||||
|
|
||||||
--container-sm: 40rem;
|
--container-sm: 40rem;
|
||||||
--container-md: 48rem;
|
--container-md: 48rem;
|
||||||
--container-lg: 64rem;
|
--container-lg: 64rem;
|
||||||
--container-xl: 80rem;
|
--container-xl: 80rem;
|
||||||
--container-2xl: 96rem;
|
--container-2xl: 96rem;
|
||||||
|
|
||||||
--shadow-button-soft:
|
|
||||||
0 3px 2px -2px var(--color-base-200), 0 4px 3px -2px var(--color-base-200);
|
|
||||||
|
|
||||||
--shadow-bg: 0px -2px 4px 0px #00000014;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import InventoryAdjustmentTable from '@/components/pages/inventory/adjustment/In
|
|||||||
|
|
||||||
const InventoryAdjustment = () => {
|
const InventoryAdjustment = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full'>
|
<section className='w-full p-4'>
|
||||||
<InventoryAdjustmentTable />
|
<InventoryAdjustmentTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import MovementTable from '@/components/pages/inventory/movement/MovementTable';
|
|||||||
|
|
||||||
const Movement = () => {
|
const Movement = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4 sm:p-0'>
|
<section className='w-full p-4'>
|
||||||
<MovementTable />
|
<MovementTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
+2
-12
@@ -1,9 +1,8 @@
|
|||||||
import type { Metadata, Viewport } from 'next';
|
import type { Metadata, Viewport } from 'next';
|
||||||
import { Inter, Roboto } from 'next/font/google';
|
import { Inter } from 'next/font/google';
|
||||||
import '@/app/globals.css';
|
import '@/app/globals.css';
|
||||||
|
|
||||||
import { Toaster } from 'react-hot-toast';
|
import { Toaster } from 'react-hot-toast';
|
||||||
import { Toaster as SonnerToaster } from '@/figma-make/components/base/sonner';
|
|
||||||
import MainDrawer from '@/components/MainDrawer';
|
import MainDrawer from '@/components/MainDrawer';
|
||||||
import RequireAuth from '@/components/helper/RequireAuth';
|
import RequireAuth from '@/components/helper/RequireAuth';
|
||||||
|
|
||||||
@@ -12,12 +11,6 @@ const inter = Inter({
|
|||||||
subsets: ['latin'],
|
subsets: ['latin'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const roboto = Roboto({
|
|
||||||
variable: '--font-roboto',
|
|
||||||
subsets: ['latin'],
|
|
||||||
weight: ['200', '300', '400', '500', '600', '700', '900'],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const viewport: Viewport = {
|
export const viewport: Viewport = {
|
||||||
themeColor: '#1f74bf',
|
themeColor: '#1f74bf',
|
||||||
colorScheme: 'light',
|
colorScheme: 'light',
|
||||||
@@ -36,15 +29,12 @@ export default function RootLayout({
|
|||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<html lang='en' data-theme='lti'>
|
<html lang='en' data-theme='lti'>
|
||||||
<body
|
<body className={`${inter.variable} antialiased font-inter`}>
|
||||||
className={`${inter.variable} ${roboto.variable} antialiased font-inter`}
|
|
||||||
>
|
|
||||||
<RequireAuth>
|
<RequireAuth>
|
||||||
<MainDrawer>{children}</MainDrawer>
|
<MainDrawer>{children}</MainDrawer>
|
||||||
</RequireAuth>
|
</RequireAuth>
|
||||||
|
|
||||||
<Toaster />
|
<Toaster />
|
||||||
<SonnerToaster position='top-right' />
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
|
||||||
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
import { MarketingApi } from '@/services/api/marketing/marketing';
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
const EditMarketingDelivery = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const soId = searchParams.get('marketingId');
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: marketing,
|
||||||
|
isLoading: isLoading,
|
||||||
|
mutate: refreshMarketing,
|
||||||
|
} = useSWR(`get-so-${soId}`, () =>
|
||||||
|
MarketingApi.getSingle(soId ? parseInt(soId) : 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!soId) {
|
||||||
|
router.back();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLoading && (!marketing || isResponseError(marketing))) {
|
||||||
|
router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4'>
|
||||||
|
{isLoading && <span className='loading loading-spinner loading-xl' />}
|
||||||
|
{!isLoading && isResponseSuccess(marketing) && (
|
||||||
|
<MarketingForm
|
||||||
|
formType='add_deliver'
|
||||||
|
initialValues={marketing.data}
|
||||||
|
afterSubmit={() => {
|
||||||
|
refreshMarketing();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default EditMarketingDelivery;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
|
||||||
|
|
||||||
|
const AddSalesOrder = () => {
|
||||||
|
return (
|
||||||
|
<div className='size-full p-4'>
|
||||||
|
<MarketingForm formType='add' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddSalesOrder;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
|
const Layout = ({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) => {
|
||||||
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Layout;
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
|
||||||
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
import { MarketingApi } from '@/services/api/marketing/marketing';
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
const EditMarketingDelivery = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const soId = searchParams.get('marketingId');
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: marketing,
|
||||||
|
isLoading: isLoading,
|
||||||
|
mutate: refreshMarketing,
|
||||||
|
} = useSWR(`get-so-${soId}`, () =>
|
||||||
|
MarketingApi.getSingle(soId ? parseInt(soId) : 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!soId) {
|
||||||
|
router.back();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLoading && (!marketing || isResponseError(marketing))) {
|
||||||
|
router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
isResponseSuccess(marketing) &&
|
||||||
|
marketing.data.latest_approval.step_number != 3
|
||||||
|
) {
|
||||||
|
toast.error('Data Marketing perlu dilakukan approval terlebih dahulu!');
|
||||||
|
router.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4'>
|
||||||
|
{isLoading && <span className='loading loading-spinner loading-xl' />}
|
||||||
|
{!isLoading && isResponseSuccess(marketing) && (
|
||||||
|
<MarketingForm
|
||||||
|
formType='edit_deliver'
|
||||||
|
initialValues={marketing.data}
|
||||||
|
afterSubmit={() => {
|
||||||
|
refreshMarketing();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default EditMarketingDelivery;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
|
const Layout = ({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) => {
|
||||||
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Layout;
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import MarketingDetail from '@/components/pages/marketing/detail/MarketingDetail';
|
||||||
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
import { MarketingApi } from '@/services/api/marketing/marketing';
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
const DetailMarketing = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const soId = searchParams.get('marketingId');
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: marketing,
|
||||||
|
isLoading: isLoading,
|
||||||
|
mutate: refreshMarketing,
|
||||||
|
} = useSWR(soId, (id: number) => MarketingApi.getSingle(id));
|
||||||
|
|
||||||
|
if (!soId) {
|
||||||
|
router.back();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLoading && (!marketing || isResponseError(marketing))) {
|
||||||
|
router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4'>
|
||||||
|
{isLoading && <span className='loading loading-spinner loading-xl' />}
|
||||||
|
{!isLoading && isResponseSuccess(marketing) && (
|
||||||
|
<MarketingDetail
|
||||||
|
initialValues={marketing.data}
|
||||||
|
refresh={refreshMarketing}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DetailMarketing;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
|
const Layout = ({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) => {
|
||||||
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Layout;
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
|
||||||
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
import { MarketingApi } from '@/services/api/marketing/marketing';
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
const EditSalesOrder = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const soId = searchParams.get('marketingId');
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: marketing,
|
||||||
|
isLoading: isLoading,
|
||||||
|
mutate: refreshMarketing,
|
||||||
|
} = useSWR(`get-so-${soId}`, () =>
|
||||||
|
MarketingApi.getSingle(soId ? parseInt(soId) : 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!soId) {
|
||||||
|
router.back();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLoading && (!marketing || isResponseError(marketing))) {
|
||||||
|
router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4'>
|
||||||
|
{isLoading && <span className='loading loading-spinner loading-xl' />}
|
||||||
|
{!isLoading && isResponseSuccess(marketing) && (
|
||||||
|
<MarketingForm
|
||||||
|
formType='edit'
|
||||||
|
initialValues={marketing.data}
|
||||||
|
afterSubmit={() => {
|
||||||
|
refreshMarketing();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default EditSalesOrder;
|
||||||
@@ -1,14 +1,9 @@
|
|||||||
import DeliveryOrderFormModal from '@/components/pages/marketing/DeliveryOrderFormModal';
|
|
||||||
import MarketingTable from '@/components/pages/marketing/MarketingTable';
|
import MarketingTable from '@/components/pages/marketing/MarketingTable';
|
||||||
import SalesOrderFormModal from '@/components/pages/marketing/SalesOrderFormModal';
|
|
||||||
|
|
||||||
const Marketing = () => {
|
const Marketing = () => {
|
||||||
return (
|
return (
|
||||||
<div className='w-full'>
|
<div className='w-full p-4'>
|
||||||
<MarketingTable />
|
<MarketingTable />
|
||||||
|
|
||||||
<SalesOrderFormModal />
|
|
||||||
<DeliveryOrderFormModal />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import AreasTable from '@/components/pages/master-data/area/AreasTable';
|
import AreasTable from '@/components/pages/master-data/area/AreasTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return <AreasTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<AreasTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import BanksTable from '@/components/pages/master-data/bank/BanksTable';
|
import BanksTable from '@/components/pages/master-data/bank/BanksTable';
|
||||||
|
|
||||||
const Bank = () => {
|
const Bank = () => {
|
||||||
return <BanksTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<BanksTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Bank;
|
export default Bank;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import CustomersTable from '@/components/pages/master-data/customer/CustomersTable';
|
import CustomersTable from '@/components/pages/master-data/customer/CustomersTable';
|
||||||
|
|
||||||
const Customer = () => {
|
const Customer = () => {
|
||||||
return <CustomersTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<CustomersTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Customer;
|
export default Customer;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import FcrForm from '@/components/pages/master-data/fcr/form/FcrForm';
|
||||||
|
|
||||||
|
const AddFcr = () => {
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
|
<FcrForm />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddFcr;
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
import FcrForm from '@/components/pages/master-data/fcr/form/FcrForm';
|
||||||
|
|
||||||
|
import { FcrApi } from '@/services/api/master-data';
|
||||||
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
|
import { FcrWithStandards } from '@/types/api/master-data/fcr';
|
||||||
|
|
||||||
|
const FcrEdit = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const fcrId = searchParams.get('fcrId');
|
||||||
|
|
||||||
|
const { data: fcr, isLoading: isLoadingFcr } = useSWR(
|
||||||
|
fcrId,
|
||||||
|
(id: number) =>
|
||||||
|
FcrApi.getSingle(id) as Promise<
|
||||||
|
BaseApiResponse<FcrWithStandards> | undefined
|
||||||
|
>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!fcrId) {
|
||||||
|
router.back();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLoadingFcr && (!fcr || isResponseError(fcr))) {
|
||||||
|
router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
|
{isLoadingFcr && <span className='loading loading-spinner loading-xl' />}
|
||||||
|
{!isLoadingFcr && isResponseSuccess(fcr) && (
|
||||||
|
<FcrForm type='edit' initialValues={fcr.data} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FcrEdit;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
|
const Layout = ({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) => {
|
||||||
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Layout;
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
import FcrForm from '@/components/pages/master-data/fcr/form/FcrForm';
|
||||||
|
|
||||||
|
import { FcrApi } from '@/services/api/master-data';
|
||||||
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
import { FcrWithStandards } from '@/types/api/master-data/fcr';
|
||||||
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
|
|
||||||
|
const FcrDetail = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const fcrId = searchParams.get('fcrId');
|
||||||
|
|
||||||
|
const { data: fcr, isLoading: isLoadingFcr } = useSWR(
|
||||||
|
fcrId,
|
||||||
|
(id: number) =>
|
||||||
|
FcrApi.getSingle(id) as Promise<
|
||||||
|
BaseApiResponse<FcrWithStandards> | undefined
|
||||||
|
>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!fcrId) {
|
||||||
|
router.back();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLoadingFcr && (!fcr || isResponseError(fcr))) {
|
||||||
|
router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
|
{isLoadingFcr && <span className='loading loading-spinner loading-xl' />}
|
||||||
|
{!isLoadingFcr && isResponseSuccess(fcr) && (
|
||||||
|
<FcrForm type='detail' initialValues={fcr.data} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FcrDetail;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import FcrsTable from '@/components/pages/master-data/fcr/FcrsTable';
|
||||||
|
|
||||||
|
const Fcr = () => {
|
||||||
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<FcrsTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Fcr;
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
import FlockTable from '@/components/pages/master-data/flock/FlocksTable';
|
import FlockTable from '@/components/pages/master-data/flock/FlocksTable';
|
||||||
|
|
||||||
const Flock = () => {
|
const Flock = () => {
|
||||||
return <FlockTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<FlockTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Flock;
|
export default Flock;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import KandangsTable from '@/components/pages/master-data/kandang/KandangsTable';
|
import KandangsTable from '@/components/pages/master-data/kandang/KandangsTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return <KandangsTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<KandangsTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import LocationsTable from '@/components/pages/master-data/location/LocationsTable';
|
import LocationsTable from '@/components/pages/master-data/location/LocationsTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return <LocationsTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<LocationsTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import NonstocksTable from '@/components/pages/master-data/nonstock/NonstocksTable';
|
import NonstocksTable from '@/components/pages/master-data/nonstock/NonstocksTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return <NonstocksTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<NonstocksTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import ProductCategoryTable from '@/components/pages/master-data/product-category/ProductCategoryTable';
|
import ProductCategoryTable from '@/components/pages/master-data/product-category/ProductCategoryTable';
|
||||||
|
|
||||||
const ProductCategory = () => {
|
const ProductCategory = () => {
|
||||||
return <ProductCategoryTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<ProductCategoryTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProductCategory;
|
export default ProductCategory;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import ProductsTable from '@/components/pages/master-data/product/ProductTable';
|
import ProductsTable from '@/components/pages/master-data/product/ProductTable';
|
||||||
|
|
||||||
const Product = () => {
|
const Product = () => {
|
||||||
return <ProductsTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<ProductsTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Product;
|
export default Product;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import ProductionStandardTable from '@/components/pages/master-data/production-standard/ProductionStandardTable';
|
import ProductionStandardTable from '@/components/pages/master-data/production-standard/ProductionStandardTable';
|
||||||
|
|
||||||
const ProductionStandardPage = () => {
|
const ProductionStandardPage = () => {
|
||||||
return <ProductionStandardTable />;
|
return (
|
||||||
|
<div className='w-full'>
|
||||||
|
<ProductionStandardTable />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProductionStandardPage;
|
export default ProductionStandardPage;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import SuppliersTable from '@/components/pages/master-data/supplier/SupplierTable';
|
import SuppliersTable from '@/components/pages/master-data/supplier/SupplierTable';
|
||||||
|
|
||||||
const Supplier = () => {
|
const Supplier = () => {
|
||||||
return <SuppliersTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<SuppliersTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Supplier;
|
export default Supplier;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import UomsTable from '@/components/pages/master-data/uom/UomsTable';
|
import UomsTable from '@/components/pages/master-data/uom/UomsTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return <UomsTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<UomsTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import WarehousesTable from '@/components/pages/master-data/warehouse/WarehousesTable';
|
import WarehousesTable from '@/components/pages/master-data/warehouse/WarehousesTable';
|
||||||
|
|
||||||
const Warehouse = () => {
|
const Warehouse = () => {
|
||||||
return <WarehousesTable />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<WarehousesTable />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Warehouse;
|
export default Warehouse;
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
import PageNotFound from '@/components/helper/NotFoundPage';
|
|
||||||
|
|
||||||
export default function NotFound() {
|
|
||||||
return <PageNotFound />;
|
|
||||||
}
|
|
||||||
+3
-6
@@ -3,9 +3,10 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { usePathname, useRouter } from 'next/navigation';
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
import { useAuth } from '@/services/hooks/useAuth';
|
import { useAuth } from '@/services/hooks/useAuth';
|
||||||
|
import { redirectToSSO } from '@/lib/auth-helper';
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const { isLoadingUser } = useAuth();
|
const { user, isLoadingUser } = useAuth();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
@@ -24,9 +25,5 @@ export default function Home() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return <>Loading...</>;
|
||||||
<main className='w-full h-full min-h-screen flex flex-row justify-center items-center'>
|
|
||||||
<span className='loading loading-spinner loading-lg'></span>
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
|
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
|
||||||
import React from 'react';
|
import React, { useImperativeHandle } from 'react';
|
||||||
// import React, { useImperativeHandle } from 'react';
|
import toast from 'react-hot-toast';
|
||||||
|
|
||||||
const AddProjectFlock = () => {
|
const AddProjectFlock = () => {
|
||||||
// useImperativeHandle(ref, () => ({
|
// useImperativeHandle(ref, () => ({
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ const ProjectFlockEdit = () => {
|
|||||||
|
|
||||||
const projectFlockId = searchParams.get('projectFlockId');
|
const projectFlockId = searchParams.get('projectFlockId');
|
||||||
|
|
||||||
const { data: projectFlock, isLoading: isLoadingProjectFlock } = useSWR(
|
const {
|
||||||
projectFlockId,
|
data: projectFlock,
|
||||||
(id: number) => ProjectFlockApi.getSingle(id)
|
isLoading: isLoadingProjectFlock,
|
||||||
);
|
mutate: refreshProjectFlocks,
|
||||||
|
} = useSWR(projectFlockId, (id: number) => ProjectFlockApi.getSingle(id));
|
||||||
|
|
||||||
if (!projectFlockId) {
|
if (!projectFlockId) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import ProjectFlockDetail from '@/components/pages/production/project-flock/detail/ProjectFlockDetail';
|
import ProjectFlockDetail from '@/components/pages/production/project-flock/detail/ProjectFlockDetail';
|
||||||
|
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { ProjectFlockApi } from '@/services/api/production/project-flock';
|
import { ProjectFlockApi } from '@/services/api/production/project-flock';
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
@@ -12,10 +13,11 @@ const ProjectFlockDetailPage = () => {
|
|||||||
|
|
||||||
const projectFlockId = searchParams.get('projectFlockId');
|
const projectFlockId = searchParams.get('projectFlockId');
|
||||||
|
|
||||||
const { data: projectFlock, isLoading: isLoadingProjectFlock } = useSWR(
|
const {
|
||||||
projectFlockId,
|
data: projectFlock,
|
||||||
(id: number) => ProjectFlockApi.getSingle(id)
|
isLoading: isLoadingProjectFlock,
|
||||||
);
|
mutate: refreshProjectFlock,
|
||||||
|
} = useSWR(projectFlockId, (id: number) => ProjectFlockApi.getSingle(id));
|
||||||
|
|
||||||
if (!projectFlockId) {
|
if (!projectFlockId) {
|
||||||
router.back();
|
router.back();
|
||||||
@@ -48,3 +50,5 @@ const ProjectFlockDetailPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default ProjectFlockDetailPage;
|
export default ProjectFlockDetailPage;
|
||||||
|
ProjectFlockDetail;
|
||||||
|
ProjectFlockDetail;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { usePathname, useRouter } from 'next/navigation';
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
import React, { ReactNode, useEffect } from 'react';
|
import Drawer from '@/components/Drawer';
|
||||||
|
import React, { ReactNode } from 'react';
|
||||||
import ProjectFlockTable from '@/components/pages/production/project-flock/ProjectFlockTable';
|
import ProjectFlockTable from '@/components/pages/production/project-flock/ProjectFlockTable';
|
||||||
import { useUiStore } from '@/stores/ui/ui.store';
|
import { useUiStore } from '@/stores/ui/ui.store';
|
||||||
import Modal, { useModal } from '@/components/Modal';
|
|
||||||
|
|
||||||
export default function ProjectFlockLayout({
|
export default function ProjectFlockLayout({
|
||||||
children,
|
children,
|
||||||
@@ -23,12 +23,9 @@ export default function ProjectFlockLayout({
|
|||||||
|
|
||||||
const isOpen = isAdd || isEdit || isDetail || isChickin || isClosing;
|
const isOpen = isAdd || isEdit || isDetail || isChickin || isClosing;
|
||||||
|
|
||||||
const formModal = useModal();
|
|
||||||
|
|
||||||
const handleBackdropClick = () => {
|
const handleBackdropClick = () => {
|
||||||
const unsub = useUiStore.getState().subscribeIsValid((isValid) => {
|
const unsub = useUiStore.getState().subscribeIsValid((isValid) => {
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
formModal.closeModal();
|
|
||||||
unsub(); // berhenti listen
|
unsub(); // berhenti listen
|
||||||
router.push('/production/project-flock');
|
router.push('/production/project-flock');
|
||||||
}
|
}
|
||||||
@@ -37,14 +34,6 @@ export default function ProjectFlockLayout({
|
|||||||
toggleValidate();
|
toggleValidate();
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isOpen && !formModal.open) {
|
|
||||||
formModal.openModal();
|
|
||||||
} else {
|
|
||||||
formModal.closeModal();
|
|
||||||
}
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* List page always rendered */}
|
{/* List page always rendered */}
|
||||||
@@ -54,19 +43,18 @@ export default function ProjectFlockLayout({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Render Modal only on /add */}
|
{/* Render Drawer only on /add */}
|
||||||
<Modal
|
<Drawer
|
||||||
ref={formModal.ref}
|
open={isOpen}
|
||||||
position='end'
|
setOpen={(v) => {
|
||||||
onBackdropClick={handleBackdropClick}
|
if (!v) router.push('/production/project-flock');
|
||||||
className={{
|
|
||||||
modalBox: 'w-full sm:w-fit p-3 rounded-xl bg-transparent shadow-none',
|
|
||||||
}}
|
}}
|
||||||
>
|
closeOnBackdropClick={isDetail ? true : false}
|
||||||
<div className='w-full sm:w-[446px] h-full flex flex-col sm:flex-row items-stretch bg-base-100 rounded-xl overflow-hidden'>
|
onBackdropClick={handleBackdropClick}
|
||||||
{isOpen && children}
|
variant='right'
|
||||||
</div>
|
zIndex='99999'
|
||||||
</Modal>
|
sidebarContent={isOpen && <div className=''>{children}</div>}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,10 @@ const RecordingEdit = () => {
|
|||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
const recordingId = searchParams.get('recordingId');
|
const recordingId = searchParams.get('recordingId');
|
||||||
const recordingDetailKey = recordingId
|
|
||||||
? ['recording-detail', recordingId]
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const { data: recording, isLoading: isLoadingRecording } = useSWR(
|
const { data: recording, isLoading: isLoadingRecording } = useSWR(
|
||||||
recordingDetailKey,
|
recordingId,
|
||||||
([, id]: [string, string]) => RecordingApi.getSingle(parseInt(id))
|
(id: string) => RecordingApi.getSingle(parseInt(id))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!recordingId) {
|
if (!recordingId) {
|
||||||
|
|||||||
@@ -11,13 +11,10 @@ const RecordingDetail = () => {
|
|||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
const recordingId = searchParams.get('recordingId');
|
const recordingId = searchParams.get('recordingId');
|
||||||
const recordingDetailKey = recordingId
|
|
||||||
? ['recording-detail', recordingId]
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const { data: recording, isLoading: isLoadingRecording } = useSWR(
|
const { data: recording, isLoading: isLoadingRecording } = useSWR(
|
||||||
recordingDetailKey,
|
recordingId,
|
||||||
([, id]: [string, string]) => RecordingApi.getSingle(parseInt(id))
|
(id: string) => RecordingApi.getSingle(parseInt(id))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!recordingId) {
|
if (!recordingId) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import RecordingTable from '@/components/pages/production/recording/RecordingTab
|
|||||||
|
|
||||||
const Recording = () => {
|
const Recording = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full'>
|
<section className='w-full p-4'>
|
||||||
<RecordingTable />
|
<RecordingTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import TransferToLayingForm from '@/components/pages/production/transfer-to-laying/form/TransferToLayingForm';
|
||||||
|
|
||||||
|
const AddTransferToLaying = () => {
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
|
<TransferToLayingForm />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddTransferToLaying;
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
import TransferToLayingForm from '@/components/pages/production/transfer-to-laying/form/TransferToLayingForm';
|
||||||
|
|
||||||
|
import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying';
|
||||||
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
|
const TransferToLayingEdit = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const transferToLayingId = searchParams.get('transferToLayingId');
|
||||||
|
|
||||||
|
const { data: transferToLaying, isLoading: isLoadingTransferToLaying } =
|
||||||
|
useSWR(transferToLayingId, (id: number) =>
|
||||||
|
TransferToLayingApi.getSingle(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!transferToLayingId) {
|
||||||
|
router.back();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!isLoadingTransferToLaying &&
|
||||||
|
(!transferToLaying || isResponseError(transferToLaying))
|
||||||
|
) {
|
||||||
|
router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
isResponseSuccess(transferToLaying) &&
|
||||||
|
transferToLaying.data.approval.step_number === 2
|
||||||
|
) {
|
||||||
|
router.replace('/production/transfer-to-laying');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
|
{isLoadingTransferToLaying && (
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
)}
|
||||||
|
{!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
|
||||||
|
<TransferToLayingForm
|
||||||
|
type='edit'
|
||||||
|
initialValues={transferToLaying.data}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TransferToLayingEdit;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
|
const Layout = ({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) => {
|
||||||
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Layout;
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
import TransferToLayingForm from '@/components/pages/production/transfer-to-laying/form/TransferToLayingForm';
|
||||||
|
|
||||||
|
import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying';
|
||||||
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
|
const TransferToLayingDetail = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const transferToLayingId = searchParams.get('transferToLayingId');
|
||||||
|
|
||||||
|
const { data: transferToLaying, isLoading: isLoadingTransferToLaying } =
|
||||||
|
useSWR(transferToLayingId, (id: number) =>
|
||||||
|
TransferToLayingApi.getSingle(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!transferToLayingId) {
|
||||||
|
router.back();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!isLoadingTransferToLaying &&
|
||||||
|
(!transferToLaying || isResponseError(transferToLaying))
|
||||||
|
) {
|
||||||
|
router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
|
{isLoadingTransferToLaying && (
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
|
||||||
|
<TransferToLayingForm
|
||||||
|
type='detail'
|
||||||
|
initialValues={transferToLaying.data}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TransferToLayingDetail;
|
||||||
@@ -1,25 +1,9 @@
|
|||||||
import TransferToLayingsTable from '@/components/pages/production/transfer-to-laying/TransferToLayingsTable';
|
import TransferToLayingsTable from '@/components/pages/production/transfer-to-laying/TransferToLayingsTable';
|
||||||
import TransferToLayingFormModal from '@/components/pages/production/transfer-to-laying/TransferToLayingFormModal';
|
|
||||||
import TransferToLayingDetailModal from '@/components/pages/production/transfer-to-laying/TransferToLayingDetailModal';
|
|
||||||
import RequirePermission from '@/components/helper/RequirePermission';
|
|
||||||
|
|
||||||
const TransferToLaying = () => {
|
const TransferToLaying = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full'>
|
<section className='w-full p-4'>
|
||||||
<TransferToLayingsTable />
|
<TransferToLayingsTable />
|
||||||
|
|
||||||
<RequirePermission
|
|
||||||
permissions={[
|
|
||||||
'lti.production.transfer_to_laying.create',
|
|
||||||
'lti.production.transfer_to_laying.update',
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<TransferToLayingFormModal />
|
|
||||||
</RequirePermission>
|
|
||||||
|
|
||||||
<RequirePermission permissions='lti.production.transfer_to_laying.detail'>
|
|
||||||
<TransferToLayingDetailModal />
|
|
||||||
</RequirePermission>
|
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
import UniformityForm from '@/components/pages/production/uniformity/form/UniformityForm';
|
|
||||||
|
|
||||||
const AddUniformity = () => {
|
|
||||||
return <UniformityForm formType='add' />;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AddUniformity;
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import UniformityDetail from '@/components/pages/production/uniformity/detail/UniformityDetail';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
|
||||||
import { UniformityApi } from '@/services/api/uniformity';
|
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
|
||||||
import useSWR from 'swr';
|
|
||||||
|
|
||||||
const UniformityDetailPage = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
const uniformityId = searchParams.get('uniformityId');
|
|
||||||
|
|
||||||
const { data: uniformity, isLoading: isLoadingUniformity } = useSWR(
|
|
||||||
uniformityId,
|
|
||||||
(id: string) => UniformityApi.getUniformityDetail(parseInt(id))
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!uniformityId) {
|
|
||||||
router.back();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full flex flex-row justify-center items-center p-4'>
|
|
||||||
<span className='loading loading-spinner loading-xl' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isLoadingUniformity && (!uniformity || isResponseError(uniformity))) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full h-full flex flex-col justify-center'>
|
|
||||||
{isLoadingUniformity && (
|
|
||||||
<div className='w-full flex flex-row justify-center items-center p-4 min-h-screen'>
|
|
||||||
<span className='loading loading-spinner loading-xl' />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{isResponseSuccess(uniformity) && (
|
|
||||||
<UniformityDetail initialValues={uniformity.data} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default UniformityDetailPage;
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { ReactNode } from 'react';
|
|
||||||
import UniformityPageWrapper from '@/components/pages/production/uniformity/UniformityPageWrapper';
|
|
||||||
|
|
||||||
export default function UniformityLayout({
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: ReactNode;
|
|
||||||
}) {
|
|
||||||
return <UniformityPageWrapper>{children}</UniformityPageWrapper>;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import UniformityTable from '@/components/pages/production/uniformity/UniformityTable';
|
|
||||||
|
|
||||||
const Uniformity = () => {
|
|
||||||
return <UniformityTable />;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Uniformity;
|
|
||||||
@@ -2,7 +2,7 @@ import PurchaseTable from '@/components/pages/purchase/PurchaseTable';
|
|||||||
|
|
||||||
const Purchase = () => {
|
const Purchase = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4 sm:p-0'>
|
<section className='w-full p-4'>
|
||||||
<PurchaseTable />
|
<PurchaseTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import ReportExpenseTabs from '@/components/pages/report/expense/ReportExpenseTabs';
|
import ReportExpenseTable from '@/components/pages/report/expense/ReportExpenseTable';
|
||||||
|
|
||||||
const ReportExpense = () => {
|
const ReportExpense = () => {
|
||||||
return <ReportExpenseTabs />;
|
return (
|
||||||
|
<div className='w-full p-4'>
|
||||||
|
<ReportExpenseTable />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ReportExpense;
|
export default ReportExpense;
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
import FinanceTabs from '@/components/pages/report/finance/FinanceTabs';
|
|
||||||
|
|
||||||
const Finance = () => {
|
|
||||||
return <FinanceTabs />;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Finance;
|
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
import MarketingReportContent from '@/components/pages/report/marketing/MarketingTabs';
|
import MarketingReportContent from '@/components/pages/report/MarketingReportContent';
|
||||||
|
|
||||||
const MarketingReportPage = () => {
|
const MarketingReportPage = () => {
|
||||||
return <MarketingReportContent />;
|
return (
|
||||||
|
<section className='w-full p-4'>
|
||||||
|
<MarketingReportContent />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MarketingReportPage;
|
export default MarketingReportPage;
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import ProductionResultTabs from '@/components/pages/report/production-result/ProductionResultTabs';
|
|
||||||
|
|
||||||
const ProductionResultReportPage = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full max-w-full'>
|
|
||||||
<ProductionResultTabs />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ProductionResultReportPage;
|
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
import { ReactNode, Ref } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
|
|
||||||
interface AlertProps {
|
interface AlertProps {
|
||||||
ref?: Ref<HTMLDivElement> | undefined;
|
|
||||||
variant?: 'outline' | 'dash' | 'soft';
|
variant?: 'outline' | 'dash' | 'soft';
|
||||||
color?: 'info' | 'success' | 'warning' | 'error';
|
color?: 'info' | 'success' | 'warning' | 'error';
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Alert = ({ children, ref, variant, color, className }: AlertProps) => {
|
const Alert = ({ children, variant, color, className }: AlertProps) => {
|
||||||
const alertBaseClassName = cn('alert', {
|
const alertBaseClassName = cn('alert', {
|
||||||
'alert-soft': variant === 'soft',
|
'alert-soft': variant === 'soft',
|
||||||
'alert-outline': variant === 'outline',
|
'alert-outline': variant === 'outline',
|
||||||
@@ -22,11 +21,7 @@ const Alert = ({ children, ref, variant, color, className }: AlertProps) => {
|
|||||||
'alert-error': color === 'error',
|
'alert-error': color === 'error',
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return <div className={cn(alertBaseClassName, className)}>{children}</div>;
|
||||||
<div ref={ref} className={cn(alertBaseClassName, className)}>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Alert;
|
export default Alert;
|
||||||
|
|||||||
+14
-34
@@ -3,25 +3,29 @@
|
|||||||
import { HTMLAttributes, ReactNode } from 'react';
|
import { HTMLAttributes, ReactNode } from 'react';
|
||||||
|
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
import type { Color, Variant, Size } from '@/types/theme';
|
|
||||||
|
|
||||||
export interface BadgeProps
|
export interface BadgeProps
|
||||||
extends Omit<HTMLAttributes<HTMLSpanElement>, 'className'> {
|
extends Omit<HTMLAttributes<HTMLSpanElement>, 'className'> {
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
className?: {
|
className?: {
|
||||||
badge?: string;
|
badge?: string;
|
||||||
status?: string;
|
|
||||||
};
|
};
|
||||||
statusIndicator?: boolean;
|
variant?: 'default' | 'outline' | 'ghost' | 'soft' | 'dash';
|
||||||
variant?: Variant;
|
color?:
|
||||||
color?: Color;
|
| 'neutral'
|
||||||
size?: Size;
|
| 'primary'
|
||||||
|
| 'secondary'
|
||||||
|
| 'accent'
|
||||||
|
| 'info'
|
||||||
|
| 'success'
|
||||||
|
| 'warning'
|
||||||
|
| 'error';
|
||||||
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
||||||
}
|
}
|
||||||
|
|
||||||
const Badge = ({
|
const Badge = ({
|
||||||
children,
|
children,
|
||||||
className,
|
className,
|
||||||
statusIndicator = false,
|
|
||||||
variant = 'default',
|
variant = 'default',
|
||||||
color,
|
color,
|
||||||
size = 'md',
|
size = 'md',
|
||||||
@@ -30,7 +34,7 @@ const Badge = ({
|
|||||||
const getBadgeClasses = () => {
|
const getBadgeClasses = () => {
|
||||||
const baseClasses = 'badge';
|
const baseClasses = 'badge';
|
||||||
|
|
||||||
const variantClasses: Record<Variant, string> = {
|
const variantClasses = {
|
||||||
default: '',
|
default: '',
|
||||||
outline: 'badge-outline',
|
outline: 'badge-outline',
|
||||||
ghost: 'badge-ghost',
|
ghost: 'badge-ghost',
|
||||||
@@ -38,7 +42,7 @@ const Badge = ({
|
|||||||
dash: 'badge-dash',
|
dash: 'badge-dash',
|
||||||
};
|
};
|
||||||
|
|
||||||
const colorClasses: Record<Color, string> = {
|
const colorClasses = {
|
||||||
neutral: 'badge-neutral',
|
neutral: 'badge-neutral',
|
||||||
primary: 'badge-primary',
|
primary: 'badge-primary',
|
||||||
secondary: 'badge-secondary',
|
secondary: 'badge-secondary',
|
||||||
@@ -47,10 +51,9 @@ const Badge = ({
|
|||||||
success: 'badge-success',
|
success: 'badge-success',
|
||||||
warning: 'badge-warning',
|
warning: 'badge-warning',
|
||||||
error: 'badge-error',
|
error: 'badge-error',
|
||||||
none: '',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const sizeClasses: Record<Size, string> = {
|
const sizeClasses = {
|
||||||
xs: 'badge-xs',
|
xs: 'badge-xs',
|
||||||
sm: 'badge-sm',
|
sm: 'badge-sm',
|
||||||
md: 'badge-md',
|
md: 'badge-md',
|
||||||
@@ -67,31 +70,8 @@ const Badge = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStatusClasses = () => {
|
|
||||||
if (!statusIndicator) return '';
|
|
||||||
|
|
||||||
const statusIndicatorClasses: Record<Color, string> = {
|
|
||||||
neutral: 'bg-neutral',
|
|
||||||
primary: 'bg-primary',
|
|
||||||
secondary: 'bg-secondary',
|
|
||||||
accent: 'bg-accent',
|
|
||||||
info: 'bg-info',
|
|
||||||
success: 'bg-success',
|
|
||||||
warning: 'bg-warning',
|
|
||||||
error: 'bg-error',
|
|
||||||
none: '',
|
|
||||||
};
|
|
||||||
|
|
||||||
return cn(
|
|
||||||
'w-2.5 h-2.5 rounded-full',
|
|
||||||
color && statusIndicatorClasses[color],
|
|
||||||
className?.status
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={getBadgeClasses()} {...props}>
|
<span className={getBadgeClasses()} {...props}>
|
||||||
{statusIndicator && <span className={getStatusClasses()} />}
|
|
||||||
{children}
|
{children}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,263 +0,0 @@
|
|||||||
import React, { useId } from 'react';
|
|
||||||
import Link from 'next/link';
|
|
||||||
import { Icon } from '@iconify/react';
|
|
||||||
import { cn, findMenuPath } from '@/lib/helper';
|
|
||||||
import { Size } from '@/types/theme';
|
|
||||||
import Button from '@/components/Button';
|
|
||||||
import { MAIN_DRAWER_LINKS } from '@/config/constant';
|
|
||||||
|
|
||||||
interface BreadcrumbItem {
|
|
||||||
label: string;
|
|
||||||
href?: string;
|
|
||||||
icon?: React.ReactNode;
|
|
||||||
isActive?: boolean;
|
|
||||||
isDisabled?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BreadcrumbsProps extends React.HTMLAttributes<HTMLElement> {
|
|
||||||
items: BreadcrumbItem[];
|
|
||||||
size?: Size;
|
|
||||||
maxVisibleItems?: number;
|
|
||||||
showEllipsisDropdown?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function buildBreadcrumbs(pathname: string): BreadcrumbItem[] {
|
|
||||||
const menuPath = findMenuPath(MAIN_DRAWER_LINKS, pathname);
|
|
||||||
|
|
||||||
if (!menuPath) return [];
|
|
||||||
|
|
||||||
return menuPath.map((menu, index) => {
|
|
||||||
const isLast = index === menuPath.length - 1;
|
|
||||||
|
|
||||||
return {
|
|
||||||
label: menu.text,
|
|
||||||
href: isLast ? menu.link : undefined,
|
|
||||||
isActive: isLast,
|
|
||||||
icon: menu.icon ? (
|
|
||||||
<Icon icon={menu.icon} width={16} height={16} />
|
|
||||||
) : undefined,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const EllipsisDropdown = ({
|
|
||||||
hiddenItems,
|
|
||||||
}: {
|
|
||||||
hiddenItems: BreadcrumbItem[];
|
|
||||||
}) => {
|
|
||||||
const dropdownId = useId();
|
|
||||||
const anchorId = useId();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<li>
|
|
||||||
{/* Ellipsis Button */}
|
|
||||||
<Button
|
|
||||||
popoverTarget={dropdownId}
|
|
||||||
variant='ghost'
|
|
||||||
color='none'
|
|
||||||
style={
|
|
||||||
{
|
|
||||||
anchorName: `--breadcrumb-ellipsis-anchor-${anchorId}`,
|
|
||||||
} as React.CSSProperties
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Icon icon='material-symbols:more-horiz' width={16} height={16} />
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
{/* Dropdown Menu using popover API */}
|
|
||||||
<ul
|
|
||||||
className='dropdown menu rounded-box bg-base-100 border border-base-300 shadow-lg z-[9999] [&_a:hover]:no-underline [&_a:focus]:no-underline [&&]:no-underline [&&_a]:no-underline [&&]:hover:no-underline [&&]:flex [&&]:items-start [&&]:justify-start w-max'
|
|
||||||
popover='auto'
|
|
||||||
id={dropdownId}
|
|
||||||
style={
|
|
||||||
{
|
|
||||||
positionAnchor: `--breadcrumb-ellipsis-anchor-${anchorId}`,
|
|
||||||
} as React.CSSProperties
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{hiddenItems.map((item, index) => {
|
|
||||||
const itemStyles = cn(
|
|
||||||
'[&]:flex [&]:items-center [&]:justify-start py-1 text-sm',
|
|
||||||
// Disabled state
|
|
||||||
item.isDisabled && 'text-base-content/40 opacity-50',
|
|
||||||
// Active/Last state
|
|
||||||
(item.isActive || item.isDisabled) && 'text-primary',
|
|
||||||
// Regular clickable state
|
|
||||||
!item.isDisabled && 'text-base-content/50'
|
|
||||||
);
|
|
||||||
|
|
||||||
const itemContent = (
|
|
||||||
<div className={itemStyles}>
|
|
||||||
{item.icon && (
|
|
||||||
<span className='inline-flex mr-2'>{item.icon}</span>
|
|
||||||
)}
|
|
||||||
{item.label}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<li
|
|
||||||
key={`ellipsis-${index}`}
|
|
||||||
className='[&&]:text-left [&&]:block w-full'
|
|
||||||
>
|
|
||||||
{item.href && !item.isDisabled ? (
|
|
||||||
<Link
|
|
||||||
href={item.href}
|
|
||||||
className='block !no-underline [&&]:text-left w-full'
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
{itemContent}
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<div className='block !no-underline [&&]:cursor-default [&&]:hover:cursor-default [&&]:hover:bg-base-100 [&&]:text-left'>
|
|
||||||
{itemContent}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const Breadcrumb = ({
|
|
||||||
items,
|
|
||||||
size = 'md',
|
|
||||||
maxVisibleItems = 3,
|
|
||||||
showEllipsisDropdown = true,
|
|
||||||
className,
|
|
||||||
...props
|
|
||||||
}: BreadcrumbsProps) => {
|
|
||||||
const sizeClasses = {
|
|
||||||
xs: 'text-xs',
|
|
||||||
sm: 'text-sm',
|
|
||||||
md: 'text-base',
|
|
||||||
lg: 'text-lg',
|
|
||||||
xl: 'text-xl',
|
|
||||||
};
|
|
||||||
|
|
||||||
const getItemStyles = (
|
|
||||||
item: BreadcrumbItem,
|
|
||||||
position: 'first' | 'middle' | 'last' = 'middle'
|
|
||||||
) => {
|
|
||||||
const baseClasses = 'inline-flex items-center gap-2';
|
|
||||||
|
|
||||||
// Disabled state
|
|
||||||
if (item.isDisabled) {
|
|
||||||
return `${baseClasses} text-base-content/40 !cursor-default opacity-50 hover:!no-underline`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Active/Last state (no underline)
|
|
||||||
if (item.isActive || position === 'last') {
|
|
||||||
return `${baseClasses} text-primary !cursor-pointer hover:!no-underline`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Regular clickable state
|
|
||||||
return `${baseClasses} text-base-content/60`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderItem = (
|
|
||||||
item: BreadcrumbItem,
|
|
||||||
position: 'first' | 'middle' | 'last' = 'middle'
|
|
||||||
) => {
|
|
||||||
const styles = getItemStyles(item, position);
|
|
||||||
|
|
||||||
// Disabled items
|
|
||||||
if (item.isDisabled) {
|
|
||||||
return (
|
|
||||||
<span className={styles}>
|
|
||||||
{item.icon && item.icon}
|
|
||||||
{item.label}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Active/Last items
|
|
||||||
if (item.isActive || position === 'last') {
|
|
||||||
if (item.href) {
|
|
||||||
return (
|
|
||||||
<Link href={item.href} className={styles}>
|
|
||||||
{item.icon && (
|
|
||||||
<span className='inline-flex gap-2'>{item.icon}</span>
|
|
||||||
)}
|
|
||||||
{item.label}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<span className={styles}>
|
|
||||||
{item.icon && item.icon}
|
|
||||||
{item.label}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Regular items
|
|
||||||
if (item.href) {
|
|
||||||
return (
|
|
||||||
<Link href={item.href} className={styles}>
|
|
||||||
{item.icon && <span className='inline-flex gap-2'>{item.icon}</span>}
|
|
||||||
{item.label}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<span className={styles}>
|
|
||||||
{item.icon && item.icon}
|
|
||||||
{item.label}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderBreadcrumbList = () => {
|
|
||||||
// Show all items if within limit
|
|
||||||
if (items.length <= maxVisibleItems) {
|
|
||||||
return items.map((item, index) => {
|
|
||||||
const position =
|
|
||||||
index === 0
|
|
||||||
? 'first'
|
|
||||||
: index === items.length - 1
|
|
||||||
? 'last'
|
|
||||||
: 'middle';
|
|
||||||
return <li key={index}>{renderItem(item, position)}</li>;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Collapsed items indexing when exceeding limit
|
|
||||||
const firstItem = items[0];
|
|
||||||
const lastItem = items[items.length - 1];
|
|
||||||
const visibleMiddleItems = items.slice(1, -1).slice(-(maxVisibleItems - 2));
|
|
||||||
const hiddenItems = items.slice(1, -1).slice(0, -(maxVisibleItems - 2));
|
|
||||||
const showEllipsis = showEllipsisDropdown && hiddenItems.length > 0;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<li>{renderItem(firstItem, 'first')}</li>
|
|
||||||
|
|
||||||
{/* Ellipsis for hidden items with dropdown */}
|
|
||||||
{showEllipsis && <EllipsisDropdown hiddenItems={hiddenItems} />}
|
|
||||||
|
|
||||||
{/* Middle items */}
|
|
||||||
{visibleMiddleItems.map((item, index) => (
|
|
||||||
<li key={`middle-${index}`}>{renderItem(item, 'middle')}</li>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<li>{renderItem(lastItem, 'last')}</li>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<nav
|
|
||||||
aria-label='Breadcrumb'
|
|
||||||
className={cn('breadcrumbs', sizeClasses[size], className)}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<ul className='text-sm'>{renderBreadcrumbList()}</ul>
|
|
||||||
</nav>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Breadcrumb;
|
|
||||||
@@ -2,12 +2,11 @@ import react from 'react';
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
import { Color } from '@/types/theme';
|
import { Color } from '@/types/theme';
|
||||||
import { UrlObject } from 'url';
|
|
||||||
|
|
||||||
export interface ButtonProps extends react.ComponentProps<'button'> {
|
export interface ButtonProps extends react.ComponentProps<'button'> {
|
||||||
variant?: 'soft' | 'outline' | 'dash' | 'ghost' | 'link' | 'active';
|
variant?: 'soft' | 'outline' | 'dash' | 'ghost' | 'link' | 'active';
|
||||||
color?: Color;
|
color?: Color;
|
||||||
href?: string | UrlObject;
|
href?: string;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
target?: string;
|
target?: string;
|
||||||
rel?: string;
|
rel?: string;
|
||||||
@@ -51,7 +50,7 @@ const Button = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{(!href || (href && disabled)) && (
|
{!href && (
|
||||||
<button
|
<button
|
||||||
{...props}
|
{...props}
|
||||||
type={type}
|
type={type}
|
||||||
@@ -68,9 +67,9 @@ const Button = ({
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{href && !disabled && (
|
{href && (
|
||||||
<Link
|
<Link
|
||||||
href={href}
|
href={disabled ? '#' : href}
|
||||||
target={target}
|
target={target}
|
||||||
rel={rel}
|
rel={rel}
|
||||||
aria-disabled={disabled}
|
aria-disabled={disabled}
|
||||||
|
|||||||
+3
-17
@@ -22,7 +22,6 @@ export interface CardProps
|
|||||||
onCollapsedChange?: (collapsed: boolean) => void;
|
onCollapsedChange?: (collapsed: boolean) => void;
|
||||||
className?: {
|
className?: {
|
||||||
wrapper?: string;
|
wrapper?: string;
|
||||||
wrapperContent?: string;
|
|
||||||
image?: string;
|
image?: string;
|
||||||
body?: string;
|
body?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
@@ -123,10 +122,6 @@ const Card = ({
|
|||||||
return cn(baseClasses, 'p-6', className?.body);
|
return cn(baseClasses, 'p-6', className?.body);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCollapsibleClasses = () => {
|
|
||||||
return cn('', className?.collapsible);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getTitleClasses = () => {
|
const getTitleClasses = () => {
|
||||||
const sizeClasses = {
|
const sizeClasses = {
|
||||||
sm: 'text-lg',
|
sm: 'text-lg',
|
||||||
@@ -149,19 +144,11 @@ const Card = ({
|
|||||||
return cn('border-t border-base-300 mt-4 pt-4', className?.footer);
|
return cn('border-t border-base-300 mt-4 pt-4', className?.footer);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getWrapperContentClasses = () => {
|
|
||||||
return cn('space-y-4', className?.wrapperContent);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderCardContent = () => {
|
const renderCardContent = () => {
|
||||||
const hasContent = children || actions || footer;
|
const hasContent = children || actions || footer;
|
||||||
|
|
||||||
const titleContent = (
|
const titleContent = (
|
||||||
<div
|
<div className='group flex items-center !justify-between w-full'>
|
||||||
className={
|
|
||||||
`group flex items-center justify-between! w-full` + getTitleClasses()
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className='flex-1'>
|
<div className='flex-1'>
|
||||||
{title && <h2 className={getTitleClasses()}>{title}</h2>}
|
{title && <h2 className={getTitleClasses()}>{title}</h2>}
|
||||||
{subtitle && <p className={getSubtitleClasses()}>{subtitle}</p>}
|
{subtitle && <p className={getSubtitleClasses()}>{subtitle}</p>}
|
||||||
@@ -169,7 +156,7 @@ const Card = ({
|
|||||||
{collapsible && (
|
{collapsible && (
|
||||||
<button
|
<button
|
||||||
onClick={() => handleCollapsedChange(!isCollapsed)}
|
onClick={() => handleCollapsedChange(!isCollapsed)}
|
||||||
className={`btn btn-ghost btn-sm btn-circle` + getTitleClasses()}
|
className='btn btn-ghost btn-sm btn-circle'
|
||||||
aria-label={isCollapsed ? 'Expand content' : 'Collapse content'}
|
aria-label={isCollapsed ? 'Expand content' : 'Collapse content'}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
@@ -186,7 +173,7 @@ const Card = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const cardContent = (
|
const cardContent = (
|
||||||
<div className={getWrapperContentClasses()}>
|
<div className='space-y-4'>
|
||||||
{children}
|
{children}
|
||||||
{actions && <div className={getActionsClasses()}>{actions}</div>}
|
{actions && <div className={getActionsClasses()}>{actions}</div>}
|
||||||
{footer && <div className={getFooterClasses()}>{footer}</div>}
|
{footer && <div className={getFooterClasses()}>{footer}</div>}
|
||||||
@@ -217,7 +204,6 @@ const Card = ({
|
|||||||
titleClassName='w-full cursor-pointer'
|
titleClassName='w-full cursor-pointer'
|
||||||
contentClassName='p-0'
|
contentClassName='p-0'
|
||||||
fullWidth={true}
|
fullWidth={true}
|
||||||
className={getCollapsibleClasses()}
|
|
||||||
>
|
>
|
||||||
{cardContent}
|
{cardContent}
|
||||||
</Collapse>
|
</Collapse>
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ interface DrawerProps {
|
|||||||
className?: DrawerClassName;
|
className?: DrawerClassName;
|
||||||
onBackdropClick?: () => void;
|
onBackdropClick?: () => void;
|
||||||
closeOnBackdropClick?: boolean;
|
closeOnBackdropClick?: boolean;
|
||||||
expandedContent?: ReactNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DrawerClassName = {
|
type DrawerClassName = {
|
||||||
@@ -24,7 +23,6 @@ type DrawerClassName = {
|
|||||||
drawerSide?: string;
|
drawerSide?: string;
|
||||||
drawerOverlay?: string;
|
drawerOverlay?: string;
|
||||||
drawerSidebarContent?: string;
|
drawerSidebarContent?: string;
|
||||||
drawerExpandedContent?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const Drawer = ({
|
const Drawer = ({
|
||||||
@@ -38,7 +36,6 @@ const Drawer = ({
|
|||||||
className,
|
className,
|
||||||
onBackdropClick,
|
onBackdropClick,
|
||||||
closeOnBackdropClick = true,
|
closeOnBackdropClick = true,
|
||||||
expandedContent,
|
|
||||||
}: DrawerProps) => {
|
}: DrawerProps) => {
|
||||||
const getDrawerClassNames = (): DrawerClassName => {
|
const getDrawerClassNames = (): DrawerClassName => {
|
||||||
const baseClassNames = {
|
const baseClassNames = {
|
||||||
@@ -49,24 +46,12 @@ const Drawer = ({
|
|||||||
drawerSidebarContent: 'min-h-full bg-base-100',
|
drawerSidebarContent: 'min-h-full bg-base-100',
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSidebarWidth = () => {
|
|
||||||
if (variant === 'sidebar') {
|
|
||||||
return expandedContent
|
|
||||||
? 'w-full lg:min-w-[600px] lg:max-w-[600px]'
|
|
||||||
: 'w-full max-w-[300px] lg:w-[300px]';
|
|
||||||
}
|
|
||||||
if (className?.drawerSidebarContent) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return 'w-full sm:min-w-120 sm:w-fit';
|
|
||||||
};
|
|
||||||
|
|
||||||
if (variant === 'sidebar') {
|
if (variant === 'sidebar') {
|
||||||
return {
|
return {
|
||||||
...baseClassNames,
|
...baseClassNames,
|
||||||
drawerSidebarContent: cn(
|
drawerSidebarContent: cn(
|
||||||
baseClassNames.drawerSidebarContent,
|
baseClassNames.drawerSidebarContent,
|
||||||
getSidebarWidth()
|
'w-full max-w-[300px] lg:w-[300px]'
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
} else if (variant === 'right') {
|
} else if (variant === 'right') {
|
||||||
@@ -75,11 +60,11 @@ const Drawer = ({
|
|||||||
drawer: cn(baseClassNames.drawer, 'drawer-end'),
|
drawer: cn(baseClassNames.drawer, 'drawer-end'),
|
||||||
drawerSide: cn(
|
drawerSide: cn(
|
||||||
baseClassNames.drawerSide,
|
baseClassNames.drawerSide,
|
||||||
'border-l border-solid border-gray-200 sm:drawer-side w-screen top-0 right-0 fixed z-21'
|
'border-l border-solid border-gray-200 drawer-side w-screen top-0 right-0 fixed z-21'
|
||||||
),
|
),
|
||||||
drawerSidebarContent: cn(
|
drawerSidebarContent: cn(
|
||||||
baseClassNames.drawerSidebarContent,
|
baseClassNames.drawerSidebarContent,
|
||||||
getSidebarWidth()
|
'w-full sm:min-w-120 sm:w-fit'
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
} else if (variant === 'left') {
|
} else if (variant === 'left') {
|
||||||
@@ -91,7 +76,7 @@ const Drawer = ({
|
|||||||
),
|
),
|
||||||
drawerSidebarContent: cn(
|
drawerSidebarContent: cn(
|
||||||
baseClassNames.drawerSidebarContent,
|
baseClassNames.drawerSidebarContent,
|
||||||
getSidebarWidth()
|
'w-full sm:min-w-120 sm:w-fit'
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -108,9 +93,7 @@ const Drawer = ({
|
|||||||
if (closeOnBackdropClick) {
|
if (closeOnBackdropClick) {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}
|
}
|
||||||
if (onBackdropClick) {
|
onBackdropClick && onBackdropClick();
|
||||||
onBackdropClick();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -155,37 +138,14 @@ const Drawer = ({
|
|||||||
onClick={closeDrawer}
|
onClick={closeDrawer}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Sidebar Content - Full height container */}
|
{/* Sidebar Content */}
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex h-screen bg-base-100 overflow-hidden',
|
varianClassName?.drawerSidebarContent,
|
||||||
variant === 'right' && 'flex-row'
|
className?.drawerContent
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{/* Primary Sidebar Content */}
|
{sidebarContent}
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
varianClassName?.drawerSidebarContent,
|
|
||||||
className?.drawerSidebarContent,
|
|
||||||
'overflow-y-auto'
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{sidebarContent}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Expanded Drawer (Right side, side-by-side) */}
|
|
||||||
{expandedContent && (
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
'border-l border-gray-200 bg-white flex flex-col h-full',
|
|
||||||
className?.drawerExpandedContent
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className='overflow-y-auto flex-1 h-full'>
|
|
||||||
{expandedContent}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ const FloatingActionsButton = ({
|
|||||||
// Jika tidak ada baris yang dipilih, jangan tampilkan FAB
|
// Jika tidak ada baris yang dipilih, jangan tampilkan FAB
|
||||||
const positionStyles =
|
const positionStyles =
|
||||||
selectedRowIds.length > 0
|
selectedRowIds.length > 0
|
||||||
? 'bottom-[5%] opacity-100'
|
? 'bottom-[10%] opacity-100'
|
||||||
: 'bottom-[-5%] opacity-0';
|
: 'bottom-[-10%] opacity-0';
|
||||||
|
|
||||||
// Helper untuk menentukan gaya warna tombol approval
|
// Helper untuk menentukan gaya warna tombol approval
|
||||||
const getApprovalColor = (action: 'APPROVED' | 'REJECTED') => {
|
const getApprovalColor = (action: 'APPROVED' | 'REJECTED') => {
|
||||||
@@ -60,7 +60,7 @@ const FloatingActionsButton = ({
|
|||||||
// Container utama FAB
|
// Container utama FAB
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
`fixed ${positionStyles} inset-x-1/2 -translate-x-1/2 z-50`,
|
`absolute ${positionStyles} inset-x-1/2 -translate-x-1/2 z-50`,
|
||||||
'mx-auto w-full max-w-sm sm:mx-0 bg-base-300 p-4 rounded-xl shadow-md transition-all duration-300 transform',
|
'mx-auto w-full max-w-sm sm:mx-0 bg-base-300 p-4 rounded-xl shadow-md transition-all duration-300 transform',
|
||||||
'bg-slate-950 backdrop-blur-md'
|
'bg-slate-950 backdrop-blur-md'
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { useCallback } from 'react';
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
|
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
@@ -12,6 +13,7 @@ import PermissionNotFound from '@/components/helper/PermissionNotFound';
|
|||||||
|
|
||||||
import { useUiStore } from '@/stores/ui/ui.store';
|
import { useUiStore } from '@/stores/ui/ui.store';
|
||||||
import { MAIN_DRAWER_LINKS } from '@/config/constant';
|
import { MAIN_DRAWER_LINKS } from '@/config/constant';
|
||||||
|
import { isPathActive } from '@/lib/helper';
|
||||||
import { ROUTE_PERMISSIONS } from '@/config/route-permission';
|
import { ROUTE_PERMISSIONS } from '@/config/route-permission';
|
||||||
import { useAuth } from '@/services/hooks/useAuth';
|
import { useAuth } from '@/services/hooks/useAuth';
|
||||||
|
|
||||||
@@ -24,34 +26,29 @@ const MainDrawerContent = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full flex flex-col'>
|
<div className='w-full p-4 flex flex-col gap-4'>
|
||||||
<div className='p-3 flex flex-row items-center gap-4 border-b border-base-content/10'>
|
<div className='flex flex-row items-center gap-4'>
|
||||||
<div className='flex flex-row items-center gap-2'>
|
<Image
|
||||||
<Image
|
src='/assets/img/lti-logo.png'
|
||||||
src='/assets/img/lti-logo.png'
|
alt='MBU Logo'
|
||||||
alt='LTI Logo'
|
width={256}
|
||||||
width={40}
|
height={256}
|
||||||
height={40}
|
className='w-full max-w-16 h-auto'
|
||||||
className='w-full max-w-10 h-auto'
|
/>
|
||||||
/>
|
|
||||||
|
|
||||||
<div className='font-roboto'>
|
<h1 className='text-xl font-bold'>LTI ERP</h1>
|
||||||
<h1 className='text-sm font-semibold'>LTI ERP</h1>
|
|
||||||
<p className='text-sm text-black/50'>Lumbung Telur Indonesia</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='grow flex flex-row justify-end sm:hidden'>
|
<div className='grow flex flex-row justify-end sm:hidden'>
|
||||||
<Button
|
<Button
|
||||||
variant='soft'
|
variant='soft'
|
||||||
color='error'
|
color='error'
|
||||||
onClick={closeMainDrawerHandler}
|
onClick={closeMainDrawerHandler}
|
||||||
className='p-1 rounded-full'
|
className='rounded-full'
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
icon='material-symbols:close-rounded'
|
icon='material-symbols:close-rounded'
|
||||||
width={16}
|
width={24}
|
||||||
height={16}
|
height={24}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -70,39 +67,61 @@ const MainDrawer = ({
|
|||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const { permissionCheck } = useAuth();
|
const { permissionCheck } = useAuth();
|
||||||
|
|
||||||
const formattedPathname = pathname.endsWith('/') ? pathname : `${pathname}/`;
|
const isPermitted = ROUTE_PERMISSIONS[pathname]?.some((permission) =>
|
||||||
|
|
||||||
const isPathnameNotFoundPage = formattedPathname === '/404/';
|
|
||||||
|
|
||||||
const isPermitted = ROUTE_PERMISSIONS[formattedPathname]?.some((permission) =>
|
|
||||||
permissionCheck(permission)
|
permissionCheck(permission)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getPageTitle = useCallback(() => {
|
||||||
|
let title = '';
|
||||||
|
|
||||||
|
const activeMenu = MAIN_DRAWER_LINKS.find((item) =>
|
||||||
|
isPathActive(pathname, item.link)
|
||||||
|
);
|
||||||
|
|
||||||
|
const traverseMenuTitle = (menu: typeof activeMenu) => {
|
||||||
|
if (!menu) return;
|
||||||
|
|
||||||
|
const hasSubmenu = menu?.submenu && menu?.submenu.length > 0;
|
||||||
|
|
||||||
|
if (!title) {
|
||||||
|
title += menu?.text;
|
||||||
|
} else {
|
||||||
|
title += ' - ' + menu?.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasSubmenu || !menu.submenu) return;
|
||||||
|
|
||||||
|
const activeSubmenu = menu.submenu?.find((item) =>
|
||||||
|
isPathActive(pathname, item.link)
|
||||||
|
);
|
||||||
|
|
||||||
|
traverseMenuTitle(activeSubmenu);
|
||||||
|
};
|
||||||
|
|
||||||
|
traverseMenuTitle(activeMenu);
|
||||||
|
|
||||||
|
return title;
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
|
const pageTitle = getPageTitle();
|
||||||
|
|
||||||
const toggleSidebar = () => {
|
const toggleSidebar = () => {
|
||||||
setMainDrawerOpen(!mainDrawerOpen);
|
setMainDrawerOpen(!mainDrawerOpen);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isPermitted && !isPathnameNotFoundPage) {
|
if (!isPermitted) {
|
||||||
return <PermissionNotFound />;
|
return <PermissionNotFound />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPathnameNotFoundPage) {
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<Drawer
|
||||||
open={mainDrawerOpen}
|
open={mainDrawerOpen}
|
||||||
setOpen={setMainDrawerOpen}
|
setOpen={setMainDrawerOpen}
|
||||||
openOnLarge
|
openOnLarge
|
||||||
sidebarContent={<MainDrawerContent />}
|
sidebarContent={<MainDrawerContent />}
|
||||||
className={{
|
|
||||||
drawerSide: 'border-r border-base-content/10',
|
|
||||||
drawerSidebarContent: 'min-w-[244px] lg:w-[244px]',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<main className='w-full h-full flex flex-col'>
|
<main className='w-full h-full flex flex-col'>
|
||||||
<Navbar toggleSidebar={toggleSidebar} />
|
<Navbar title={pageTitle as string} toggleSidebar={toggleSidebar} />
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -31,11 +31,7 @@ export const useModal = (isNestingModal = false) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const toggle = useCallback(() => {
|
const toggle = useCallback(() => {
|
||||||
if (open) {
|
open ? closeModal() : openModal();
|
||||||
closeModal();
|
|
||||||
} else {
|
|
||||||
openModal();
|
|
||||||
}
|
|
||||||
}, [open, closeModal, openModal]);
|
}, [open, closeModal, openModal]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -57,25 +53,15 @@ interface ModalProps {
|
|||||||
ref: RefObject<HTMLDialogElement | null>;
|
ref: RefObject<HTMLDialogElement | null>;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
closeOnBackdrop?: boolean;
|
closeOnBackdrop?: boolean;
|
||||||
onBackdropClick?: () => void;
|
|
||||||
position?: 'top' | 'middle' | 'bottom' | 'start' | 'end';
|
|
||||||
className?: {
|
className?: {
|
||||||
modal?: string;
|
modal?: string;
|
||||||
modalBox?: string;
|
modalBox?: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const Modal = ({
|
const Modal = ({ ref, children, closeOnBackdrop, className }: ModalProps) => {
|
||||||
ref,
|
|
||||||
children,
|
|
||||||
closeOnBackdrop,
|
|
||||||
onBackdropClick,
|
|
||||||
position = 'middle',
|
|
||||||
className,
|
|
||||||
}: ModalProps) => {
|
|
||||||
const handleBackdropClick = (e: React.MouseEvent<HTMLDialogElement>) => {
|
const handleBackdropClick = (e: React.MouseEvent<HTMLDialogElement>) => {
|
||||||
if (closeOnBackdrop && e.target === ref.current) {
|
if (closeOnBackdrop && e.target === ref.current) {
|
||||||
onBackdropClick?.();
|
|
||||||
ref.current?.close();
|
ref.current?.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -83,17 +69,7 @@ const Modal = ({
|
|||||||
return (
|
return (
|
||||||
<dialog
|
<dialog
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn('modal', className?.modal)}
|
||||||
'modal',
|
|
||||||
{
|
|
||||||
'modal-top': position === 'top',
|
|
||||||
'modal-middle': position === 'middle',
|
|
||||||
'modal-bottom': position === 'bottom',
|
|
||||||
'modal-start': position === 'start',
|
|
||||||
'modal-end': position === 'end',
|
|
||||||
},
|
|
||||||
className?.modal
|
|
||||||
)}
|
|
||||||
onClick={handleBackdropClick}
|
onClick={handleBackdropClick}
|
||||||
>
|
>
|
||||||
<div className={cn('modal-box', className?.modalBox)}>{children}</div>
|
<div className={cn('modal-box', className?.modalBox)}>{children}</div>
|
||||||
|
|||||||
+33
-51
@@ -1,94 +1,76 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import { usePathname, useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
|
import Menu from '@/components/menu/Menu';
|
||||||
|
import MenuItem from '@/components/menu/MenuItem';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import Breadcrumb, { buildBreadcrumbs } from '@/components/Breadcrumb';
|
import Dropdown from '@/components/Dropdown';
|
||||||
import PopoverButton from '@/components/popover/PopoverButton';
|
|
||||||
import PopoverContent from '@/components/popover/PopoverContent';
|
|
||||||
|
|
||||||
import { useAuth } from '@/services/hooks/useAuth';
|
import { useAuth } from '@/services/hooks/useAuth';
|
||||||
import { AuthApi } from '@/services/api/auth';
|
import { AuthApi } from '@/services/api/auth';
|
||||||
import { isResponseError } from '@/lib/api-helper';
|
import { isResponseError } from '@/lib/api-helper';
|
||||||
import { useUiStore } from '@/stores/ui/ui.store';
|
|
||||||
|
|
||||||
interface NavbarProps {
|
interface NavbarProps {
|
||||||
|
title: string;
|
||||||
toggleSidebar?: () => void;
|
toggleSidebar?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Navbar = ({ toggleSidebar }: NavbarProps) => {
|
const Navbar = ({ title, toggleSidebar }: NavbarProps) => {
|
||||||
const { setUser } = useAuth();
|
const { setUser } = useAuth();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
|
||||||
const navbarActions = useUiStore((state) => state.navbarActions);
|
|
||||||
|
|
||||||
const logoutClickHandler = async () => {
|
const logoutClickHandler = async () => {
|
||||||
const logoutRes = await AuthApi.logout();
|
const logoutRes = await AuthApi.logout();
|
||||||
|
|
||||||
if (isResponseError(logoutRes)) {
|
if (isResponseError(logoutRes)) {
|
||||||
toast.error('Gagal logout! Coba lagi!');
|
toast.error('Gagal logout! Coba lagi!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setUser(undefined);
|
setUser(undefined);
|
||||||
const redirect = (logoutRes as { redirect?: string })?.redirect;
|
|
||||||
if (redirect) {
|
|
||||||
window.location.href = redirect;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
router.replace(process.env.NEXT_PUBLIC_SSO_LOGIN_URL as string);
|
router.replace(process.env.NEXT_PUBLIC_SSO_LOGIN_URL as string);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='navbar p-3 bg-base-100 border-b border-base-content/10'>
|
<div className='navbar px-4 bg-base-100 shadow-sm'>
|
||||||
<div className='flex-1'>
|
<div className='flex-1'>
|
||||||
<div className='flex flex-row items-center gap-4'>
|
<div className='flex flex-row items-center gap-4'>
|
||||||
{toggleSidebar && (
|
{toggleSidebar && (
|
||||||
<Button
|
<Button onClick={toggleSidebar} className='block lg:hidden'>
|
||||||
variant='ghost'
|
<Icon
|
||||||
color='none'
|
icon='material-symbols:menu-rounded'
|
||||||
onClick={toggleSidebar}
|
width={24}
|
||||||
className='block lg:hidden p-[9px] text-base-content/50 border border-base-content/10 rounded-xl shadow-button-soft'
|
height={24}
|
||||||
>
|
/>
|
||||||
<Icon icon='heroicons:bars-3' width={20} height={20} />
|
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Breadcrumb items={buildBreadcrumbs(pathname)} />
|
<span className='font-bold text-xl text-primary'>{title}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='flex gap-2 items-center'>
|
<div className='flex gap-2'>
|
||||||
{/* Page-specific actions */}
|
<Dropdown
|
||||||
{navbarActions && <div className='mr-2'>{navbarActions}</div>}
|
align='end'
|
||||||
<PopoverButton
|
direction='bottom'
|
||||||
tabIndex={0}
|
trigger={
|
||||||
variant='ghost'
|
<div className='btn btn-ghost btn-circle avatar'>
|
||||||
color='none'
|
<div className='w-10 rounded-full border flex justify-center items-center'>
|
||||||
popoverTarget='accountNavbar'
|
<Icon icon='uil:user' width={40} height={40} />
|
||||||
anchorName='--account-navbar'
|
</div>
|
||||||
className='p-[9px] text-base-content/50 border border-base-content/10 rounded-xl shadow-button-soft'
|
</div>
|
||||||
|
}
|
||||||
|
className={{
|
||||||
|
content: 'w-52 mt-3',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Icon icon='heroicons:user' width={20} height={20} />
|
<Menu>
|
||||||
</PopoverButton>
|
<MenuItem title='Logout' onClick={logoutClickHandler} />
|
||||||
|
</Menu>
|
||||||
<PopoverContent
|
</Dropdown>
|
||||||
id='accountNavbar'
|
|
||||||
anchorName='--account-navbar'
|
|
||||||
position='bottom-start'
|
|
||||||
className='rounded-xl border border-base-content/5 shadow-sm'
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
onClick={logoutClickHandler}
|
|
||||||
variant='ghost'
|
|
||||||
color='error'
|
|
||||||
className='p-3 justify-start text-sm font-semibold w-full'
|
|
||||||
>
|
|
||||||
<Icon icon='heroicons-outline:logout' width={20} height={20} />
|
|
||||||
Logout
|
|
||||||
</Button>
|
|
||||||
</PopoverContent>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+55
-196
@@ -1,12 +1,11 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { Fragment, ReactNode, useCallback, useEffect, useState } from 'react';
|
import { ReactNode, useCallback, useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
flexRender,
|
flexRender,
|
||||||
getCoreRowModel,
|
getCoreRowModel,
|
||||||
getFilteredRowModel,
|
getFilteredRowModel,
|
||||||
getPaginationRowModel,
|
getPaginationRowModel,
|
||||||
getExpandedRowModel,
|
|
||||||
getSortedRowModel,
|
getSortedRowModel,
|
||||||
TableOptions,
|
TableOptions,
|
||||||
useReactTable,
|
useReactTable,
|
||||||
@@ -16,7 +15,6 @@ import {
|
|||||||
OnChangeFn,
|
OnChangeFn,
|
||||||
Row,
|
Row,
|
||||||
HeaderContext,
|
HeaderContext,
|
||||||
ExpandedState,
|
|
||||||
} from '@tanstack/react-table';
|
} from '@tanstack/react-table';
|
||||||
import { rankItem } from '@tanstack/match-sorter-utils';
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
@@ -33,16 +31,11 @@ interface TableClassNames {
|
|||||||
headerColumnClassName?: string;
|
headerColumnClassName?: string;
|
||||||
tableBodyClassName?: string;
|
tableBodyClassName?: string;
|
||||||
bodyRowClassName?: string;
|
bodyRowClassName?: string;
|
||||||
selectedBodyRowClassName?: string;
|
|
||||||
bodyColumnClassName?: string;
|
bodyColumnClassName?: string;
|
||||||
bodySubRowClassName?: (depth: number) => string;
|
|
||||||
selectedBodySubRowClassName?: (depth: number) => string;
|
|
||||||
bodySubRowColumnClassName?: (depth: number) => string;
|
|
||||||
tableFooterClassName?: string;
|
tableFooterClassName?: string;
|
||||||
footerRowClassName?: string;
|
footerRowClassName?: string;
|
||||||
footerColumnClassName?: string;
|
footerColumnClassName?: string;
|
||||||
paginationClassName?: string;
|
paginationClassName?: string;
|
||||||
skeletonCellClassName?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TableProps<TData extends object> {
|
export interface TableProps<TData extends object> {
|
||||||
@@ -66,7 +59,6 @@ export interface TableProps<TData extends object> {
|
|||||||
enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
|
enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
|
||||||
renderFooter?: boolean;
|
renderFooter?: boolean;
|
||||||
withCheckbox?: boolean;
|
withCheckbox?: boolean;
|
||||||
withPagination?: boolean;
|
|
||||||
rowOptions?: number[];
|
rowOptions?: number[];
|
||||||
/**
|
/**
|
||||||
* Custom row renderer. Should return a complete <tr> element or null.
|
* Custom row renderer. Should return a complete <tr> element or null.
|
||||||
@@ -74,19 +66,13 @@ export interface TableProps<TData extends object> {
|
|||||||
* Return null to render the default row.
|
* Return null to render the default row.
|
||||||
*/
|
*/
|
||||||
renderCustomRow?: (row: Row<TData>) => ReactNode | null;
|
renderCustomRow?: (row: Row<TData>) => ReactNode | null;
|
||||||
getRowCanExpand?: (row: Row<TData>) => boolean;
|
|
||||||
renderSubComponent?: (props: { row: Row<TData> }) => React.ReactElement;
|
|
||||||
expanded?: ExpandedState;
|
|
||||||
getSubRows?: (originalRow: TData, index: number) => TData[] | undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const DUMMY_SKELETON_DATA = Array.from({ length: 10 }, (_, index) => ({
|
const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}];
|
||||||
id: index,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const emptyContentDefaultValue = (
|
const emptyContentDefaultValue = (
|
||||||
<div className='w-full text-center py-4'>
|
<div className='w-full p-5 text-center'>
|
||||||
<span className='text-sm opacity-50'>
|
<span className='text-lg opacity-50'>
|
||||||
Tidak ada data yang dapat ditampilkan...
|
Tidak ada data yang dapat ditampilkan...
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -100,18 +86,11 @@ export const TABLE_DEFAULT_STYLING = {
|
|||||||
tableHeaderClassName: '',
|
tableHeaderClassName: '',
|
||||||
headerRowClassName: '',
|
headerRowClassName: '',
|
||||||
headerColumnClassName:
|
headerColumnClassName:
|
||||||
'px-4 py-3 border-base-content/10 text-base-content/50 text-sm font-medium',
|
'px-4 py-3 border-base-content/10 text-base-content/50',
|
||||||
tableBodyClassName: '',
|
tableBodyClassName: '',
|
||||||
bodyRowClassName:
|
bodyRowClassName: 'border-t border-base-content/10',
|
||||||
'transition-all duration-200 border-t border-base-content/10 bg-transparent',
|
bodyColumnClassName: 'px-4 py-3 text-base-content',
|
||||||
selectedBodyRowClassName: 'bg-primary/5',
|
paginationClassName: '',
|
||||||
bodyColumnClassName: 'px-4 py-3 text-base-content font-medium',
|
|
||||||
bodySubRowClassName: (depth: number) =>
|
|
||||||
'transition-all duration-200 border-t border-base-content/10 bg-transparent',
|
|
||||||
selectedBodySubRowClassName: (depth: number) => 'bg-primary/5',
|
|
||||||
bodySubRowColumnClassName: (depth: number) =>
|
|
||||||
'px-4 py-3 text-base-content font-medium',
|
|
||||||
paginationClassName: 'px-3',
|
|
||||||
tableFooterClassName: 'font-semibold border-base-content/10',
|
tableFooterClassName: 'font-semibold border-base-content/10',
|
||||||
footerRowClassName: 'bg-base-200 border-t-2 border-base-content/10',
|
footerRowClassName: 'bg-base-200 border-t-2 border-base-content/10',
|
||||||
footerColumnClassName: 'p-4 text-base-content whitespace-nowrap',
|
footerColumnClassName: 'p-4 text-base-content whitespace-nowrap',
|
||||||
@@ -138,13 +117,8 @@ const Table = <TData extends object>({
|
|||||||
enableRowSelection,
|
enableRowSelection,
|
||||||
renderFooter = false,
|
renderFooter = false,
|
||||||
withCheckbox = false,
|
withCheckbox = false,
|
||||||
withPagination = true,
|
|
||||||
rowOptions = [10, 20, 50, 100],
|
rowOptions = [10, 20, 50, 100],
|
||||||
renderCustomRow,
|
renderCustomRow,
|
||||||
getRowCanExpand,
|
|
||||||
renderSubComponent,
|
|
||||||
expanded = {},
|
|
||||||
getSubRows,
|
|
||||||
}: TableProps<TData>) => {
|
}: TableProps<TData>) => {
|
||||||
const isServerSideTable =
|
const isServerSideTable =
|
||||||
totalItems !== undefined &&
|
totalItems !== undefined &&
|
||||||
@@ -177,14 +151,10 @@ const Table = <TData extends object>({
|
|||||||
getSortedRowModel: getSortedRowModel(),
|
getSortedRowModel: getSortedRowModel(),
|
||||||
getPaginationRowModel: getPaginationRowModel(),
|
getPaginationRowModel: getPaginationRowModel(),
|
||||||
onPaginationChange: setPagination,
|
onPaginationChange: setPagination,
|
||||||
getExpandedRowModel: getExpandedRowModel(),
|
|
||||||
getRowCanExpand: getRowCanExpand ?? (getSubRows ? undefined : () => false),
|
|
||||||
getSubRows,
|
|
||||||
manualSorting,
|
manualSorting,
|
||||||
state: {
|
state: {
|
||||||
pagination,
|
pagination,
|
||||||
globalFilter: fuzzySearchValue,
|
globalFilter: fuzzySearchValue,
|
||||||
expanded,
|
|
||||||
},
|
},
|
||||||
filterFns: {
|
filterFns: {
|
||||||
fuzzy: fuzzyFilter,
|
fuzzy: fuzzyFilter,
|
||||||
@@ -252,40 +222,14 @@ const Table = <TData extends object>({
|
|||||||
}, [pageSize, setPageSize]);
|
}, [pageSize, setPageSize]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={tableClassNames.containerClassName}>
|
||||||
className={cn(
|
<div className={tableClassNames.tableWrapperClassName}>
|
||||||
TABLE_DEFAULT_STYLING.containerClassName,
|
<table className={tableClassNames.tableClassName}>
|
||||||
tableClassNames.containerClassName,
|
<thead className={tableClassNames.tableHeaderClassName}>
|
||||||
{
|
|
||||||
'mb-0': !withPagination,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
TABLE_DEFAULT_STYLING.tableWrapperClassName,
|
|
||||||
tableClassNames.tableWrapperClassName
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
className={cn(
|
|
||||||
TABLE_DEFAULT_STYLING.tableClassName,
|
|
||||||
tableClassNames.tableClassName
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<thead
|
|
||||||
className={cn(
|
|
||||||
TABLE_DEFAULT_STYLING.tableHeaderClassName,
|
|
||||||
tableClassNames.tableHeaderClassName
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{table.getHeaderGroups().map((headerGroup) => (
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
<tr
|
<tr
|
||||||
key={headerGroup.id}
|
key={headerGroup.id}
|
||||||
className={cn(
|
className={tableClassNames.headerRowClassName}
|
||||||
TABLE_DEFAULT_STYLING.headerRowClassName,
|
|
||||||
tableClassNames.headerRowClassName
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
{headerGroup.headers.map((header) => {
|
{headerGroup.headers.map((header) => {
|
||||||
const columnRelativeDepth =
|
const columnRelativeDepth =
|
||||||
@@ -318,7 +262,6 @@ const Table = <TData extends object>({
|
|||||||
{
|
{
|
||||||
'border-b': header.colSpan > 1,
|
'border-b': header.colSpan > 1,
|
||||||
},
|
},
|
||||||
TABLE_DEFAULT_STYLING.headerColumnClassName,
|
|
||||||
tableClassNames.headerColumnClassName
|
tableClassNames.headerColumnClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -368,12 +311,7 @@ const Table = <TData extends object>({
|
|||||||
))}
|
))}
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody
|
<tbody className={tableClassNames.tableBodyClassName}>
|
||||||
className={cn(
|
|
||||||
TABLE_DEFAULT_STYLING.tableBodyClassName,
|
|
||||||
tableClassNames.tableBodyClassName
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{table.getRowModel().rows.map((row) => {
|
{table.getRowModel().rows.map((row) => {
|
||||||
const customRowContent = renderCustomRow?.(row);
|
const customRowContent = renderCustomRow?.(row);
|
||||||
|
|
||||||
@@ -382,110 +320,36 @@ const Table = <TData extends object>({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment key={row.id}>
|
<tr key={row.id} className={tableClassNames.bodyRowClassName}>
|
||||||
<tr
|
{row.getVisibleCells().map((cell) => (
|
||||||
data-depth={row.depth}
|
<td
|
||||||
className={cn(
|
key={cell.id}
|
||||||
row.depth > 0
|
className={cn(
|
||||||
? tableClassNames.bodySubRowClassName(row.depth)
|
{ 'first:w-9 first:pr-0': withCheckbox },
|
||||||
: tableClassNames.bodyRowClassName,
|
tableClassNames.bodyColumnClassName
|
||||||
{
|
|
||||||
[tableClassNames.selectedBodyRowClassName!]:
|
|
||||||
row.getIsSelected() && row.depth === 0,
|
|
||||||
[tableClassNames.selectedBodySubRowClassName(
|
|
||||||
row.depth
|
|
||||||
)!]: row.getIsSelected() && row.depth > 0,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{row.getVisibleCells().map((cell) => (
|
|
||||||
<td
|
|
||||||
key={cell.id}
|
|
||||||
className={cn(
|
|
||||||
{ 'first:w-9 first:pr-0': withCheckbox },
|
|
||||||
TABLE_DEFAULT_STYLING.bodyColumnClassName,
|
|
||||||
row.depth > 0
|
|
||||||
? tableClassNames.bodySubRowColumnClassName(
|
|
||||||
row.depth
|
|
||||||
)
|
|
||||||
: tableClassNames.bodyColumnClassName
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{!isLoading &&
|
|
||||||
flexRender(
|
|
||||||
cell.column.columnDef.cell,
|
|
||||||
cell.getContext()
|
|
||||||
)}
|
|
||||||
|
|
||||||
{isLoading && (
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
'skeleton w-full h-4',
|
|
||||||
tableClassNames.skeletonCellClassName
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
))}
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
{row.getIsExpanded() && (
|
|
||||||
<>
|
|
||||||
{renderSubComponent && (
|
|
||||||
<tr
|
|
||||||
className={cn(
|
|
||||||
TABLE_DEFAULT_STYLING.bodySubRowClassName(1),
|
|
||||||
tableClassNames.bodySubRowClassName(1),
|
|
||||||
{
|
|
||||||
[tableClassNames.selectedBodySubRowClassName(1)]:
|
|
||||||
row.getIsSelected(),
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<td colSpan={row.getVisibleCells().length}>
|
|
||||||
{renderSubComponent({ row })}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
)}
|
||||||
</>
|
>
|
||||||
)}
|
{!isLoading &&
|
||||||
</Fragment>
|
flexRender(
|
||||||
|
cell.column.columnDef.cell,
|
||||||
|
cell.getContext()
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isLoading && <div className='skeleton w-full h-4' />}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{(data.length === 0 || table.getRowModel().rows.length === 0) &&
|
|
||||||
!isLoading && (
|
|
||||||
<tr>
|
|
||||||
<td
|
|
||||||
colSpan={
|
|
||||||
table.getAllLeafColumns().length + (withCheckbox ? 1 : 0)
|
|
||||||
}
|
|
||||||
className='p-0'
|
|
||||||
>
|
|
||||||
{emptyContent}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot
|
<tfoot className={cn(tableClassNames.tableFooterClassName)}>
|
||||||
className={cn(
|
|
||||||
TABLE_DEFAULT_STYLING.tableFooterClassName,
|
|
||||||
tableClassNames.tableFooterClassName
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{renderFooter && (
|
{renderFooter && (
|
||||||
<tr
|
<tr className={cn(tableClassNames.footerRowClassName)}>
|
||||||
className={cn(
|
|
||||||
TABLE_DEFAULT_STYLING.footerRowClassName,
|
|
||||||
tableClassNames.footerRowClassName
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{table.getAllLeafColumns().map((column) => (
|
{table.getAllLeafColumns().map((column) => (
|
||||||
<td
|
<td
|
||||||
key={column.id}
|
key={column.id}
|
||||||
className={cn(
|
className={cn(
|
||||||
{ 'first:w-9 first:pr-0': withCheckbox },
|
{ 'first:w-9 first:pr-0': withCheckbox },
|
||||||
TABLE_DEFAULT_STYLING.footerColumnClassName,
|
|
||||||
tableClassNames.footerColumnClassName
|
tableClassNames.footerColumnClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -503,33 +367,28 @@ const Table = <TData extends object>({
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{data.length > 0 &&
|
{(data.length === 0 || table.getRowModel().rows.length === 0) &&
|
||||||
table.getRowModel().rows.length > 0 &&
|
|
||||||
!isLoading &&
|
!isLoading &&
|
||||||
withPagination && (
|
emptyContent}
|
||||||
<div
|
|
||||||
className={cn(
|
{data.length > 0 && table.getRowModel().rows.length > 0 && !isLoading && (
|
||||||
'mt-5',
|
<div className={cn('mt-5', tableClassNames.paginationClassName)}>
|
||||||
TABLE_DEFAULT_STYLING.paginationClassName,
|
<Pagination
|
||||||
tableClassNames.paginationClassName
|
totalItems={isServerSideTable ? totalItems : table.getRowCount()}
|
||||||
)}
|
itemsPerPage={table.getState().pagination.pageSize}
|
||||||
>
|
currentPage={
|
||||||
<Pagination
|
isServerSideTable
|
||||||
totalItems={isServerSideTable ? totalItems : table.getRowCount()}
|
? page
|
||||||
itemsPerPage={table.getState().pagination.pageSize}
|
: table.getState().pagination.pageIndex + 1
|
||||||
currentPage={
|
}
|
||||||
isServerSideTable
|
onPrevPage={prevPageClickHandler}
|
||||||
? page
|
onNextPage={nextPageClickHandler}
|
||||||
: table.getState().pagination.pageIndex + 1
|
onPageChange={pageChangeHandler}
|
||||||
}
|
rowOptions={rowOptions}
|
||||||
onPrevPage={prevPageClickHandler}
|
onRowChange={onPageSizeChange}
|
||||||
onNextPage={nextPageClickHandler}
|
/>
|
||||||
onPageChange={pageChangeHandler}
|
</div>
|
||||||
rowOptions={rowOptions}
|
)}
|
||||||
onRowChange={onPageSizeChange}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+13
-24
@@ -1,4 +1,4 @@
|
|||||||
import { HTMLAttributes, ReactNode, useState } from 'react';
|
import { HTMLAttributes, ReactNode, useEffect, useState } from 'react';
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
|
|
||||||
export interface TabItem {
|
export interface TabItem {
|
||||||
@@ -25,10 +25,8 @@ export interface TabsProps
|
|||||||
wrapper?: string;
|
wrapper?: string;
|
||||||
tab?: string;
|
tab?: string;
|
||||||
content?: string;
|
content?: string;
|
||||||
tabHeaderWrapper?: string;
|
|
||||||
};
|
};
|
||||||
onTabChange?: (tabId: string) => void;
|
onTabChange?: (tabId: string) => void;
|
||||||
sideContent?: ReactNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tabs = ({
|
const Tabs = ({
|
||||||
@@ -40,7 +38,6 @@ const Tabs = ({
|
|||||||
activeTabId: controlledActiveId,
|
activeTabId: controlledActiveId,
|
||||||
className,
|
className,
|
||||||
onTabChange,
|
onTabChange,
|
||||||
sideContent,
|
|
||||||
...props
|
...props
|
||||||
}: TabsProps) => {
|
}: TabsProps) => {
|
||||||
// State internal hanya dipakai kalau `activeTabId` (controlled) tidak diset
|
// State internal hanya dipakai kalau `activeTabId` (controlled) tidak diset
|
||||||
@@ -62,7 +59,6 @@ const Tabs = ({
|
|||||||
wrapper: wrapperClassName,
|
wrapper: wrapperClassName,
|
||||||
tab: tabClassName,
|
tab: tabClassName,
|
||||||
content: contentClassName,
|
content: contentClassName,
|
||||||
tabHeaderWrapper: tabHeaderWrapperClassName,
|
|
||||||
} = typeof className === 'object'
|
} = typeof className === 'object'
|
||||||
? className
|
? className
|
||||||
: { wrapper: className, tab: undefined };
|
: { wrapper: className, tab: undefined };
|
||||||
@@ -106,10 +102,6 @@ const Tabs = ({
|
|||||||
tabClassName
|
tabClassName
|
||||||
);
|
);
|
||||||
|
|
||||||
const getSideContentClasses = () => {
|
|
||||||
return cn('flex flex-row', tabHeaderWrapperClassName);
|
|
||||||
};
|
|
||||||
|
|
||||||
const activeContent = tabs.find((tab) => tab.id === activeTabId)?.content;
|
const activeContent = tabs.find((tab) => tab.id === activeTabId)?.content;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -120,21 +112,18 @@ const Tabs = ({
|
|||||||
typeof className === 'string' ? className : containerClassName
|
typeof className === 'string' ? className : containerClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className={getSideContentClasses()}>
|
<div role='tablist' className={getTabsClasses()}>
|
||||||
<div role='tablist' className={getTabsClasses()}>
|
{tabs.map(({ id, label, disabled }) => (
|
||||||
{tabs.map(({ id, label, disabled }) => (
|
<button
|
||||||
<button
|
key={id}
|
||||||
key={id}
|
role='tab'
|
||||||
role='tab'
|
className={getTabClasses(id === activeTabId, disabled)}
|
||||||
className={getTabClasses(id === activeTabId, disabled)}
|
onClick={() => !disabled && handleTabChange(id)}
|
||||||
onClick={() => !disabled && handleTabChange(id)}
|
disabled={disabled}
|
||||||
disabled={disabled}
|
>
|
||||||
>
|
{label}
|
||||||
{label}
|
</button>
|
||||||
</button>
|
))}
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
{sideContent && sideContent}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{activeContent && (
|
{activeContent && (
|
||||||
|
|||||||
@@ -1,205 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
|
||||||
|
|
||||||
import { Icon } from '@iconify/react';
|
|
||||||
import { BaseApproval } from '@/types/api/api-general';
|
|
||||||
import Button from '@/components/Button';
|
|
||||||
|
|
||||||
import { cn, formatDate } from '@/lib/helper';
|
|
||||||
|
|
||||||
interface ApprovalStepsV2Props {
|
|
||||||
title?: string;
|
|
||||||
approvals?: BaseApproval[];
|
|
||||||
steps: {
|
|
||||||
step_number: number;
|
|
||||||
step_name: string;
|
|
||||||
}[];
|
|
||||||
maxVisibleSteps?: number;
|
|
||||||
className?: {
|
|
||||||
wrapper?: string;
|
|
||||||
stepsWrapper?: string;
|
|
||||||
stepsContainer?: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApprovalStepsV2 = ({
|
|
||||||
title = 'Progress Details',
|
|
||||||
approvals,
|
|
||||||
steps,
|
|
||||||
maxVisibleSteps = 2,
|
|
||||||
className,
|
|
||||||
}: ApprovalStepsV2Props) => {
|
|
||||||
const [isSeeAll, setIsSeeAll] = useState(false);
|
|
||||||
const [formattedApprovals, setFormattedApprovals] = useState<
|
|
||||||
(BaseApproval & { isActive: boolean })[]
|
|
||||||
>([]);
|
|
||||||
|
|
||||||
const latestApprovalStepNumber =
|
|
||||||
approvals?.[approvals.length - 1].step_number ?? 0;
|
|
||||||
|
|
||||||
const lastStepNumber = steps[steps.length - 1].step_number;
|
|
||||||
|
|
||||||
const isLatestApprovalStepNumberLessThanLastStepNumber =
|
|
||||||
latestApprovalStepNumber < lastStepNumber;
|
|
||||||
|
|
||||||
const slicedFormattedApprovals = useMemo(() => {
|
|
||||||
return formattedApprovals.slice(0, isSeeAll ? undefined : maxVisibleSteps);
|
|
||||||
}, [formattedApprovals, isSeeAll]);
|
|
||||||
|
|
||||||
const seeMoreClickHandler = () => {
|
|
||||||
setIsSeeAll((prevVal) => !prevVal);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (approvals) {
|
|
||||||
const tempFormattedApprovals: (BaseApproval & { isActive: boolean })[] =
|
|
||||||
[];
|
|
||||||
|
|
||||||
approvals.forEach((approval) => {
|
|
||||||
tempFormattedApprovals.push({
|
|
||||||
...approval,
|
|
||||||
isActive: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isLatestApprovalStepNumberLessThanLastStepNumber) {
|
|
||||||
const latestApprovalStepNumberIndexInSteps = steps.findIndex(
|
|
||||||
(step) => step.step_number === latestApprovalStepNumber
|
|
||||||
);
|
|
||||||
|
|
||||||
const slicedSteps = steps.slice(
|
|
||||||
latestApprovalStepNumberIndexInSteps + 1
|
|
||||||
);
|
|
||||||
|
|
||||||
slicedSteps.forEach((step) => {
|
|
||||||
tempFormattedApprovals.push({
|
|
||||||
action: 'APPROVED',
|
|
||||||
action_at: new Date().toISOString(),
|
|
||||||
action_by: {
|
|
||||||
id: 0,
|
|
||||||
id_user: 0,
|
|
||||||
email: '',
|
|
||||||
name: '',
|
|
||||||
},
|
|
||||||
step_name: step.step_name,
|
|
||||||
step_number: step.step_number,
|
|
||||||
isActive: false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setFormattedApprovals(tempFormattedApprovals);
|
|
||||||
}
|
|
||||||
}, [approvals]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
'w-full p-4 flex flex-col border-b border-base-content/10',
|
|
||||||
className?.wrapper
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<h4 className='text-base font-medium text-base-content/50 font-roboto'>
|
|
||||||
{title}
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
'mt-6 mb-8 flex flex-col gap-10',
|
|
||||||
className?.stepsWrapper
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{slicedFormattedApprovals.map((approval, idx) => {
|
|
||||||
const isApprovalActionCreated = approval.action === 'CREATED';
|
|
||||||
const isApprovalActionUpdated = approval.action === 'UPDATED';
|
|
||||||
const isApprovalActionRejected = approval.action === 'REJECTED';
|
|
||||||
const isApprovalActionApproved = approval.action === 'APPROVED';
|
|
||||||
|
|
||||||
const approvalIcon =
|
|
||||||
isApprovalActionCreated || isApprovalActionUpdated
|
|
||||||
? 'heroicons:clock-solid'
|
|
||||||
: isApprovalActionRejected
|
|
||||||
? 'heroicons:x-circle-solid'
|
|
||||||
: isApprovalActionApproved
|
|
||||||
? 'heroicons:check-badge-solid'
|
|
||||||
: 'heroicons:check-badge-solid';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div key={idx} className='w-full flex flex-row items-stretch gap-3'>
|
|
||||||
<div className='w-fit self-stretch relative'>
|
|
||||||
<div className='w-fit h-fit flex flex-col items-start'>
|
|
||||||
<Icon
|
|
||||||
icon={approvalIcon}
|
|
||||||
width={24}
|
|
||||||
height={24}
|
|
||||||
className={cn({
|
|
||||||
'text-warning':
|
|
||||||
isApprovalActionCreated || isApprovalActionUpdated,
|
|
||||||
'text-error': isApprovalActionRejected,
|
|
||||||
'text-success': isApprovalActionApproved,
|
|
||||||
'text-base-content/20': !approval.isActive,
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{idx < formattedApprovals.length - 1 && (
|
|
||||||
<div className='absolute top-6 left-1/2 -translate-x-1/2 w-0 min-h-full h-[calc(100%)] mx-auto my-2 border border-dashed border-base-content/10' />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
className={cn('w-full flex flex-col gap-1 text-base-content', {
|
|
||||||
'text-base-content/20': !approval.isActive,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<div className='flex flex-col'>
|
|
||||||
<span className='text-xs'>{approval.step_name}</span>
|
|
||||||
<span className='text-sm font-semibold'>
|
|
||||||
{(isApprovalActionCreated || isApprovalActionUpdated) &&
|
|
||||||
'Diajukan oleh '}
|
|
||||||
{isApprovalActionRejected && 'Ditolak oleh '}
|
|
||||||
{isApprovalActionApproved && 'Disetujui oleh '}
|
|
||||||
{approval.isActive ? approval.action_by.name : '...'}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{approval.isActive && (
|
|
||||||
<p className='w-full max-w-60 p-3 bg-base-content/5 rounded-xl text-xs text-base-content/50'>
|
|
||||||
Created at :{' '}
|
|
||||||
{formatDate(approval.action_at, 'DD-MM-YYYY, HH:mm')}
|
|
||||||
<br />
|
|
||||||
Notes : {approval.notes ?? '-'}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{formattedApprovals.length > maxVisibleSteps && (
|
|
||||||
<Button
|
|
||||||
variant='outline'
|
|
||||||
color='none'
|
|
||||||
onClick={seeMoreClickHandler}
|
|
||||||
className={cn(
|
|
||||||
'px-3 py-2 gap-2.5 text-sm text-base-content/50 border border-base-content/10 rounded-lg transition-all'
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Icon
|
|
||||||
icon='heroicons-outline:chevron-double-down'
|
|
||||||
width={20}
|
|
||||||
height={20}
|
|
||||||
className={cn('transition-all duration-300', {
|
|
||||||
'-rotate-180': isSeeAll,
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
See {isSeeAll ? 'Less' : 'More'}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ApprovalStepsV2;
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
import Button, { ButtonProps } from '@/components/Button';
|
|
||||||
import { getFilledFormikValuesCount } from '@/lib/formik-helper';
|
|
||||||
import { cn } from '@/lib/helper';
|
|
||||||
import { Icon } from '@iconify/react';
|
|
||||||
import { FormikValues } from 'formik';
|
|
||||||
import { useMemo } from 'react';
|
|
||||||
|
|
||||||
export type ButtonFilterProps = ButtonProps & {
|
|
||||||
values: FormikValues;
|
|
||||||
onClick: () => void;
|
|
||||||
excludeFields?: string[];
|
|
||||||
fieldGroups?: string[][];
|
|
||||||
};
|
|
||||||
|
|
||||||
// 'bg-gradient-to-t from-blue-50 to-blue-100 border-blue-500 text-blue-600 hover:from-blue-100 hover:to-blue-200
|
|
||||||
|
|
||||||
const ButtonFilter = ({
|
|
||||||
values,
|
|
||||||
onClick,
|
|
||||||
excludeFields = [],
|
|
||||||
fieldGroups = [],
|
|
||||||
...props
|
|
||||||
}: ButtonFilterProps) => {
|
|
||||||
const activeCount = useMemo(() => {
|
|
||||||
const filteredValues: FormikValues = {};
|
|
||||||
Object.keys(values).forEach((key) => {
|
|
||||||
if (!excludeFields.includes(key)) {
|
|
||||||
filteredValues[key] = values[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let count = getFilledFormikValuesCount(filteredValues);
|
|
||||||
|
|
||||||
fieldGroups.forEach((group) => {
|
|
||||||
const groupFields = group.filter(
|
|
||||||
(field) => !excludeFields.includes(field)
|
|
||||||
);
|
|
||||||
const filledGroupFields = groupFields.filter(
|
|
||||||
(field) => filteredValues[field]
|
|
||||||
);
|
|
||||||
if (
|
|
||||||
filledGroupFields.length === groupFields.length &&
|
|
||||||
groupFields.length > 1
|
|
||||||
) {
|
|
||||||
count -= groupFields.length - 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}, [values, excludeFields, fieldGroups]);
|
|
||||||
return (
|
|
||||||
<Button
|
|
||||||
{...props}
|
|
||||||
onClick={onClick}
|
|
||||||
variant='outline'
|
|
||||||
color='none'
|
|
||||||
className={cn(
|
|
||||||
'rounded-lg max-h-10 font-semibold text-sm gap-1.5',
|
|
||||||
'text-sm text-base-content/50 border border-base-content/10 shadow-button-soft',
|
|
||||||
activeCount > 0
|
|
||||||
? 'border-primary-gradient text-primary rounded-lg!'
|
|
||||||
: 'rounded-lg',
|
|
||||||
props.className
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Icon
|
|
||||||
icon='heroicons:funnel'
|
|
||||||
width={20}
|
|
||||||
height={20}
|
|
||||||
className={activeCount > 0 ? 'text-blue-600' : ''}
|
|
||||||
/>
|
|
||||||
Filter
|
|
||||||
{activeCount > 0 && (
|
|
||||||
<span className='w-5 h-5 text-white bg-[#FF3535] rounded-lg border border-base-300 flex items-center justify-center text-xs'>
|
|
||||||
{activeCount}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ButtonFilter;
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import Button from '@/components/Button';
|
|
||||||
|
|
||||||
const PageNotFound = () => {
|
|
||||||
return (
|
|
||||||
<div className='w-full h-full flex-1 flex flex-col justify-center items-center gap-4'>
|
|
||||||
<h2 className='text-2xl font-bold text-error'>Halaman Tidak Ditemukan</h2>
|
|
||||||
<p className='text-gray-600 text-center'>
|
|
||||||
Halaman atau data yang anda cari tidak ditemukan.
|
|
||||||
</p>
|
|
||||||
<Button href='/dashboard' className='text-base-100'>
|
|
||||||
Kembali ke Dashboard
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default PageNotFound;
|
|
||||||
@@ -1,17 +1,10 @@
|
|||||||
import Button from '@/components/Button';
|
|
||||||
|
|
||||||
const PermissionNotFound = () => {
|
const PermissionNotFound = () => {
|
||||||
return (
|
return (
|
||||||
<div className='w-full h-screen flex flex-col justify-center items-center gap-4'>
|
<div className='w-full h-screen flex flex-col justify-center items-center gap-4'>
|
||||||
<h2 className='text-2xl font-bold text-error'>
|
<h2 className='text-2xl font-bold text-error'>Permission Not Found</h2>
|
||||||
Hak Akses Tidak Ditemukan
|
|
||||||
</h2>
|
|
||||||
<p className='text-gray-600 text-center'>
|
<p className='text-gray-600 text-center'>
|
||||||
Anda tidak memiliki hak akses untuk mengakses halaman ini.
|
You do not have permission to access this page.
|
||||||
</p>
|
</p>
|
||||||
<Button href='/dashboard' className='text-base-100'>
|
|
||||||
Kembali ke Dashboard
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import useSWR from 'swr';
|
|||||||
|
|
||||||
import { useAuth } from '@/services/hooks/useAuth';
|
import { useAuth } from '@/services/hooks/useAuth';
|
||||||
import { httpClientFetcher, SWRHttpKey } from '@/services/http/client';
|
import { httpClientFetcher, SWRHttpKey } from '@/services/http/client';
|
||||||
import { AuthApi } from '@/services/api/auth';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { BaseApiResponse, GetMeResponse } from '@/types/api/api-general';
|
import { BaseApiResponse, GetMeResponse } from '@/types/api/api-general';
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
@@ -29,8 +28,8 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
|
|||||||
>('/sso/userinfo', httpClientFetcher, {
|
>('/sso/userinfo', httpClientFetcher, {
|
||||||
shouldRetryOnError: false,
|
shouldRetryOnError: false,
|
||||||
|
|
||||||
// refresh every 12 minutes
|
// refresh every 13 minutes
|
||||||
refreshInterval: 12 * 60 * 1000,
|
refreshInterval: 13 * 60 * 1000,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -56,27 +55,6 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
|
|||||||
setIsLoadingUser(isLoadingUserResponse);
|
setIsLoadingUser(isLoadingUserResponse);
|
||||||
}, [isLoadingUserResponse]);
|
}, [isLoadingUserResponse]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const interval = setInterval(
|
|
||||||
async () => {
|
|
||||||
await AuthApi.refresh();
|
|
||||||
},
|
|
||||||
12 * 60 * 1000
|
|
||||||
);
|
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const refreshUserSession = async () => {
|
|
||||||
await AuthApi.refresh();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (user) {
|
|
||||||
refreshUserSession();
|
|
||||||
}
|
|
||||||
}, [user]);
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(isLoadingUserResponse && !userResponse && !userErrorResponse) ||
|
(isLoadingUserResponse && !userResponse && !userErrorResponse) ||
|
||||||
(!userResponse && !userErrorResponse)
|
(!userResponse && !userErrorResponse)
|
||||||
@@ -88,7 +66,7 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadingUserResponse && userErrorResponse) {
|
if (userErrorResponse) {
|
||||||
return (
|
return (
|
||||||
<div className='w-full h-screen flex flex-col justify-center items-center gap-4'>
|
<div className='w-full h-screen flex flex-col justify-center items-center gap-4'>
|
||||||
<h2 className='text-2xl font-bold text-error'>Authentication Failed</h2>
|
<h2 className='text-2xl font-bold text-error'>Authentication Failed</h2>
|
||||||
@@ -96,7 +74,10 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
|
|||||||
Please try refreshing the page or contact support if the problem
|
Please try refreshing the page or contact support if the problem
|
||||||
persists.
|
persists.
|
||||||
</p>
|
</p>
|
||||||
<button className='btn btn-primary' onClick={() => redirectToSSO()}>
|
<button
|
||||||
|
className='btn btn-primary'
|
||||||
|
onClick={() => window.location.reload()}
|
||||||
|
>
|
||||||
Retry
|
Retry
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
import { ReactNode } from 'react';
|
|
||||||
|
|
||||||
import Badge from '@/components/Badge';
|
|
||||||
|
|
||||||
import { cn } from '@/lib/helper';
|
|
||||||
import { Color } from '@/types/theme';
|
|
||||||
|
|
||||||
interface StatusBadgeProps {
|
|
||||||
color: Color;
|
|
||||||
text: ReactNode;
|
|
||||||
className?: {
|
|
||||||
badge?: string;
|
|
||||||
status?: string;
|
|
||||||
};
|
|
||||||
onClick?: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const StatusBadge = ({
|
|
||||||
color = 'neutral',
|
|
||||||
text,
|
|
||||||
className,
|
|
||||||
onClick,
|
|
||||||
}: StatusBadgeProps) => {
|
|
||||||
return (
|
|
||||||
<Badge
|
|
||||||
variant='soft'
|
|
||||||
onClick={onClick}
|
|
||||||
className={{
|
|
||||||
badge: cn(
|
|
||||||
'px-2 py-1 w-full flex flex-row justify-start gap-1 rounded-lg border border-base-content/10 text-xs font-medium text-base-content',
|
|
||||||
{
|
|
||||||
'bg-base-content/5': color === 'neutral',
|
|
||||||
'bg-success/30': color === 'success',
|
|
||||||
'bg-error/20': color === 'error',
|
|
||||||
'bg-primary/20': color === 'info',
|
|
||||||
'bg-[#FF9A20]/12': color === 'warning',
|
|
||||||
'bg-[#1166EF]/12': color === 'primary',
|
|
||||||
},
|
|
||||||
className?.badge
|
|
||||||
),
|
|
||||||
status: cn(className?.status),
|
|
||||||
}}
|
|
||||||
color={color}
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
height='12'
|
|
||||||
width='12'
|
|
||||||
xmlns='http://www.w3.org/2000/svg'
|
|
||||||
className={cn({
|
|
||||||
'text-base-content/10': color === 'neutral',
|
|
||||||
'text-[#008000]': color === 'success',
|
|
||||||
'text-error': color === 'error',
|
|
||||||
'text-primary': color === 'info',
|
|
||||||
'text-[#FF9A20]': color === 'warning',
|
|
||||||
'text-[#1166EF]': color === 'primary',
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<circle r='6' cx='6' cy='6' fill='currentColor' />
|
|
||||||
</svg>
|
|
||||||
|
|
||||||
{text}
|
|
||||||
</Badge>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default StatusBadge;
|
|
||||||
@@ -27,7 +27,7 @@ export interface DrawerHeaderProps {
|
|||||||
|
|
||||||
const DrawerHeader = ({
|
const DrawerHeader = ({
|
||||||
leftIcon = 'mdi:close',
|
leftIcon = 'mdi:close',
|
||||||
leftIconSize = 20,
|
leftIconSize = 24,
|
||||||
leftIconHref,
|
leftIconHref,
|
||||||
leftIconOnClick,
|
leftIconOnClick,
|
||||||
leftIconClassName,
|
leftIconClassName,
|
||||||
@@ -43,7 +43,7 @@ const DrawerHeader = ({
|
|||||||
icon={leftIcon}
|
icon={leftIcon}
|
||||||
width={leftIconSize}
|
width={leftIconSize}
|
||||||
height={leftIconSize}
|
height={leftIconSize}
|
||||||
className={cn('cursor-pointer text-base-content ', leftIconClassName)}
|
className={cn('cursor-pointer', leftIconClassName)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -58,7 +58,6 @@ const DrawerHeader = ({
|
|||||||
if (leftIconOnClick) {
|
if (leftIconOnClick) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type='button'
|
|
||||||
onClick={leftIconOnClick}
|
onClick={leftIconOnClick}
|
||||||
className='hover:text-gray-400 bg-transparent border-none p-0'
|
className='hover:text-gray-400 bg-transparent border-none p-0'
|
||||||
>
|
>
|
||||||
@@ -73,25 +72,20 @@ const DrawerHeader = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex flex-row justify-between items-center p-4 border-b border-base-content/10',
|
'flex flex-row justify-between items-center px-4 pt-4',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{/* Left Side */}
|
{/* Left Side */}
|
||||||
<div className='flex flex-row h-full gap-3 items-center'>
|
<div className='flex flex-row h-full gap-2 items-center'>
|
||||||
{renderLeftIcon()}
|
{renderLeftIcon()}
|
||||||
|
|
||||||
{showDivider && subtitle && (
|
{showDivider && subtitle && (
|
||||||
<div className='w-px h-full border-none bg-base-content/10' />
|
<div className='divider divider-horizontal p-0 m-0'></div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{subtitle && (
|
{subtitle && (
|
||||||
<div
|
<div className={cn('text-sm text-neutral', subtitleClassName)}>
|
||||||
className={cn(
|
|
||||||
'text-sm font-medium text-base-content/50',
|
|
||||||
subtitleClassName
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{subtitle}
|
{subtitle}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import Alert from '@/components/Alert';
|
|
||||||
import Button from '@/components/Button';
|
|
||||||
import { cn } from '@/lib/helper';
|
|
||||||
import { Icon } from '@iconify/react';
|
|
||||||
import { useEffect, useRef } from 'react';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Alert Unique Error List
|
|
||||||
* @param formErrorList - Array of error messages
|
|
||||||
* @param onClose - Function to close the alert
|
|
||||||
*/
|
|
||||||
const AlertErrorList = ({
|
|
||||||
formErrorList,
|
|
||||||
className,
|
|
||||||
onClose,
|
|
||||||
title,
|
|
||||||
}: {
|
|
||||||
formErrorList: string[];
|
|
||||||
className?: {
|
|
||||||
alert?: string;
|
|
||||||
button?: string;
|
|
||||||
headerWrapper?: string;
|
|
||||||
headerIcon?: string;
|
|
||||||
headerText?: string;
|
|
||||||
titleWrapper?: string;
|
|
||||||
ul?: string;
|
|
||||||
li?: string;
|
|
||||||
};
|
|
||||||
onClose: () => void;
|
|
||||||
title?: string;
|
|
||||||
}) => {
|
|
||||||
const alertRef = useRef<HTMLDivElement | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (formErrorList.length > 0) {
|
|
||||||
alertRef.current?.scrollIntoView({
|
|
||||||
behavior: 'smooth',
|
|
||||||
block: 'start',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [formErrorList.length]);
|
|
||||||
|
|
||||||
if (formErrorList.length === 0) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Alert
|
|
||||||
ref={alertRef}
|
|
||||||
color='error'
|
|
||||||
className={cn(
|
|
||||||
'w-full flex flex-col gap-2 px-3 rounded-lg',
|
|
||||||
className?.alert
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
'flex justify-between items-center gap-2 w-full',
|
|
||||||
className?.headerWrapper
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className={cn('flex items-center gap-2', className?.titleWrapper)}>
|
|
||||||
<Icon
|
|
||||||
icon='material-symbols:error-outline'
|
|
||||||
className={cn(className?.headerIcon)}
|
|
||||||
width={20}
|
|
||||||
height={20}
|
|
||||||
/>
|
|
||||||
<span className={cn('font-semibold text-sm', className?.headerText)}>
|
|
||||||
{title || `Terdapat ${formErrorList.length} error pada form:`}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
type='button'
|
|
||||||
onClick={onClose}
|
|
||||||
variant='link'
|
|
||||||
className={cn('ml-auto p-0 w-fit text-white', className?.button)}
|
|
||||||
color='none'
|
|
||||||
>
|
|
||||||
<Icon icon='material-symbols:close' width={20} height={20} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<ul
|
|
||||||
className={cn(
|
|
||||||
'list-disc list-inside pl-4 space-y-1.5 w-full',
|
|
||||||
className?.ul
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{formErrorList.map((error, index) => (
|
|
||||||
<li key={index} className={cn('text-sm', className?.li)}>
|
|
||||||
{error}
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</Alert>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AlertErrorList;
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user