Compare commits
143
Commits
9f934ce5c7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2641175e04 | ||
|
|
c78b32d7b8 | ||
|
|
e8609a0ab9 | ||
|
|
b22f400534 | ||
|
|
b506d97c06 | ||
|
|
a3dd214a99 | ||
|
|
3c13aa897c | ||
|
|
f4783236d2 | ||
|
|
67ebb2ebd7 | ||
|
|
de32d86e94 | ||
|
|
3cf7799a91 | ||
|
|
37de68879c | ||
|
|
80bab20f89 | ||
|
|
6b46f9070a | ||
|
|
c5cda37efb | ||
|
|
2897436c5f | ||
|
|
fe4176621c | ||
|
|
16deaf1890 | ||
|
|
f434373eaf | ||
|
|
8e4ab5dd69 | ||
|
|
5f65211432 | ||
|
|
ead773982a | ||
|
|
aae1d49721 | ||
|
|
347d00271b | ||
|
|
ac2fc4e920 | ||
|
|
e551ae7feb | ||
|
|
d059f31eaa | ||
|
|
f1cf351ca4 | ||
|
|
801fcdda2f | ||
|
|
4ba5b9def3 | ||
|
|
116f6b8009 | ||
|
|
1b9908e882 | ||
|
|
d245074904 | ||
|
|
8672f01261 | ||
|
|
256f035997 | ||
|
|
bd14adde23 | ||
|
|
726d1f4984 | ||
|
|
35b1426384 | ||
|
|
9b92f4742f | ||
|
|
1bf2bad52c | ||
|
|
e55357e305 | ||
|
|
9806400308 | ||
|
|
3bfd0b9e19 | ||
|
|
f98b61e527 | ||
|
|
97ed613cc6 | ||
|
|
fdcb0e12f4 | ||
|
|
7570e973b8 | ||
|
|
e82173c6e2 | ||
|
|
4640d14cb7 | ||
|
|
3a56e56c69 | ||
|
|
6d2e436b09 | ||
|
|
7252c05569 | ||
|
|
757d9f524a | ||
|
|
a6f80bbd02 | ||
|
|
8ed2786bc2 | ||
|
|
4655411b24 | ||
|
|
185edb94cb | ||
|
|
2643963b49 | ||
|
|
18ee652731 | ||
|
|
3d1b6eee39 | ||
|
|
966081214f | ||
|
|
1c5740a85b | ||
|
|
f527b6f004 | ||
|
|
84454e66dc | ||
|
|
54d8ff3444 | ||
|
|
ddbd5ba607 | ||
|
|
50a8f4a295 | ||
|
|
fb6e2571a5 | ||
|
|
5de78cb78f | ||
|
|
d85f081d3a | ||
|
|
f3358705b0 | ||
|
|
9959775c77 | ||
|
|
14efada9bb | ||
|
|
7384b38df5 | ||
|
|
7f646b82a9 | ||
|
|
fab31f1540 | ||
|
|
aa2946e627 | ||
|
|
2d3274d3bf | ||
|
|
e1084277e0 | ||
|
|
222beb5043 | ||
|
|
98d6446b0c | ||
|
|
d54d623d4c | ||
|
|
140822763e | ||
|
|
0b51b29474 | ||
|
|
20203942d2 | ||
|
|
b2840ca27c | ||
|
|
ce344e4a98 | ||
|
|
2d69a024c1 | ||
|
|
27fe48e99e | ||
|
|
5a0d96ee43 | ||
|
|
9cbb41c2ad | ||
|
|
76ee71e7fe | ||
|
|
54c7598e7a | ||
|
|
40c417ec72 | ||
|
|
c91be1812b | ||
|
|
3a74e32e64 | ||
|
|
8026004630 | ||
|
|
0e8216b0c9 | ||
|
|
e8c1d02843 | ||
|
|
a019a4bdbc | ||
|
|
5def10dc64 | ||
|
|
5723d49090 | ||
|
|
1a9015563f | ||
|
|
34442740e2 | ||
|
|
e13fbab564 | ||
|
|
f2eb142dec | ||
|
|
a1d23cad9e | ||
|
|
b3a41fe0e0 | ||
|
|
5a77d3c2ea | ||
|
|
29defb68c8 | ||
|
|
c9e260860c | ||
|
|
9c1b1fc1db | ||
|
|
42b95bb212 | ||
|
|
63eea38d48 | ||
|
|
630d9c0e65 | ||
|
|
e267a50946 | ||
|
|
2c754d96fd | ||
|
|
66589abdd4 | ||
|
|
00620026e4 | ||
|
|
afa4cfad0d | ||
|
|
420df71452 | ||
|
|
7077bf8d87 | ||
|
|
c32d08666e | ||
|
|
8461e1f4b7 | ||
|
|
8ec6ba62f3 | ||
|
|
ce9f845fe4 | ||
|
|
cc3a0c07a9 | ||
|
|
f585f23c54 | ||
|
|
9b787e65d4 | ||
|
|
d0d5d066a1 | ||
|
|
b20e672ea1 | ||
|
|
49ed3386be | ||
|
|
4c4579f009 | ||
|
|
dfa8218017 | ||
|
|
849013a08a | ||
|
|
5dc62b8390 | ||
|
|
dfa6b4be75 | ||
|
|
59f2d45854 | ||
|
|
105d75c820 | ||
|
|
789dd823b6 | ||
|
|
d58bf1983c | ||
|
|
0528cfa053 | ||
|
|
17f059f09d |
@@ -39,3 +39,5 @@ next-env.d.ts
|
|||||||
# icon generated file
|
# icon generated file
|
||||||
src/assets/iconify-icons/generated-icons.js
|
src/assets/iconify-icons/generated-icons.js
|
||||||
src/assets/iconify-icons/generated-icons.css
|
src/assets/iconify-icons/generated-icons.css
|
||||||
|
|
||||||
|
*.backup
|
||||||
|
|||||||
Generated
+1222
-58
File diff suppressed because it is too large
Load Diff
+9
-2
@@ -30,6 +30,7 @@
|
|||||||
"@fullcalendar/list": "6.1.15",
|
"@fullcalendar/list": "6.1.15",
|
||||||
"@fullcalendar/react": "6.1.15",
|
"@fullcalendar/react": "6.1.15",
|
||||||
"@fullcalendar/timegrid": "6.1.15",
|
"@fullcalendar/timegrid": "6.1.15",
|
||||||
|
"@hello-pangea/dnd": "^18.0.1",
|
||||||
"@hookform/resolvers": "3.9.1",
|
"@hookform/resolvers": "3.9.1",
|
||||||
"@iconify/react": "^6.0.1",
|
"@iconify/react": "^6.0.1",
|
||||||
"@mui/lab": "6.0.0-beta.19",
|
"@mui/lab": "6.0.0-beta.19",
|
||||||
@@ -52,18 +53,23 @@
|
|||||||
"apexcharts": "3.49.0",
|
"apexcharts": "3.49.0",
|
||||||
"axios": "^1.11.0",
|
"axios": "^1.11.0",
|
||||||
"bootstrap-icons": "1.11.3",
|
"bootstrap-icons": "1.11.3",
|
||||||
|
"chart.js": "^4.5.1",
|
||||||
|
"chartjs-plugin-datalabels": "^2.2.0",
|
||||||
"classnames": "2.5.1",
|
"classnames": "2.5.1",
|
||||||
"cmdk": "1.0.4",
|
"cmdk": "1.0.4",
|
||||||
"date-fns": "4.1.0",
|
"date-fns": "4.1.0",
|
||||||
"emoji-mart": "5.6.0",
|
"emoji-mart": "5.6.0",
|
||||||
|
"exceljs": "^4.4.0",
|
||||||
"fs-extra": "11.2.0",
|
"fs-extra": "11.2.0",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
"input-otp": "1.4.1",
|
"input-otp": "1.4.1",
|
||||||
"jspdf": "^3.0.1",
|
"jspdf": "^3.0.1",
|
||||||
|
"jspdf-autotable": "^5.0.2",
|
||||||
"keen-slider": "6.8.6",
|
"keen-slider": "6.8.6",
|
||||||
|
"lucide-react": "^0.544.0",
|
||||||
"mapbox-gl": "3.9.0",
|
"mapbox-gl": "3.9.0",
|
||||||
"negotiator": "1.0.0",
|
"negotiator": "1.0.0",
|
||||||
"next": "15.1.2",
|
"next": "^15.1.9",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"react-apexcharts": "1.4.1",
|
"react-apexcharts": "1.4.1",
|
||||||
"react-colorful": "5.6.1",
|
"react-colorful": "5.6.1",
|
||||||
@@ -79,7 +85,8 @@
|
|||||||
"react-use": "17.6.0",
|
"react-use": "17.6.0",
|
||||||
"recharts": "2.15.0",
|
"recharts": "2.15.0",
|
||||||
"use-debounce": "^10.0.5",
|
"use-debounce": "^10.0.5",
|
||||||
"valibot": "0.42.1"
|
"valibot": "0.42.1",
|
||||||
|
"xlsx": "^0.18.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@iconify/json": "2.2.286",
|
"@iconify/json": "2.2.286",
|
||||||
|
|||||||
@@ -0,0 +1,976 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
|
import { RotateCw, Trophy, Trash2, RefreshCw, Shuffle, Sparkles, Gift } from 'lucide-react';
|
||||||
|
import { useVoucherRows } from '@/services/queries/vouchers';
|
||||||
|
import { Voucher, VoucherRow } from '@/types/services/voucher';
|
||||||
|
import { toast } from 'react-toastify';
|
||||||
|
|
||||||
|
interface SpinRow {
|
||||||
|
id: string;
|
||||||
|
rowNumber: number;
|
||||||
|
vouchers: Voucher[];
|
||||||
|
displayVouchers: Voucher[];
|
||||||
|
isSpinning: boolean;
|
||||||
|
isShuffling: boolean;
|
||||||
|
winner: Voucher | null;
|
||||||
|
wheelRef: React.RefObject<HTMLDivElement>;
|
||||||
|
selectedWinner: Voucher | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface WinnerHistory {
|
||||||
|
rowNumber: number;
|
||||||
|
winner: Voucher;
|
||||||
|
timestamp: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
const RandomDrawApp: React.FC = () => {
|
||||||
|
const [spinRows, setSpinRows] = useState<SpinRow[]>([]);
|
||||||
|
const [numberOfRows, setNumberOfRows] = useState<number>(5);
|
||||||
|
const [winnersHistory, setWinnersHistory] = useState<WinnerHistory[]>([]);
|
||||||
|
const [isRevealingWinners, setIsRevealingWinners] = useState<boolean>(false);
|
||||||
|
const [revealedWinners, setRevealedWinners] = useState<Set<number>>(new Set());
|
||||||
|
const [isSequentialSpinning, setIsSequentialSpinning] = useState<boolean>(false);
|
||||||
|
const [currentSpinningRow, setCurrentSpinningRow] = useState<number | null>(null);
|
||||||
|
const [selectedPrize, setSelectedPrize] = useState<number>(1); // 1 for Emas 0.25 Gram, 2 for Emas 3 Gram
|
||||||
|
const audioContextRef = useRef<AudioContext | null>(null);
|
||||||
|
const tickIntervalRefs = useRef<Map<string, NodeJS.Timeout>>(new Map());
|
||||||
|
const shuffleIntervalRefs = useRef<Map<string, NodeJS.Timeout>>(new Map());
|
||||||
|
|
||||||
|
// Use React Query hook for fetching voucher data - disabled by default
|
||||||
|
const { data: voucherData, isLoading: isLoadingData, refetch: refetchVouchers, error: fetchError } = useVoucherRows({
|
||||||
|
rows: numberOfRows,
|
||||||
|
winner_number: selectedPrize
|
||||||
|
}, {
|
||||||
|
enabled: false // Disable automatic fetching - only fetch when Load Data is clicked
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize Audio Context
|
||||||
|
useEffect(() => {
|
||||||
|
const initAudio = () => {
|
||||||
|
if (!audioContextRef.current) {
|
||||||
|
audioContextRef.current = new (window.AudioContext || (window as any).webkitAudioContext)();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener('click', initAudio, { once: true });
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('click', initAudio);
|
||||||
|
tickIntervalRefs.current.forEach(timeout => clearTimeout(timeout));
|
||||||
|
shuffleIntervalRefs.current.forEach(timeout => clearTimeout(timeout));
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Create tick sound effect
|
||||||
|
const playTickSound = () => {
|
||||||
|
if (!audioContextRef.current) return;
|
||||||
|
|
||||||
|
const ctx = audioContextRef.current;
|
||||||
|
const oscillator = ctx.createOscillator();
|
||||||
|
const gainNode = ctx.createGain();
|
||||||
|
|
||||||
|
oscillator.connect(gainNode);
|
||||||
|
gainNode.connect(ctx.destination);
|
||||||
|
|
||||||
|
oscillator.frequency.setValueAtTime(800, ctx.currentTime);
|
||||||
|
oscillator.frequency.exponentialRampToValueAtTime(200, ctx.currentTime + 0.05);
|
||||||
|
|
||||||
|
gainNode.gain.setValueAtTime(0, ctx.currentTime);
|
||||||
|
gainNode.gain.linearRampToValueAtTime(0.1, ctx.currentTime + 0.01);
|
||||||
|
gainNode.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.05);
|
||||||
|
|
||||||
|
oscillator.start(ctx.currentTime);
|
||||||
|
oscillator.stop(ctx.currentTime + 0.05);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create drum roll sound
|
||||||
|
const playDrumRoll = () => {
|
||||||
|
if (!audioContextRef.current) return;
|
||||||
|
|
||||||
|
const ctx = audioContextRef.current;
|
||||||
|
const oscillator = ctx.createOscillator();
|
||||||
|
const gainNode = ctx.createGain();
|
||||||
|
const noiseNode = ctx.createBufferSource();
|
||||||
|
|
||||||
|
// Create noise buffer for snare-like sound
|
||||||
|
const bufferSize = ctx.sampleRate * 0.05;
|
||||||
|
const buffer = ctx.createBuffer(1, bufferSize, ctx.sampleRate);
|
||||||
|
const data = buffer.getChannelData(0);
|
||||||
|
for (let i = 0; i < bufferSize; i++) {
|
||||||
|
data[i] = Math.random() * 2 - 1;
|
||||||
|
}
|
||||||
|
noiseNode.buffer = buffer;
|
||||||
|
|
||||||
|
oscillator.connect(gainNode);
|
||||||
|
noiseNode.connect(gainNode);
|
||||||
|
gainNode.connect(ctx.destination);
|
||||||
|
|
||||||
|
oscillator.frequency.setValueAtTime(200, ctx.currentTime);
|
||||||
|
gainNode.gain.setValueAtTime(0.05, ctx.currentTime);
|
||||||
|
gainNode.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.1);
|
||||||
|
|
||||||
|
oscillator.start(ctx.currentTime);
|
||||||
|
oscillator.stop(ctx.currentTime + 0.1);
|
||||||
|
noiseNode.start(ctx.currentTime);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create winner sound
|
||||||
|
const playWinnerSound = () => {
|
||||||
|
if (!audioContextRef.current) return;
|
||||||
|
|
||||||
|
const ctx = audioContextRef.current;
|
||||||
|
const notes = [523.25, 659.25, 783.99, 1046.5]; // C, E, G, C (higher octave)
|
||||||
|
|
||||||
|
notes.forEach((freq, index) => {
|
||||||
|
const oscillator = ctx.createOscillator();
|
||||||
|
const gainNode = ctx.createGain();
|
||||||
|
|
||||||
|
oscillator.connect(gainNode);
|
||||||
|
gainNode.connect(ctx.destination);
|
||||||
|
|
||||||
|
oscillator.frequency.setValueAtTime(freq, ctx.currentTime + index * 0.1);
|
||||||
|
|
||||||
|
gainNode.gain.setValueAtTime(0, ctx.currentTime + index * 0.1);
|
||||||
|
gainNode.gain.linearRampToValueAtTime(0.2, ctx.currentTime + index * 0.1 + 0.05);
|
||||||
|
gainNode.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + index * 0.1 + 0.5);
|
||||||
|
|
||||||
|
oscillator.start(ctx.currentTime + index * 0.1);
|
||||||
|
oscillator.stop(ctx.currentTime + index * 0.1 + 0.5);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Start tick sound during spinning
|
||||||
|
const startTickSound = (rowId: string, duration: number) => {
|
||||||
|
const existingInterval = tickIntervalRefs.current.get(rowId);
|
||||||
|
if (existingInterval) {
|
||||||
|
clearTimeout(existingInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
let tickInterval = 50;
|
||||||
|
const maxInterval = 200;
|
||||||
|
const intervalIncrement = (maxInterval - tickInterval) / (duration / 100);
|
||||||
|
|
||||||
|
const tick = () => {
|
||||||
|
playTickSound();
|
||||||
|
tickInterval += intervalIncrement;
|
||||||
|
|
||||||
|
if (tickInterval < maxInterval) {
|
||||||
|
const timeoutId = setTimeout(tick, Math.min(tickInterval, maxInterval));
|
||||||
|
tickIntervalRefs.current.set(rowId, timeoutId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tick();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const interval = tickIntervalRefs.current.get(rowId);
|
||||||
|
if (interval) {
|
||||||
|
clearTimeout(interval);
|
||||||
|
tickIntervalRefs.current.delete(rowId);
|
||||||
|
}
|
||||||
|
}, duration + 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Shuffle array
|
||||||
|
const shuffleArray = <T,>(array: T[]): T[] => {
|
||||||
|
const shuffled = [...array];
|
||||||
|
for (let i = shuffled.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
|
||||||
|
}
|
||||||
|
return shuffled;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Process voucher data when it changes
|
||||||
|
useEffect(() => {
|
||||||
|
if (voucherData && voucherData.rows) {
|
||||||
|
const newSpinRows: SpinRow[] = voucherData.rows.map(row => ({
|
||||||
|
id: `row-${row.row_number}-${Date.now()}`,
|
||||||
|
rowNumber: row.row_number,
|
||||||
|
vouchers: row.vouchers,
|
||||||
|
displayVouchers: [...row.vouchers],
|
||||||
|
isSpinning: false,
|
||||||
|
isShuffling: false,
|
||||||
|
winner: null,
|
||||||
|
wheelRef: React.createRef<HTMLDivElement>(),
|
||||||
|
selectedWinner: null,
|
||||||
|
}));
|
||||||
|
setSpinRows(newSpinRows);
|
||||||
|
setRevealedWinners(new Set());
|
||||||
|
}
|
||||||
|
}, [voucherData]);
|
||||||
|
|
||||||
|
// Show error if fetch failed
|
||||||
|
useEffect(() => {
|
||||||
|
if (fetchError) {
|
||||||
|
toast.error('Failed to load voucher data. Please check your connection and try again.');
|
||||||
|
}
|
||||||
|
}, [fetchError]);
|
||||||
|
|
||||||
|
// Remove auto-refetch - data will only load when Load Data button is clicked
|
||||||
|
|
||||||
|
// Shuffle all rows (Acak functionality)
|
||||||
|
const shuffleAllRows = () => {
|
||||||
|
setSpinRows(prev => prev.map(row => ({
|
||||||
|
...row,
|
||||||
|
isShuffling: true
|
||||||
|
})));
|
||||||
|
|
||||||
|
// Animate shuffling for each row
|
||||||
|
spinRows.forEach((row, index) => {
|
||||||
|
let shuffleCount = 0;
|
||||||
|
const maxShuffles = 20;
|
||||||
|
|
||||||
|
const shuffleInterval = setInterval(() => {
|
||||||
|
shuffleCount++;
|
||||||
|
|
||||||
|
setSpinRows(prev => prev.map(r => {
|
||||||
|
if (r.id === row.id) {
|
||||||
|
return {
|
||||||
|
...r,
|
||||||
|
displayVouchers: shuffleArray(r.vouchers)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}));
|
||||||
|
|
||||||
|
playTickSound();
|
||||||
|
|
||||||
|
if (shuffleCount >= maxShuffles) {
|
||||||
|
clearInterval(shuffleInterval);
|
||||||
|
setTimeout(() => {
|
||||||
|
setSpinRows(prev => prev.map(r => {
|
||||||
|
if (r.id === row.id) {
|
||||||
|
return {
|
||||||
|
...r,
|
||||||
|
isShuffling: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}));
|
||||||
|
}, index * 100);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
shuffleIntervalRefs.current.set(row.id, shuffleInterval as any);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Reveal winners dramatically
|
||||||
|
const revealWinnersDramatically = async () => {
|
||||||
|
setIsRevealingWinners(true);
|
||||||
|
setRevealedWinners(new Set());
|
||||||
|
|
||||||
|
// First, arrange winners to be in the winner zone for each row
|
||||||
|
const arrangedRows = spinRows.map(row => {
|
||||||
|
const winner = row.vouchers.find(v => v.is_winner);
|
||||||
|
if (!winner) return row;
|
||||||
|
|
||||||
|
// Create a new display order with winner at position 3 or 4 (will be in winner zone)
|
||||||
|
const otherVouchers = row.vouchers.filter(v => v.voucher_code !== winner.voucher_code);
|
||||||
|
const shuffledOthers = shuffleArray(otherVouchers);
|
||||||
|
|
||||||
|
// Place winner at index 3 (4th position) which will be in the winner zone
|
||||||
|
const newDisplayVouchers = [
|
||||||
|
...shuffledOthers.slice(0, 3),
|
||||||
|
winner,
|
||||||
|
...shuffledOthers.slice(3)
|
||||||
|
];
|
||||||
|
|
||||||
|
return {
|
||||||
|
...row,
|
||||||
|
displayVouchers: newDisplayVouchers
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update display to show arranged vouchers
|
||||||
|
setSpinRows(arrangedRows);
|
||||||
|
|
||||||
|
// Start drum roll effect
|
||||||
|
const drumRollInterval = setInterval(() => {
|
||||||
|
playDrumRoll();
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
// Create a scrolling/spinning effect for all wheels simultaneously
|
||||||
|
let scrollSpeed = 50;
|
||||||
|
let currentScroll = 0;
|
||||||
|
const maxScroll = 2000;
|
||||||
|
const deceleration = 0.95;
|
||||||
|
|
||||||
|
const spinInterval = setInterval(() => {
|
||||||
|
currentScroll += scrollSpeed;
|
||||||
|
scrollSpeed *= deceleration;
|
||||||
|
|
||||||
|
// Apply scrolling to all wheels
|
||||||
|
arrangedRows.forEach(row => {
|
||||||
|
const wheelElement = row.wheelRef.current;
|
||||||
|
if (wheelElement) {
|
||||||
|
wheelElement.style.transition = 'none';
|
||||||
|
wheelElement.style.transform = `translateY(${-currentScroll}px)`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Stop when speed is very slow
|
||||||
|
if (scrollSpeed < 0.5 || currentScroll >= maxScroll) {
|
||||||
|
clearInterval(spinInterval);
|
||||||
|
clearInterval(drumRollInterval);
|
||||||
|
|
||||||
|
// Final positioning - snap to winner position
|
||||||
|
arrangedRows.forEach(row => {
|
||||||
|
const wheelElement = row.wheelRef.current;
|
||||||
|
if (wheelElement) {
|
||||||
|
const CARD_HEIGHT = 80;
|
||||||
|
const WINNER_ZONE_TOP = 260; // Top position of winner zone
|
||||||
|
// Position 4th card (index 3) exactly at the winner zone
|
||||||
|
const finalPosition = -(3 * CARD_HEIGHT - WINNER_ZONE_TOP);
|
||||||
|
|
||||||
|
wheelElement.style.transition = 'transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94)';
|
||||||
|
wheelElement.style.transform = `translateY(${finalPosition}px)`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 20);
|
||||||
|
|
||||||
|
// Wait for scrolling to complete
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||||
|
|
||||||
|
// Play winner sound
|
||||||
|
playWinnerSound();
|
||||||
|
|
||||||
|
// Collect all winners
|
||||||
|
const winnersToReveal: { row: SpinRow, winner: Voucher }[] = [];
|
||||||
|
arrangedRows.forEach(row => {
|
||||||
|
const winner = row.vouchers.find(v => v.is_winner);
|
||||||
|
if (winner) {
|
||||||
|
winnersToReveal.push({ row, winner });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update all winners at once with highlighting
|
||||||
|
const allWinnerNumbers = new Set<number>();
|
||||||
|
const historyEntries: WinnerHistory[] = [];
|
||||||
|
|
||||||
|
winnersToReveal.forEach(({ row, winner }) => {
|
||||||
|
allWinnerNumbers.add(row.rowNumber);
|
||||||
|
historyEntries.push({
|
||||||
|
rowNumber: row.rowNumber,
|
||||||
|
winner: winner,
|
||||||
|
timestamp: new Date()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update state to highlight winners
|
||||||
|
setRevealedWinners(allWinnerNumbers);
|
||||||
|
|
||||||
|
setSpinRows(prev => prev.map(r => {
|
||||||
|
const winnerInfo = winnersToReveal.find(w => w.row.id === r.id);
|
||||||
|
if (winnerInfo) {
|
||||||
|
return {
|
||||||
|
...r,
|
||||||
|
winner: winnerInfo.winner,
|
||||||
|
selectedWinner: winnerInfo.winner
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}));
|
||||||
|
|
||||||
|
setWinnersHistory(prev => [...prev, ...historyEntries]);
|
||||||
|
|
||||||
|
setIsRevealingWinners(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const performDramaticSpin = (row: SpinRow, isSequential: boolean = false) => {
|
||||||
|
const wheelElement = row.wheelRef.current;
|
||||||
|
if (!wheelElement) return;
|
||||||
|
|
||||||
|
const winner = row.vouchers.find(v => v.is_winner);
|
||||||
|
if (!winner) {
|
||||||
|
console.error('No winner found in vouchers');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CARD_HEIGHT = 80;
|
||||||
|
const WINNER_ZONE_TOP = 260; // Top position of winner zone
|
||||||
|
|
||||||
|
// Shuffle the display vouchers to create more dramatic effect
|
||||||
|
const shuffledVouchers = shuffleArray([...row.vouchers]);
|
||||||
|
const winnerIndex = shuffledVouchers.findIndex(v => v.voucher_code === winner.voucher_code);
|
||||||
|
|
||||||
|
// Update display vouchers with shuffled order
|
||||||
|
setSpinRows(prev => prev.map(r =>
|
||||||
|
r.id === row.id ? { ...r, displayVouchers: shuffledVouchers } : r
|
||||||
|
));
|
||||||
|
|
||||||
|
wheelElement.style.transition = 'none';
|
||||||
|
wheelElement.style.transform = 'translateY(0px)';
|
||||||
|
wheelElement.offsetHeight;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
// More dramatic spinning with multiple phases
|
||||||
|
const minSpins = 15;
|
||||||
|
const maxSpins = 25;
|
||||||
|
const spins = minSpins + Math.random() * (maxSpins - minSpins);
|
||||||
|
const totalItems = shuffledVouchers.length;
|
||||||
|
|
||||||
|
const totalRotations = Math.floor(spins);
|
||||||
|
const baseScrollDistance = totalRotations * totalItems * CARD_HEIGHT;
|
||||||
|
const winnerScrollPosition = winnerIndex * CARD_HEIGHT;
|
||||||
|
const finalPosition = -(baseScrollDistance + winnerScrollPosition) + WINNER_ZONE_TOP;
|
||||||
|
|
||||||
|
const distance = Math.abs(finalPosition);
|
||||||
|
const baseDuration = 4000; // Longer base duration
|
||||||
|
const maxDuration = 7000; // Longer max duration
|
||||||
|
const duration = Math.min(baseDuration + (distance / 8000) * 2000, maxDuration);
|
||||||
|
|
||||||
|
// Phase 1: Fast initial spin
|
||||||
|
const phase1Duration = duration * 0.3;
|
||||||
|
const phase1Distance = finalPosition * 0.7;
|
||||||
|
|
||||||
|
wheelElement.style.transform = `translateY(${phase1Distance}px)`;
|
||||||
|
wheelElement.style.transition = `transform ${phase1Duration}ms cubic-bezier(0.25, 0.46, 0.45, 0.94)`;
|
||||||
|
|
||||||
|
// Phase 2: Slower approach to final position
|
||||||
|
setTimeout(() => {
|
||||||
|
wheelElement.style.transform = `translateY(${finalPosition}px)`;
|
||||||
|
wheelElement.style.transition = `transform ${duration - phase1Duration}ms cubic-bezier(0.17, 0.67, 0.12, 0.99)`;
|
||||||
|
}, phase1Duration);
|
||||||
|
|
||||||
|
startTickSound(row.id, duration);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const interval = tickIntervalRefs.current.get(row.id);
|
||||||
|
if (interval) {
|
||||||
|
clearTimeout(interval);
|
||||||
|
tickIntervalRefs.current.delete(row.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
playWinnerSound();
|
||||||
|
|
||||||
|
setSpinRows(prev => prev.map(r =>
|
||||||
|
r.id === row.id
|
||||||
|
? { ...r, isSpinning: false, winner: winner, selectedWinner: winner }
|
||||||
|
: r
|
||||||
|
));
|
||||||
|
|
||||||
|
setWinnersHistory(prev => [...prev, {
|
||||||
|
rowNumber: row.rowNumber,
|
||||||
|
winner: winner,
|
||||||
|
timestamp: new Date()
|
||||||
|
}]);
|
||||||
|
|
||||||
|
// If this is sequential spinning, trigger next row
|
||||||
|
if (isSequential) {
|
||||||
|
const nextRowIndex = spinRows.findIndex(r => r.id === row.id) + 1;
|
||||||
|
if (nextRowIndex < spinRows.length) {
|
||||||
|
setTimeout(() => {
|
||||||
|
spinSequentialRow(nextRowIndex);
|
||||||
|
}, 2000); // Wait 2 seconds before next spin
|
||||||
|
} else {
|
||||||
|
// All rows completed
|
||||||
|
setIsSequentialSpinning(false);
|
||||||
|
setCurrentSpinningRow(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep the winner in the winner zone - don't reset position
|
||||||
|
// The winning card will stay exactly where it landed in the winner zone
|
||||||
|
|
||||||
|
}, duration);
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
const performSpin = (row: SpinRow) => {
|
||||||
|
const wheelElement = row.wheelRef.current;
|
||||||
|
if (!wheelElement) return;
|
||||||
|
|
||||||
|
const winner = row.vouchers.find(v => v.is_winner);
|
||||||
|
if (!winner) {
|
||||||
|
console.error('No winner found in vouchers');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CARD_HEIGHT = 80;
|
||||||
|
const WINNER_ZONE_TOP = 260; // Top position of winner zone
|
||||||
|
|
||||||
|
// Shuffle the display vouchers to create more dramatic effect
|
||||||
|
const shuffledVouchers = shuffleArray([...row.vouchers]);
|
||||||
|
const winnerIndex = shuffledVouchers.findIndex(v => v.voucher_code === winner.voucher_code);
|
||||||
|
|
||||||
|
// Update display vouchers with shuffled order
|
||||||
|
setSpinRows(prev => prev.map(r =>
|
||||||
|
r.id === row.id ? { ...r, displayVouchers: shuffledVouchers } : r
|
||||||
|
));
|
||||||
|
|
||||||
|
wheelElement.style.transition = 'none';
|
||||||
|
wheelElement.style.transform = 'translateY(0px)';
|
||||||
|
wheelElement.offsetHeight;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
// More dramatic spinning with multiple phases
|
||||||
|
const minSpins = 15;
|
||||||
|
const maxSpins = 25;
|
||||||
|
const spins = minSpins + Math.random() * (maxSpins - minSpins);
|
||||||
|
const totalItems = shuffledVouchers.length;
|
||||||
|
|
||||||
|
const totalRotations = Math.floor(spins);
|
||||||
|
const baseScrollDistance = totalRotations * totalItems * CARD_HEIGHT;
|
||||||
|
const winnerScrollPosition = winnerIndex * CARD_HEIGHT;
|
||||||
|
const finalPosition = -(baseScrollDistance + winnerScrollPosition) + WINNER_ZONE_TOP;
|
||||||
|
|
||||||
|
const distance = Math.abs(finalPosition);
|
||||||
|
const baseDuration = 4000; // Longer base duration
|
||||||
|
const maxDuration = 7000; // Longer max duration
|
||||||
|
const duration = Math.min(baseDuration + (distance / 8000) * 2000, maxDuration);
|
||||||
|
|
||||||
|
// Phase 1: Fast initial spin
|
||||||
|
const phase1Duration = duration * 0.3;
|
||||||
|
const phase1Distance = finalPosition * 0.7;
|
||||||
|
|
||||||
|
wheelElement.style.transform = `translateY(${phase1Distance}px)`;
|
||||||
|
wheelElement.style.transition = `transform ${phase1Duration}ms cubic-bezier(0.25, 0.46, 0.45, 0.94)`;
|
||||||
|
|
||||||
|
// Phase 2: Slower approach to final position
|
||||||
|
setTimeout(() => {
|
||||||
|
wheelElement.style.transform = `translateY(${finalPosition}px)`;
|
||||||
|
wheelElement.style.transition = `transform ${duration - phase1Duration}ms cubic-bezier(0.17, 0.67, 0.12, 0.99)`;
|
||||||
|
}, phase1Duration);
|
||||||
|
|
||||||
|
startTickSound(row.id, duration);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const interval = tickIntervalRefs.current.get(row.id);
|
||||||
|
if (interval) {
|
||||||
|
clearTimeout(interval);
|
||||||
|
tickIntervalRefs.current.delete(row.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
playWinnerSound();
|
||||||
|
|
||||||
|
setSpinRows(prev => prev.map(r =>
|
||||||
|
r.id === row.id
|
||||||
|
? { ...r, isSpinning: false, winner: winner, selectedWinner: winner }
|
||||||
|
: r
|
||||||
|
));
|
||||||
|
|
||||||
|
setWinnersHistory(prev => [...prev, {
|
||||||
|
rowNumber: row.rowNumber,
|
||||||
|
winner: winner,
|
||||||
|
timestamp: new Date()
|
||||||
|
}]);
|
||||||
|
|
||||||
|
// Keep the winner in the winner zone - don't reset position
|
||||||
|
// The winning card will stay exactly where it landed in the winner zone
|
||||||
|
|
||||||
|
}, duration);
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
const spinSequentialRow = (rowIndex: number) => {
|
||||||
|
if (rowIndex >= spinRows.length) {
|
||||||
|
setIsSequentialSpinning(false);
|
||||||
|
setCurrentSpinningRow(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const row = spinRows[rowIndex];
|
||||||
|
if (!row || row.isSpinning || row.winner) {
|
||||||
|
// Skip this row and go to next
|
||||||
|
spinSequentialRow(rowIndex + 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentSpinningRow(row.rowNumber);
|
||||||
|
setSpinRows(prev => prev.map(r =>
|
||||||
|
r.id === row.id ? { ...r, isSpinning: true, selectedWinner: null } : r
|
||||||
|
));
|
||||||
|
|
||||||
|
const wheelElement = row.wheelRef.current;
|
||||||
|
if (wheelElement) {
|
||||||
|
wheelElement.style.transition = 'none';
|
||||||
|
wheelElement.style.transform = 'translateY(0px)';
|
||||||
|
wheelElement.offsetHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
performDramaticSpin(row, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const startSequentialSpinning = () => {
|
||||||
|
if (spinRows.length === 0) return;
|
||||||
|
|
||||||
|
// Clear any existing results
|
||||||
|
setWinnersHistory([]);
|
||||||
|
setRevealedWinners(new Set());
|
||||||
|
setSpinRows(prev => prev.map(row => ({
|
||||||
|
...row,
|
||||||
|
isSpinning: false,
|
||||||
|
isShuffling: false,
|
||||||
|
winner: null,
|
||||||
|
selectedWinner: null,
|
||||||
|
displayVouchers: [...row.vouchers]
|
||||||
|
})));
|
||||||
|
|
||||||
|
// Reset all wheel positions
|
||||||
|
spinRows.forEach(row => {
|
||||||
|
const wheelElement = row.wheelRef.current;
|
||||||
|
if (wheelElement) {
|
||||||
|
wheelElement.style.transition = 'none';
|
||||||
|
wheelElement.style.transform = 'translateY(0px)';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setIsSequentialSpinning(true);
|
||||||
|
setCurrentSpinningRow(null);
|
||||||
|
|
||||||
|
// Start with first row after a short delay
|
||||||
|
setTimeout(() => {
|
||||||
|
spinSequentialRow(0);
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
|
|
||||||
|
const spinWheel = (rowId: string) => {
|
||||||
|
const row = spinRows.find(r => r.id === rowId);
|
||||||
|
if (!row || row.isSpinning || row.winner) return;
|
||||||
|
|
||||||
|
setSpinRows(prev => prev.map(r =>
|
||||||
|
r.id === rowId ? { ...r, isSpinning: true, selectedWinner: null } : r
|
||||||
|
));
|
||||||
|
|
||||||
|
const wheelElement = row.wheelRef.current;
|
||||||
|
if (wheelElement) {
|
||||||
|
wheelElement.style.transition = 'none';
|
||||||
|
wheelElement.style.transform = 'translateY(0px)';
|
||||||
|
wheelElement.offsetHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
performSpin(row);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearResults = () => {
|
||||||
|
tickIntervalRefs.current.forEach(timeout => clearTimeout(timeout));
|
||||||
|
shuffleIntervalRefs.current.forEach(timeout => clearTimeout(timeout));
|
||||||
|
tickIntervalRefs.current.clear();
|
||||||
|
shuffleIntervalRefs.current.clear();
|
||||||
|
|
||||||
|
setWinnersHistory([]);
|
||||||
|
setRevealedWinners(new Set());
|
||||||
|
setIsSequentialSpinning(false);
|
||||||
|
setCurrentSpinningRow(null);
|
||||||
|
setSpinRows(prev => prev.map(row => ({
|
||||||
|
...row,
|
||||||
|
isSpinning: false,
|
||||||
|
isShuffling: false,
|
||||||
|
winner: null,
|
||||||
|
selectedWinner: null,
|
||||||
|
displayVouchers: [...row.vouchers]
|
||||||
|
})));
|
||||||
|
|
||||||
|
spinRows.forEach(row => {
|
||||||
|
const wheelElement = row.wheelRef.current;
|
||||||
|
if (wheelElement) {
|
||||||
|
wheelElement.style.transition = 'none';
|
||||||
|
wheelElement.style.transform = 'translateY(0px)';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const refreshData = async () => {
|
||||||
|
tickIntervalRefs.current.forEach(timeout => clearTimeout(timeout));
|
||||||
|
shuffleIntervalRefs.current.forEach(timeout => clearTimeout(timeout));
|
||||||
|
tickIntervalRefs.current.clear();
|
||||||
|
shuffleIntervalRefs.current.clear();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await refetchVouchers();
|
||||||
|
toast.success('Data refreshed successfully');
|
||||||
|
} catch (error) {
|
||||||
|
toast.error('Failed to refresh data');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatPhoneNumber = (phone: string) => {
|
||||||
|
return phone.substring(0, 5) + '****' + phone.substring(phone.length - 2);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-gradient-to-br from-gray-50 to-gray-100 text-gray-900 p-6">
|
||||||
|
<style jsx>{`
|
||||||
|
@keyframes bounce-in {
|
||||||
|
0% {
|
||||||
|
transform: scale(0.3);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: scale(1.05);
|
||||||
|
}
|
||||||
|
70% {
|
||||||
|
transform: scale(0.9);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: scale(1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.animate-bounce-in {
|
||||||
|
animation: bounce-in 0.6s ease-out;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
|
||||||
|
<div className="max-w-full px-4 mx-auto">
|
||||||
|
{/* Header */}
|
||||||
|
<div className="text-center mb-8">
|
||||||
|
<h1 className="text-5xl font-bold bg-gradient-to-r from-primary to-purple-600 bg-clip-text text-transparent mb-2">
|
||||||
|
Voucher Lucky Draw
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Controls Section - Compact Layout */}
|
||||||
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-3">
|
||||||
|
{/* Configuration Card */}
|
||||||
|
<div className="bg-white rounded-lg p-4 border border-gray-200 shadow-sm">
|
||||||
|
<h2 className="text-lg font-semibold mb-3 text-gray-900">
|
||||||
|
Configuration
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<div>
|
||||||
|
<label className="block text-xs font-medium text-gray-700 mb-1">
|
||||||
|
Number of Rows
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min="1"
|
||||||
|
max="10"
|
||||||
|
value={numberOfRows}
|
||||||
|
onChange={(e) => setNumberOfRows(parseInt(e.target.value) || 1)}
|
||||||
|
className="w-full bg-white border border-gray-300 rounded p-1.5 text-sm text-gray-900 focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary/20"
|
||||||
|
disabled={isLoadingData}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className="block text-xs font-medium text-gray-700 mb-1">
|
||||||
|
Prize Selection
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
value={selectedPrize}
|
||||||
|
onChange={(e) => setSelectedPrize(parseInt(e.target.value))}
|
||||||
|
className="w-full bg-white border border-gray-300 rounded p-1.5 text-sm text-gray-900 focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary/20"
|
||||||
|
disabled={isLoadingData}
|
||||||
|
>
|
||||||
|
<option value={1}>🥇 Emas 0.25 Gram</option>
|
||||||
|
<option value={2}>🥇 Emas 3 Gram</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={refreshData}
|
||||||
|
disabled={isLoadingData}
|
||||||
|
className="w-full px-3 py-1.5 bg-primary hover:bg-primary/90 disabled:bg-gray-400 text-white text-sm font-semibold rounded flex items-center justify-center gap-1 transition-colors"
|
||||||
|
>
|
||||||
|
<RefreshCw size={14} className={isLoadingData ? 'animate-spin' : ''} />
|
||||||
|
{isLoadingData ? 'Loading...' : 'Load Data'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{spinRows.length > 0 && (
|
||||||
|
<div className="mt-3 p-2 bg-gray-50 rounded text-xs text-gray-600">
|
||||||
|
<div>Rows: {spinRows.length} | Vouchers: {spinRows.reduce((acc, row) => acc + row.vouchers.length, 0)}</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Actions Card */}
|
||||||
|
<div className="bg-white rounded-lg p-4 border border-gray-200 shadow-sm">
|
||||||
|
<h2 className="text-lg font-semibold mb-3 text-gray-900">
|
||||||
|
Actions
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<button
|
||||||
|
onClick={shuffleAllRows}
|
||||||
|
disabled={isLoadingData || spinRows.some(r => r.isShuffling) || spinRows.length === 0}
|
||||||
|
className="w-full px-3 py-1.5 bg-purple-600 hover:bg-purple-700 disabled:bg-gray-400 text-white text-sm font-semibold rounded flex items-center justify-center gap-1 transition-colors"
|
||||||
|
>
|
||||||
|
<Shuffle size={14} className={spinRows.some(r => r.isShuffling) ? 'animate-pulse' : ''} />
|
||||||
|
Shuffle All
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={startSequentialSpinning}
|
||||||
|
disabled={isSequentialSpinning || spinRows.length === 0}
|
||||||
|
className="w-full px-3 py-1.5 bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 disabled:from-gray-400 disabled:to-gray-500 text-white text-sm font-bold rounded flex items-center justify-center gap-1 transition-all"
|
||||||
|
>
|
||||||
|
<Trophy size={14} className={isSequentialSpinning ? 'animate-spin' : ''} />
|
||||||
|
{isSequentialSpinning ? 'Spinning...' : 'Spin for Winner'}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{winnersHistory.length > 0 && (
|
||||||
|
<button
|
||||||
|
onClick={clearResults}
|
||||||
|
className="w-full px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm font-semibold rounded flex items-center justify-center gap-1 transition-colors"
|
||||||
|
>
|
||||||
|
<Trash2 size={14} />
|
||||||
|
Clear Results
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Winners Summary Card */}
|
||||||
|
<div className="bg-white rounded-lg p-4 border border-gray-200 shadow-sm">
|
||||||
|
<h2 className="text-lg font-semibold mb-3 text-gray-900 flex items-center gap-2">
|
||||||
|
<Trophy className="text-yellow-500" size={18} />
|
||||||
|
Winners
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
{winnersHistory.length > 0 ? (
|
||||||
|
<div className="space-y-1 max-h-32 overflow-y-auto">
|
||||||
|
{winnersHistory.map((history) => (
|
||||||
|
<div
|
||||||
|
key={`${history.rowNumber}-${history.timestamp.getTime()}`}
|
||||||
|
className="p-1.5 bg-yellow-50 border border-yellow-200 rounded text-xs"
|
||||||
|
>
|
||||||
|
<div className="font-semibold text-yellow-700">
|
||||||
|
Row {history.rowNumber}: {history.winner.name}
|
||||||
|
</div>
|
||||||
|
<div className="text-xs text-yellow-600">
|
||||||
|
{history.winner.voucher_code}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="text-center py-2">
|
||||||
|
<Trophy className="mx-auto text-gray-300 mb-1" size={20} />
|
||||||
|
<p className="text-gray-500 text-xs">No winners yet</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Spin Rows - Display in grid */}
|
||||||
|
<div className={`grid gap-4 ${
|
||||||
|
spinRows.length === 1 ? 'grid-cols-1' :
|
||||||
|
spinRows.length === 2 ? 'grid-cols-1 lg:grid-cols-2' :
|
||||||
|
spinRows.length === 3 ? 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3' :
|
||||||
|
spinRows.length === 4 ? 'grid-cols-1 md:grid-cols-2 xl:grid-cols-4' :
|
||||||
|
spinRows.length === 5 ? 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5' :
|
||||||
|
'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4'
|
||||||
|
}`}>
|
||||||
|
{spinRows.map((row) => (
|
||||||
|
<div key={row.id} className={`bg-white rounded-lg border-2 shadow-sm transition-all ${
|
||||||
|
row.isShuffling ? 'border-purple-400 animate-pulse' : 'border-gray-200'
|
||||||
|
}`}>
|
||||||
|
<div className="p-4 border-b border-gray-200">
|
||||||
|
|
||||||
|
{row.winner && (
|
||||||
|
<div className="mt-2 p-2 bg-yellow-50 border border-yellow-200 rounded-lg animate-bounce-in">
|
||||||
|
<div className="flex items-center gap-1 text-sm">
|
||||||
|
<Trophy className="text-yellow-500" size={16} />
|
||||||
|
<span className="font-semibold text-yellow-700 truncate">
|
||||||
|
{row.winner.name}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="text-xs text-yellow-600 mt-1">
|
||||||
|
{row.winner.voucher_code}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Wheel Container */}
|
||||||
|
<div
|
||||||
|
className="relative bg-gray-50 overflow-hidden"
|
||||||
|
style={{ height: '600px' }}
|
||||||
|
>
|
||||||
|
{/* Subtle Winner Zone Indicator */}
|
||||||
|
<div
|
||||||
|
className="absolute left-0 right-0 z-10 pointer-events-none"
|
||||||
|
style={{
|
||||||
|
top: '260px',
|
||||||
|
height: '80px',
|
||||||
|
background: 'linear-gradient(90deg, transparent 0%, rgba(34, 197, 94, 0.1) 20%, rgba(34, 197, 94, 0.2) 50%, rgba(34, 197, 94, 0.1) 80%, transparent 100%)',
|
||||||
|
borderTop: '2px dashed rgba(34, 197, 94, 0.3)',
|
||||||
|
borderBottom: '2px dashed rgba(34, 197, 94, 0.3)'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="absolute right-2 top-1/2 transform -translate-y-1/2">
|
||||||
|
<div className="bg-green-500 text-white px-2 py-1 rounded text-xs font-bold shadow-lg">
|
||||||
|
🏆 WINNER
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Scrolling Cards */}
|
||||||
|
<div
|
||||||
|
ref={row.wheelRef}
|
||||||
|
className="absolute inset-0"
|
||||||
|
style={{ transform: 'translateY(0px)' }}
|
||||||
|
>
|
||||||
|
{Array.from({ length: 50 }, (_, repeatIndex) =>
|
||||||
|
row.displayVouchers.map((voucher, voucherIndex) => {
|
||||||
|
const isSelectedWinner = row.selectedWinner?.voucher_code === voucher.voucher_code;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={`${repeatIndex}-${voucherIndex}`}
|
||||||
|
className={`flex items-center px-4 border-b border-gray-300 transition-all duration-300 ${
|
||||||
|
isSelectedWinner
|
||||||
|
? 'bg-gradient-to-r from-yellow-100 to-yellow-200 border-yellow-300 shadow-lg'
|
||||||
|
: voucherIndex % 2 === 0
|
||||||
|
? 'bg-white hover:bg-gray-50'
|
||||||
|
: 'bg-gray-50 hover:bg-gray-100'
|
||||||
|
}`}
|
||||||
|
style={{
|
||||||
|
height: '80px',
|
||||||
|
minHeight: '80px',
|
||||||
|
maxHeight: '80px',
|
||||||
|
boxSizing: 'border-box'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="flex-1">
|
||||||
|
<div className={`font-bold text-lg mb-1 ${
|
||||||
|
isSelectedWinner ? 'text-yellow-600' : 'text-gray-900'
|
||||||
|
}`}>
|
||||||
|
{voucher.voucher_code}
|
||||||
|
</div>
|
||||||
|
<div className={`text-sm ${
|
||||||
|
isSelectedWinner ? 'text-yellow-700' : 'text-gray-600'
|
||||||
|
}`}>
|
||||||
|
{voucher.name}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="text-right">
|
||||||
|
<div className="text-gray-500 text-xs">
|
||||||
|
{formatPhoneNumber(voucher.phone_number)}
|
||||||
|
</div>
|
||||||
|
{isSelectedWinner && (
|
||||||
|
<Trophy className="inline ml-2 text-yellow-500" size={16} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Gradient Overlays */}
|
||||||
|
<div className="absolute top-0 left-0 right-0 h-32 bg-gradient-to-b from-gray-50 via-gray-50/70 to-transparent pointer-events-none z-40"></div>
|
||||||
|
<div className="absolute bottom-0 left-0 right-0 h-32 bg-gradient-to-t from-gray-50 via-gray-50/70 to-transparent pointer-events-none z-40"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RandomDrawApp;
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import AccountList from '@/views/apps/account'
|
||||||
|
|
||||||
|
const AccountPage = () => {
|
||||||
|
return <AccountList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AccountPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import CashBankDetail from '@/views/apps/cash-bank/detail'
|
||||||
|
|
||||||
|
const CashBankDetailPage = () => {
|
||||||
|
return <CashBankDetail />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CashBankDetailPage
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
import CashBankDetailTransactionContent from '@/views/apps/cash-bank/detail/transaction/CashBankDetailTransactionContent'
|
||||||
|
import CashBankDetailTransactionHeader from '@/views/apps/cash-bank/detail/transaction/CashBankDetailTransactionHeader'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const TransactionPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<CashBankDetailTransactionHeader title='Giro 1-10003' transaction='Terima Pembayaran Tagihan' />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<CashBankDetailTransactionContent />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TransactionPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import CashBankList from '@/views/apps/cash-bank/CashBankList'
|
||||||
|
|
||||||
|
const CashBankPage = () => {
|
||||||
|
return <CashBankList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CashBankPage
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import ExpenseDetailContent from '@/views/apps/expense/detail/ExpenseDetailContent'
|
||||||
|
import ExpenseDetailHeader from '@/views/apps/expense/detail/ExpenseDetailHeader'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const ExpenseDetailPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ExpenseDetailHeader />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ExpenseDetailContent />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ExpenseDetailPage
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import ExpenseAddForm from '@/views/apps/expense/add/ExpenseAddForm'
|
||||||
|
import ExpenseAddHeader from '@/views/apps/expense/add/ExpenseAddHeader'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const ExpenseAddPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ExpenseAddHeader />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ExpenseAddForm />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ExpenseAddPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import ExpenseList from '@/views/apps/expense/list'
|
||||||
|
|
||||||
|
const ExpensePage = () => {
|
||||||
|
return <ExpenseList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ExpensePage
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import FixedAssetAddForm from '@/views/apps/fixed-assets/add/FixedAssetAddForm'
|
||||||
|
import FixedAssetAddHeader from '@/views/apps/fixed-assets/add/FixedAssetAddHeader'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const FixedAssetPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<FixedAssetAddHeader />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<FixedAssetAddForm />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FixedAssetPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import FixedAssetList from '@/views/apps/fixed-assets'
|
||||||
|
|
||||||
|
const FixedAssetPage = () => {
|
||||||
|
return <FixedAssetList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FixedAssetPage
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
import IngredientDetail from '@/views/apps/ecommerce/products/ingredient/detail'
|
||||||
|
|
||||||
|
const IngredientDetailPage = () => {
|
||||||
|
return <IngredientDetail />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IngredientDetailPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import CampaignDetailContent from '@/views/apps/marketing/campaign/detail'
|
||||||
|
|
||||||
|
const CampaignDetailPage = () => {
|
||||||
|
return <CampaignDetailContent />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CampaignDetailPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import CampaignListTable from '@/views/apps/marketing/campaign/CampaignListTable'
|
||||||
|
|
||||||
|
const CampaignPage = () => {
|
||||||
|
return <CampaignListTable />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CampaignPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import CustomerAnalyticList from '@/views/apps/marketing/customer-analytics'
|
||||||
|
|
||||||
|
const CustomerAnalyticsPage = () => {
|
||||||
|
return <CustomerAnalyticList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CustomerAnalyticsPage
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import DiscountAddHeader from '@/views/apps/marketing/discount/add/DiscountAddHeader'
|
||||||
|
import DiscountInformation from '@/views/apps/marketing/discount/add/DiscountAddInformation'
|
||||||
|
import DiscountOutlets from '@/views/apps/marketing/discount/add/DiscountAddOutlets'
|
||||||
|
import DiscountRules from '@/views/apps/marketing/discount/add/DiscountAddRule'
|
||||||
|
import DiscountSettings from '@/views/apps/marketing/discount/add/DiscountAddSetting'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const DiscountsAddPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<DiscountAddHeader />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12, md: 8 }}>
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<DiscountInformation />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<DiscountRules />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12, md: 4 }}>
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<DiscountSettings />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<DiscountOutlets />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DiscountsAddPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import DiscountList from '@/views/apps/marketing/discount'
|
||||||
|
|
||||||
|
const DiscountPage = () => {
|
||||||
|
return <DiscountList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DiscountPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import GamePrizeList from '@/views/apps/marketing/games/game-prizes'
|
||||||
|
|
||||||
|
const GamePrizePage = () => {
|
||||||
|
return <GamePrizeList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GamePrizePage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import GamesList from '@/views/apps/marketing/games/list'
|
||||||
|
|
||||||
|
const GamePage = () => {
|
||||||
|
return <GamesList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GamePage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import WheelSpinList from '@/views/apps/marketing/gamification/wheel-spin'
|
||||||
|
|
||||||
|
const WheelSpinPage = () => {
|
||||||
|
return <WheelSpinList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default WheelSpinPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import LoyaltyList from '@/views/apps/marketing/loyalty'
|
||||||
|
|
||||||
|
const LoyaltiPage = () => {
|
||||||
|
return <LoyaltyList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LoyaltiPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import RewardList from '@/views/apps/marketing/reward'
|
||||||
|
|
||||||
|
const RewardPage = () => {
|
||||||
|
return <RewardList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RewardPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import TierList from '@/views/apps/marketing/tier'
|
||||||
|
|
||||||
|
const TierPage = () => {
|
||||||
|
return <TierList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TierPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import VoucherList from '@/views/apps/marketing/voucher'
|
||||||
|
|
||||||
|
const VoucherPage = () => {
|
||||||
|
return <VoucherList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default VoucherPage
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
import { TextField, Typography, useTheme } from '@mui/material'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { formatDateDDMMYYYY, formatForInputDate } from '@/utils/transform'
|
||||||
|
import PurchaseOverviewLeft from '@/views/apps/purchase/overview/overview-left'
|
||||||
|
import PurchaseOverviewRight from '@/views/apps/purchase/overview/overview-right'
|
||||||
|
|
||||||
|
const PurchaseOverviewPage = () => {
|
||||||
|
const theme = useTheme()
|
||||||
|
|
||||||
|
const today = new Date()
|
||||||
|
const monthAgo = new Date()
|
||||||
|
monthAgo.setDate(today.getDate() - 30)
|
||||||
|
|
||||||
|
const [filter, setFilter] = useState({
|
||||||
|
date_from: formatDateDDMMYYYY(monthAgo),
|
||||||
|
date_to: formatDateDDMMYYYY(today)
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<div className='flex gap-4 items-center justify-between'>
|
||||||
|
<Typography variant='h1' className='text-3xl font-bold text-gray-900 mb-2'>
|
||||||
|
Overview Pembelian
|
||||||
|
</Typography>
|
||||||
|
<div className='flex items-center gap-4'>
|
||||||
|
<TextField
|
||||||
|
type='date'
|
||||||
|
value={formatForInputDate(today || new Date())}
|
||||||
|
onChange={e => {
|
||||||
|
setFilter({
|
||||||
|
...filter,
|
||||||
|
date_from: formatDateDDMMYYYY(new Date(e.target.value))
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
size='small'
|
||||||
|
sx={{
|
||||||
|
'& .MuiOutlinedInput-root': {
|
||||||
|
'&.Mui-focused fieldset': {
|
||||||
|
borderColor: 'primary.main'
|
||||||
|
},
|
||||||
|
'& fieldset': {
|
||||||
|
borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Typography>-</Typography>
|
||||||
|
<TextField
|
||||||
|
type='date'
|
||||||
|
value={today}
|
||||||
|
onChange={e => {}}
|
||||||
|
size='small'
|
||||||
|
sx={{
|
||||||
|
'& .MuiOutlinedInput-root': {
|
||||||
|
'&.Mui-focused fieldset': {
|
||||||
|
borderColor: 'primary.main'
|
||||||
|
},
|
||||||
|
'& fieldset': {
|
||||||
|
borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<Grid container spacing={6} className='mt-5'>
|
||||||
|
<Grid size={{ xs: 12, lg: 8, md: 7 }}>
|
||||||
|
<PurchaseOverviewRight />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12, lg: 4, md: 5 }}>
|
||||||
|
<PurchaseOverviewLeft />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseOverviewPage
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
import PurchaseDetailContent from '@/views/apps/purchase/purchase-detail/PurchaseDetailContent'
|
||||||
|
import PurchaseDetailHeader from '@/views/apps/purchase/purchase-detail/PurchaseDetailHeader'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const PurchaseBillDetailPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseDetailHeader title='Detail Pesanan Pembelian' />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseDetailContent />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseBillDetailPage
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
import PurchaseAddForm from '@/views/apps/purchase/purchase-form/PurchaseAddForm'
|
||||||
|
import PurchaseBillAddHeader from '@/views/apps/purchase/purchase-bills/add/PurchaseBillAddHeader'
|
||||||
|
|
||||||
|
const PurchaseBillAddPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseBillAddHeader />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseAddForm />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseBillAddPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import PurchaseBillList from '@/views/apps/purchase/purchase-bills/list'
|
||||||
|
|
||||||
|
const PurchaseBillsPage = () => {
|
||||||
|
return <PurchaseBillList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseBillsPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import PurchaseDeliveryListTable from '@/views/apps/purchase/purchase-deliveries/list/PurchaseDeliveryListTable'
|
||||||
|
|
||||||
|
const PurchaseDeliveryPage = () => {
|
||||||
|
return <PurchaseDeliveryListTable />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseDeliveryPage
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
import PurchaseDetailContent from '@/views/apps/purchase/purchase-detail/PurchaseDetailContent'
|
||||||
|
import PurchaseDetailHeader from '@/views/apps/purchase/purchase-detail/PurchaseDetailHeader'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const PurchaseOrderDetailPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseDetailHeader title='Detail Pesanan Pembelian' />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseDetailContent />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseOrderDetailPage
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
import PurchaseOrderAddHeader from '@/views/apps/purchase/purchase-orders/add/PurchaseOrderAddHeader'
|
||||||
|
import PurchaseAddForm from '@/views/apps/purchase/purchase-form/PurchaseAddForm'
|
||||||
|
|
||||||
|
const PurchaseOrderAddPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseOrderAddHeader />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseAddForm />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseOrderAddPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import PurchaseOrderList from '@/views/apps/purchase/purchase-orders/list'
|
||||||
|
|
||||||
|
const PurchaseOrdersPage = () => {
|
||||||
|
return <PurchaseOrderList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseOrdersPage
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
import PurchaseAddForm from '@/views/apps/purchase/purchase-form/PurchaseAddForm'
|
||||||
|
import PurchaseQuoteAddHeader from '@/views/apps/purchase/purchase-quote/add/PurchaseQuoteAddHeader'
|
||||||
|
|
||||||
|
const PurchaseQuoteAddPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseQuoteAddHeader />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseAddForm />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseQuoteAddPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import PurchaseQuoteList from '@/views/apps/purchase/purchase-quote/list'
|
||||||
|
|
||||||
|
const PurchaseQuotePage = () => {
|
||||||
|
return <PurchaseQuoteList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseQuotePage
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import ReportTitle from '@/components/report/ReportTitle'
|
||||||
|
import ReportCashFlowCard from '@/views/apps/report/cash-flow/ReportCashFlowCard'
|
||||||
|
import ReportCashFlowContent from '@/views/apps/report/cash-flow/ReportCashFlowContent'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const CashFlowPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ReportTitle title='Arus Kas' />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ReportCashFlowCard />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ReportCashFlowContent />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CashFlowPage
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import ReportTitle from '@/components/report/ReportTitle'
|
||||||
|
import ReportNeracaCard from '@/views/apps/report/neraca/ReportNeracaCard'
|
||||||
|
import ReportNeracaContent from '@/views/apps/report/neraca/ReportNeracaContent'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const NeracaPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ReportTitle title='Neraca' />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ReportNeracaCard />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ReportNeracaContent />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NeracaPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import ReportList from '@/views/apps/report'
|
||||||
|
|
||||||
|
const ReportPage = () => {
|
||||||
|
return <ReportList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ReportPage
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import ReportTitle from '@/components/report/ReportTitle'
|
||||||
|
import ReportProfitLossCard from '@/views/apps/report/profit-loss/ReportProfitLossCard'
|
||||||
|
import ReportProfitLossContent from '@/views/apps/report/profit-loss/ReportProfitLossContent'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
const ProfiltLossPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ReportTitle title='Laba Rugi' />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ReportProfitLossCard />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<ReportProfitLossContent />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ProfiltLossPage
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
import { TextField, Typography, useTheme } from '@mui/material'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { formatDateDDMMYYYY, formatForInputDate } from '@/utils/transform'
|
||||||
|
import SalesOverviewRight from '@/views/apps/sales/overview/overview-right'
|
||||||
|
import SalesOverviewLeft from '@/views/apps/sales/overview/overview-left'
|
||||||
|
|
||||||
|
const SalesOverviewPage = () => {
|
||||||
|
const theme = useTheme()
|
||||||
|
|
||||||
|
const today = new Date()
|
||||||
|
const monthAgo = new Date()
|
||||||
|
monthAgo.setDate(today.getDate() - 30)
|
||||||
|
|
||||||
|
const [filter, setFilter] = useState({
|
||||||
|
date_from: formatDateDDMMYYYY(monthAgo),
|
||||||
|
date_to: formatDateDDMMYYYY(today)
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<div className='flex gap-4 items-center justify-between'>
|
||||||
|
<Typography variant='h1' className='text-3xl font-bold text-gray-900 mb-2'>
|
||||||
|
Overview Penjualan
|
||||||
|
</Typography>
|
||||||
|
<div className='flex items-center gap-4'>
|
||||||
|
<TextField
|
||||||
|
type='date'
|
||||||
|
value={formatForInputDate(today || new Date())}
|
||||||
|
onChange={e => {
|
||||||
|
setFilter({
|
||||||
|
...filter,
|
||||||
|
date_from: formatDateDDMMYYYY(new Date(e.target.value))
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
size='small'
|
||||||
|
sx={{
|
||||||
|
'& .MuiOutlinedInput-root': {
|
||||||
|
'&.Mui-focused fieldset': {
|
||||||
|
borderColor: 'primary.main'
|
||||||
|
},
|
||||||
|
'& fieldset': {
|
||||||
|
borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Typography>-</Typography>
|
||||||
|
<TextField
|
||||||
|
type='date'
|
||||||
|
value={today}
|
||||||
|
onChange={e => {}}
|
||||||
|
size='small'
|
||||||
|
sx={{
|
||||||
|
'& .MuiOutlinedInput-root': {
|
||||||
|
'&.Mui-focused fieldset': {
|
||||||
|
borderColor: 'primary.main'
|
||||||
|
},
|
||||||
|
'& fieldset': {
|
||||||
|
borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<Grid container spacing={6} className='mt-5'>
|
||||||
|
<Grid size={{ xs: 12, lg: 8, md: 7 }}>
|
||||||
|
<SalesOverviewRight />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12, lg: 4, md: 5 }}>
|
||||||
|
<SalesOverviewLeft />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesOverviewPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import SalesBillList from '@/views/apps/sales/sales-bill/list'
|
||||||
|
|
||||||
|
const SalesBillPage = () => {
|
||||||
|
return <SalesBillList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesBillPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import SalesDeliveryListTable from '@/views/apps/sales/sales-deliveries/list/SalesDeliveryListTable'
|
||||||
|
|
||||||
|
const SalesDeliveryPage = () => {
|
||||||
|
return <SalesDeliveryListTable />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesDeliveryPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import SalesOrderList from '@/views/apps/sales/sales-orders/list'
|
||||||
|
|
||||||
|
const SalesOrdersPage = () => {
|
||||||
|
return <SalesOrderList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesOrdersPage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import SalesQuoteList from '@/views/apps/sales/sales-quote/list'
|
||||||
|
|
||||||
|
const SalesQuotePage = () => {
|
||||||
|
return <SalesQuoteList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesQuotePage
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import VendorView from '@/views/apps/vendor/detail'
|
||||||
|
|
||||||
|
const VendorViewPage = async () => {
|
||||||
|
return <VendorView />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default VendorViewPage
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { vendorDummyData } from '@/data/dummy/vendor'
|
||||||
|
import VendorList from '@/views/apps/vendor/list'
|
||||||
|
|
||||||
|
const VendorListTablePage = async () => {
|
||||||
|
return <VendorList vendorData={vendorDummyData} />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default VendorListTablePage
|
||||||
@@ -8,23 +8,63 @@ import {
|
|||||||
useCategoryAnalytics
|
useCategoryAnalytics
|
||||||
} from '@/services/queries/analytics'
|
} from '@/services/queries/analytics'
|
||||||
import { useOutletById } from '@/services/queries/outlets'
|
import { useOutletById } from '@/services/queries/outlets'
|
||||||
|
import { generateExcel } from '@/utils/excelGenerator'
|
||||||
|
import { generatePDF } from '@/utils/pdfGenerator'
|
||||||
import { formatCurrency, formatDate, formatDateDDMMYYYY, formatDatetime } from '@/utils/transform'
|
import { formatCurrency, formatDate, formatDateDDMMYYYY, formatDatetime } from '@/utils/transform'
|
||||||
import ReportGeneratorComponent from '@/views/dashboards/daily-report/report-generator'
|
import ReportGeneratorComponent from '@/views/dashboards/daily-report/report-generator'
|
||||||
import ReportHeader from '@/views/dashboards/daily-report/report-header'
|
import ReportHeader from '@/views/dashboards/daily-report/report-header'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
|
|
||||||
|
// Dummy HPP values — ganti dengan data real nantinya
|
||||||
|
const DUMMY_STD_HPP = 30 // % — ganti dengan data real nantinya
|
||||||
|
const DUMMY_REAL_HPP = 0 // % — ganti dengan kalkulasi real nantinya
|
||||||
|
|
||||||
|
const getHppStatus = (stdHpp: number, realHpp: number): 'Sehat' | 'Tidak Sehat' =>
|
||||||
|
realHpp <= stdHpp ? 'Sehat' : 'Tidak Sehat'
|
||||||
|
|
||||||
|
const StatusBadge = ({ status }: { status: 'Sehat' | 'Tidak Sehat' }) => (
|
||||||
|
<span
|
||||||
|
className={`inline-block px-3 py-1 rounded-full text-base font-bold ${
|
||||||
|
status === 'Sehat' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{status}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
|
||||||
const DailyPOSReport = () => {
|
const DailyPOSReport = () => {
|
||||||
const reportRef = useRef<HTMLDivElement | null>(null)
|
const reportRef = useRef<HTMLDivElement | null>(null)
|
||||||
|
|
||||||
|
const [isGeneratingExcel, setIsGeneratingExcel] = useState(false)
|
||||||
|
|
||||||
const [now, setNow] = useState(new Date())
|
const [now, setNow] = useState(new Date())
|
||||||
const [selectedDate, setSelectedDate] = useState(new Date())
|
const [selectedDate, setSelectedDate] = useState(new Date())
|
||||||
const [dateRange, setDateRange] = useState({
|
const [dateRange, setDateRange] = useState({
|
||||||
startDate: new Date(),
|
startDate: new Date(),
|
||||||
endDate: new Date()
|
endDate: new Date()
|
||||||
})
|
})
|
||||||
const [filterType, setFilterType] = useState<'single' | 'range'>('single') // 'single' or 'range'
|
const [filterType, setFilterType] = useState<'single' | 'range'>('single')
|
||||||
|
const [isGeneratingPDF, setIsGeneratingPDF] = useState(false)
|
||||||
|
|
||||||
|
// PDF Font Size Configuration
|
||||||
|
const PDF_FONT_SIZES = {
|
||||||
|
heading: 18,
|
||||||
|
subheading: 16,
|
||||||
|
tableContent: 12,
|
||||||
|
tableHeader: 12,
|
||||||
|
tableFooter: 12,
|
||||||
|
grandTotal: 14,
|
||||||
|
footer: 11
|
||||||
|
}
|
||||||
|
|
||||||
|
// PDF Spacing Configuration
|
||||||
|
const PDF_SPACING = {
|
||||||
|
cellPadding: 5,
|
||||||
|
cellPaddingLarge: 6,
|
||||||
|
sectionGap: 20,
|
||||||
|
headerGap: 15
|
||||||
|
}
|
||||||
|
|
||||||
// Use selectedDate for single date filter, or dateRange for range filter
|
|
||||||
const getDateParams = () => {
|
const getDateParams = () => {
|
||||||
if (filterType === 'single') {
|
if (filterType === 'single') {
|
||||||
return {
|
return {
|
||||||
@@ -41,8 +81,15 @@ const DailyPOSReport = () => {
|
|||||||
|
|
||||||
const dateParams = getDateParams()
|
const dateParams = getDateParams()
|
||||||
|
|
||||||
|
const today = new Date()
|
||||||
|
const sevenDaysAgo = new Date()
|
||||||
|
sevenDaysAgo.setDate(today.getDate() - 7)
|
||||||
|
|
||||||
const { data: outlet } = useOutletById()
|
const { data: outlet } = useOutletById()
|
||||||
const { data: sales } = useSalesAnalytics(dateParams)
|
const { data: profitLoss7Days } = useProfitLossAnalytics({
|
||||||
|
date_from: formatDateDDMMYYYY(sevenDaysAgo),
|
||||||
|
date_to: formatDateDDMMYYYY(today)
|
||||||
|
})
|
||||||
const { data: profitLoss } = useProfitLossAnalytics(dateParams)
|
const { data: profitLoss } = useProfitLossAnalytics(dateParams)
|
||||||
const { data: products } = useProductSalesAnalytics(dateParams)
|
const { data: products } = useProductSalesAnalytics(dateParams)
|
||||||
const { data: paymentAnalytics } = usePaymentAnalytics(dateParams)
|
const { data: paymentAnalytics } = usePaymentAnalytics(dateParams)
|
||||||
@@ -54,14 +101,6 @@ const DailyPOSReport = () => {
|
|||||||
totalOrders: products?.data?.reduce((sum, item) => sum + (item?.order_count || 0), 0) || 0
|
totalOrders: products?.data?.reduce((sum, item) => sum + (item?.order_count || 0), 0) || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate profit loss product summary
|
|
||||||
const profitLossProductSummary = {
|
|
||||||
totalRevenue: profitLoss?.product_data?.reduce((sum, item) => sum + (item?.revenue || 0), 0) || 0,
|
|
||||||
totalCost: profitLoss?.product_data?.reduce((sum, item) => sum + (item?.cost || 0), 0) || 0,
|
|
||||||
totalGrossProfit: profitLoss?.product_data?.reduce((sum, item) => sum + (item?.gross_profit || 0), 0) || 0,
|
|
||||||
totalQuantity: profitLoss?.product_data?.reduce((sum, item) => sum + (item?.quantity_sold || 0), 0) || 0
|
|
||||||
}
|
|
||||||
|
|
||||||
const categorySummary = {
|
const categorySummary = {
|
||||||
totalRevenue: category?.data?.reduce((sum, item) => sum + (item?.total_revenue || 0), 0) || 0,
|
totalRevenue: category?.data?.reduce((sum, item) => sum + (item?.total_revenue || 0), 0) || 0,
|
||||||
orderCount: category?.data?.reduce((sum, item) => sum + (item?.order_count || 0), 0) || 0,
|
orderCount: category?.data?.reduce((sum, item) => sum + (item?.order_count || 0), 0) || 0,
|
||||||
@@ -73,12 +112,10 @@ const DailyPOSReport = () => {
|
|||||||
setNow(new Date())
|
setNow(new Date())
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// Format date for input field (YYYY-MM-DD)
|
|
||||||
const formatDateForInput = (date: Date) => {
|
const formatDateForInput = (date: Date) => {
|
||||||
return date.toISOString().split('T')[0]
|
return date.toISOString().split('T')[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get display text for the report period
|
|
||||||
const getReportPeriodText = () => {
|
const getReportPeriodText = () => {
|
||||||
if (filterType === 'single') {
|
if (filterType === 'single') {
|
||||||
return `${formatDateDDMMYYYY(selectedDate)} - ${formatDateDDMMYYYY(selectedDate)}`
|
return `${formatDateDDMMYYYY(selectedDate)} - ${formatDateDDMMYYYY(selectedDate)}`
|
||||||
@@ -87,98 +124,107 @@ const DailyPOSReport = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get report title based on filter type
|
|
||||||
const getReportTitle = () => {
|
const getReportTitle = () => {
|
||||||
if (filterType === 'single') {
|
return 'Laporan Transaksi'
|
||||||
return 'Laporan Transaksi'
|
|
||||||
} else {
|
|
||||||
const daysDiff = Math.ceil((dateRange.endDate.getTime() - dateRange.startDate.getTime()) / (1000 * 3600 * 24)) + 1
|
|
||||||
// return `Laporan Transaksi ${daysDiff} Hari`
|
|
||||||
return `Laporan Transaksi`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleGeneratePDF = async () => {
|
const handleGeneratePDF = async () => {
|
||||||
const reportElement = reportRef.current
|
setIsGeneratingPDF(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Import jsPDF dan html2canvas
|
await generatePDF({
|
||||||
const jsPDF = (await import('jspdf')).default
|
reportRef,
|
||||||
const html2canvas = (await import('html2canvas')).default
|
outlet,
|
||||||
|
profitLoss,
|
||||||
// Optimized canvas capture dengan scale lebih rendah
|
products,
|
||||||
const canvas = await html2canvas(reportElement!, {
|
paymentAnalytics,
|
||||||
scale: 1.5, // Reduced from 2 to 1.5
|
category,
|
||||||
useCORS: true,
|
productSummary,
|
||||||
allowTaint: true,
|
categorySummary,
|
||||||
backgroundColor: '#ffffff',
|
filterType,
|
||||||
logging: false, // Disable logging for performance
|
selectedDate,
|
||||||
removeContainer: true, // Clean up after capture
|
dateRange,
|
||||||
imageTimeout: 0, // No timeout for image loading
|
now
|
||||||
height: reportElement!.scrollHeight,
|
|
||||||
width: reportElement!.scrollWidth
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Compress canvas using JPEG with quality setting
|
|
||||||
const imgData = canvas.toDataURL('image/jpeg', 0.85) // JPEG with 85% quality instead of PNG
|
|
||||||
|
|
||||||
// Create PDF with compression
|
|
||||||
const pdf = new jsPDF({
|
|
||||||
orientation: 'portrait',
|
|
||||||
unit: 'mm',
|
|
||||||
format: 'a4',
|
|
||||||
compress: true // Enable built-in compression
|
|
||||||
})
|
|
||||||
|
|
||||||
const imgWidth = 210
|
|
||||||
const pageHeight = 295
|
|
||||||
const imgHeight = (canvas.height * imgWidth) / canvas.width
|
|
||||||
let heightLeft = imgHeight
|
|
||||||
let position = 0
|
|
||||||
|
|
||||||
// Add first page with compressed image
|
|
||||||
pdf.addImage(imgData, 'JPEG', 0, position, imgWidth, imgHeight, '', 'FAST') // Use FAST compression
|
|
||||||
heightLeft -= pageHeight
|
|
||||||
|
|
||||||
// Handle multiple pages if needed
|
|
||||||
while (heightLeft >= 0) {
|
|
||||||
position = heightLeft - imgHeight
|
|
||||||
pdf.addPage()
|
|
||||||
pdf.addImage(imgData, 'JPEG', 0, position, imgWidth, imgHeight, '', 'FAST')
|
|
||||||
heightLeft -= pageHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
// Additional compression options
|
|
||||||
pdf.setProperties({
|
|
||||||
title: `${getReportTitle()}`,
|
|
||||||
subject: 'Daily Transaction Report',
|
|
||||||
author: 'Apskel POS System',
|
|
||||||
creator: 'Apskel'
|
|
||||||
})
|
|
||||||
|
|
||||||
// Save with optimized settings
|
|
||||||
const fileName =
|
|
||||||
filterType === 'single'
|
|
||||||
? `laporan-transaksi-${formatDateForInput(selectedDate)}.pdf`
|
|
||||||
: `laporan-transaksi-${formatDateForInput(dateRange.startDate)}-to-${formatDateForInput(dateRange.endDate)}.pdf`
|
|
||||||
|
|
||||||
pdf.save(fileName, {
|
|
||||||
returnPromise: true
|
|
||||||
})
|
|
||||||
|
|
||||||
// Clean up canvas to free memory
|
|
||||||
canvas.width = canvas.height = 0
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error generating PDF:', error)
|
console.error('Error generating PDF:', error)
|
||||||
alert('Terjadi kesalahan saat membuat PDF. Pastikan jsPDF dan html2canvas sudah terinstall.')
|
alert(`Terjadi kesalahan saat membuat PDF: ${error}`)
|
||||||
|
} finally {
|
||||||
|
setIsGeneratingPDF(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleGenerateExcel = async () => {
|
||||||
|
setIsGeneratingExcel(true)
|
||||||
|
try {
|
||||||
|
await generateExcel({
|
||||||
|
outlet,
|
||||||
|
profitLoss,
|
||||||
|
products,
|
||||||
|
paymentAnalytics,
|
||||||
|
category,
|
||||||
|
productSummary,
|
||||||
|
categorySummary,
|
||||||
|
filterType,
|
||||||
|
selectedDate,
|
||||||
|
dateRange
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error generating Excel:', error)
|
||||||
|
alert(`Terjadi kesalahan saat membuat Excel: ${error}`)
|
||||||
|
} finally {
|
||||||
|
setIsGeneratingExcel(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const LoadingOverlay = ({ isVisible, message = 'Generating PDF...' }: { isVisible: boolean; message?: string }) => {
|
||||||
|
if (!isVisible) return null
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 backdrop-blur-sm'>
|
||||||
|
<div className='bg-white rounded-lg shadow-xl p-8 max-w-sm w-full mx-4'>
|
||||||
|
<div className='text-center'>
|
||||||
|
<div className='inline-block animate-spin rounded-full h-12 w-12 border-4 border-gray-200 border-t-purple-600 mb-4'></div>
|
||||||
|
<h3 className='text-lg font-semibold text-gray-800 mb-2'>{message}</h3>
|
||||||
|
<p className='text-sm text-gray-600'>Mohon tunggu, proses ini mungkin membutuhkan beberapa detik...</p>
|
||||||
|
<div className='mt-6 space-y-2'>
|
||||||
|
<div className='flex items-center text-xs text-gray-500'>
|
||||||
|
<div className='w-2 h-2 bg-green-500 rounded-full mr-2 flex-shrink-0'></div>
|
||||||
|
<span>Capturing report content</span>
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center text-xs text-gray-500'>
|
||||||
|
<div className='w-2 h-2 bg-blue-500 rounded-full mr-2 flex-shrink-0 animate-pulse'></div>
|
||||||
|
<span>Processing pages</span>
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center text-xs text-gray-500'>
|
||||||
|
<div className='w-2 h-2 bg-gray-300 rounded-full mr-2 flex-shrink-0'></div>
|
||||||
|
<span>Finalizing PDF</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group products by category
|
||||||
|
const groupedProducts =
|
||||||
|
products?.data?.reduce(
|
||||||
|
(acc, item) => {
|
||||||
|
const categoryName = item.category_name || 'Tidak Berkategori'
|
||||||
|
if (!acc[categoryName]) {
|
||||||
|
acc[categoryName] = []
|
||||||
|
}
|
||||||
|
acc[categoryName].push(item)
|
||||||
|
return acc
|
||||||
|
},
|
||||||
|
{} as Record<string, any[]>
|
||||||
|
) || {}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='min-h-screen'>
|
<div className='min-h-screen'>
|
||||||
{/* Control Panel */}
|
<LoadingOverlay isVisible={isGeneratingPDF} message='Membuat PDF Laporan...' />
|
||||||
|
|
||||||
<ReportGeneratorComponent
|
<ReportGeneratorComponent
|
||||||
// Props wajib
|
|
||||||
reportTitle='Laporan Penjualan'
|
reportTitle='Laporan Penjualan'
|
||||||
filterType={filterType}
|
filterType={filterType}
|
||||||
selectedDate={selectedDate}
|
selectedDate={selectedDate}
|
||||||
@@ -187,161 +233,99 @@ const DailyPOSReport = () => {
|
|||||||
onSingleDateChange={setSelectedDate}
|
onSingleDateChange={setSelectedDate}
|
||||||
onDateRangeChange={setDateRange}
|
onDateRangeChange={setDateRange}
|
||||||
onGeneratePDF={handleGeneratePDF}
|
onGeneratePDF={handleGeneratePDF}
|
||||||
// Props opsional
|
onGenerateExcel={handleGenerateExcel}
|
||||||
// isGenerating={isGenerating}
|
isGeneratingExcel={isGeneratingExcel}
|
||||||
// customQuickActions={customQuickActions}
|
|
||||||
// labels={customLabels}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Report Template */}
|
|
||||||
<div ref={reportRef} className='max-w-4xl mx-auto bg-white min-h-[297mm]' style={{ width: '210mm' }}>
|
<div ref={reportRef} className='max-w-4xl mx-auto bg-white min-h-[297mm]' style={{ width: '210mm' }}>
|
||||||
{/* Header */}
|
{/* Wrap header in a section for easy capture */}
|
||||||
<ReportHeader
|
<div className='report-header-section'>
|
||||||
outlet={outlet}
|
<ReportHeader
|
||||||
reportTitle={getReportTitle()}
|
outlet={outlet}
|
||||||
reportSubtitle='Laporan Bulanan'
|
reportTitle={getReportTitle()}
|
||||||
brandName='Apskel'
|
reportSubtitle='Laporan Bulanan'
|
||||||
brandColor='#36175e'
|
brandName='Apskel'
|
||||||
periode={getReportPeriodText()}
|
brandColor='#36175e'
|
||||||
/>
|
periode={getReportPeriodText()}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Performance Summary */}
|
{/* Performance Summary */}
|
||||||
<div className='p-8'>
|
<div className='p-8'>
|
||||||
<h3 className='text-xl font-bold mb-6' style={{ color: '#36175e' }}>
|
<h3 className='text-3xl font-bold mb-8' style={{ color: '#36175e' }}>
|
||||||
1. Ringkasan
|
Ringkasan
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div className='grid grid-cols-2 gap-6'>
|
<div className='space-y-5'>
|
||||||
<div className='space-y-4'>
|
<div className='flex justify-between items-center py-3 border-b border-gray-200'>
|
||||||
<div className='flex justify-between items-center py-2 border-b border-gray-200'>
|
<span className='text-xl text-gray-700'>Total Penjualan</span>
|
||||||
<span className='text-gray-700'>Total Penjualan (termasuk rasik)</span>
|
<span className='text-xl font-semibold text-gray-800'>
|
||||||
<span className='font-semibold text-gray-800'>
|
{formatCurrency(profitLoss?.summary.total_revenue ?? 0)}
|
||||||
{formatCurrency(profitLoss?.summary.total_revenue ?? 0)}
|
</span>
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className='flex justify-between items-center py-2 border-b border-gray-200'>
|
|
||||||
<span className='text-gray-700'>Total Terjual</span>
|
|
||||||
<span className='font-semibold text-gray-800'>{productSummary.totalQuantitySold}</span>
|
|
||||||
</div>
|
|
||||||
<div className='flex justify-between items-center py-2 border-b border-gray-200'>
|
|
||||||
<span className='text-gray-700'>HPP</span>
|
|
||||||
<span className='font-semibold text-gray-800'>
|
|
||||||
{formatCurrency(profitLoss?.summary.total_cost ?? 0)} |{' '}
|
|
||||||
{(((profitLoss?.summary.total_cost ?? 0) / (profitLoss?.summary.total_revenue || 1)) * 100).toFixed(
|
|
||||||
0
|
|
||||||
)}
|
|
||||||
%
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className='flex justify-between items-center py-2 border-b-2 border-gray-300'>
|
|
||||||
<span className='text-lg font-semibold text-green-800'>Laba Kotor</span>
|
|
||||||
<span className='text-lg font-bold text-green-800'>
|
|
||||||
{formatCurrency(profitLoss?.summary.gross_profit ?? 0)} |{' '}
|
|
||||||
{(profitLoss?.summary.gross_profit_margin ?? 0).toFixed(0)}%
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className='flex justify-between items-center py-3 border-b border-gray-200'>
|
||||||
<div className='space-y-4'>
|
<span className='text-xl text-gray-700'>Total Diskon</span>
|
||||||
<div className='flex justify-between items-center py-2 border-b border-gray-200'>
|
<span className='text-xl font-semibold text-gray-800'>
|
||||||
<span className='text-gray-700'>Biaya lain²</span>
|
{formatCurrency(profitLoss?.summary.total_discount ?? 0)}
|
||||||
<span className='font-semibold text-gray-800'>
|
</span>
|
||||||
{formatCurrency(profitLoss?.summary.total_tax ?? 0)} |{' '}
|
</div>
|
||||||
{(((profitLoss?.summary.total_tax ?? 0) / (profitLoss?.summary.total_revenue || 1)) * 100).toFixed(0)}
|
<div className='flex justify-between items-center py-3 border-b border-gray-200'>
|
||||||
%
|
<span className='text-xl text-gray-700'>Total Pajak</span>
|
||||||
</span>
|
<span className='text-xl font-semibold text-gray-800'>
|
||||||
</div>
|
{formatCurrency(profitLoss?.summary.total_tax ?? 0)}
|
||||||
<div className='flex justify-between items-center py-2 border-b-2 border-gray-300'>
|
</span>
|
||||||
<span className='text-lg font-bold text-blue-800'>Laba/Rugi</span>
|
</div>
|
||||||
<span className='text-lg font-bold text-blue-800'>
|
<div className='flex justify-between items-center py-3 border-b border-gray-200'>
|
||||||
{formatCurrency(profitLoss?.summary.net_profit ?? 0)} |{' '}
|
<span className='text-xl text-gray-700'>Service Charge</span>
|
||||||
{(profitLoss?.summary.net_profit_margin ?? 0).toFixed(0)}%
|
<span className='text-xl font-semibold text-gray-800'>{formatCurrency(0)}</span>
|
||||||
</span>
|
</div>
|
||||||
</div>
|
<div className='flex justify-between items-center py-3 border-b-2 border-gray-300'>
|
||||||
|
<span className='text-xl text-gray-700 font-bold'>Total</span>
|
||||||
|
<span className='text-xl font-bold text-gray-800'>
|
||||||
|
{formatCurrency(profitLoss?.summary.total_revenue ?? 0)}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Profit Loss Product Table */}
|
{/* Invoice */}
|
||||||
<div className='px-8 pb-8'>
|
<div className='px-8 pb-8'>
|
||||||
<h3 className='text-lg font-medium mb-6' style={{ color: '#36175e' }}>
|
<h3 className='text-3xl font-bold mb-8' style={{ color: '#36175e' }}>
|
||||||
Laba Rugi Per Produk
|
Invoice
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div className='bg-gray-50 rounded-lg border border-gray-200 overflow-hidden'>
|
<div className='space-y-5'>
|
||||||
<table className='w-full'>
|
<div className='flex justify-between items-center py-3 border-b border-gray-200'>
|
||||||
<thead>
|
<span className='text-xl text-gray-700'>Total Invoice</span>
|
||||||
<tr style={{ backgroundColor: '#36175e' }} className='text-white'>
|
<span className='text-xl font-semibold text-gray-800'>{profitLoss?.summary.total_orders ?? 0}</span>
|
||||||
<th className='text-left p-3 font-semibold'>Produk</th>
|
</div>
|
||||||
<th className='text-center p-3 font-semibold'>Qty</th>
|
|
||||||
<th className='text-right p-3 font-semibold'>Pendapatan</th>
|
|
||||||
<th className='text-right p-3 font-semibold'>HPP</th>
|
|
||||||
<th className='text-right p-3 font-semibold'>Laba Kotor</th>
|
|
||||||
<th className='text-center p-3 font-semibold'>Margin (%)</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{profitLoss?.product_data?.map((item, index) => (
|
|
||||||
<tr key={index} className={index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}>
|
|
||||||
<td className='p-3 font-medium text-gray-800'>{item.product_name}</td>
|
|
||||||
<td className='p-3 text-center text-gray-700'>{item.quantity_sold}</td>
|
|
||||||
<td className='p-3 text-right font-semibold text-gray-800'>{formatCurrency(item.revenue)}</td>
|
|
||||||
<td className='p-3 text-right font-semibold text-red-600'>{formatCurrency(item.cost)}</td>
|
|
||||||
<td className='p-3 text-right font-semibold text-green-600'>{formatCurrency(item.gross_profit)}</td>
|
|
||||||
<td className='p-3 text-center font-semibold' style={{ color: '#36175e' }}>
|
|
||||||
{(item.gross_profit_margin ?? 0).toFixed(1)}%
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)) || []}
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr style={{ backgroundColor: '#36175e' }} className='text-white'>
|
|
||||||
<td className='p-3 font-bold'>TOTAL</td>
|
|
||||||
<td className='p-3 text-center font-bold'>{profitLossProductSummary.totalQuantity}</td>
|
|
||||||
<td className='p-3 text-right font-bold'>{formatCurrency(profitLossProductSummary.totalRevenue)}</td>
|
|
||||||
<td className='p-3 text-right font-bold'>{formatCurrency(profitLossProductSummary.totalCost)}</td>
|
|
||||||
<td className='p-3 text-right font-bold'>
|
|
||||||
{formatCurrency(profitLossProductSummary.totalGrossProfit)}
|
|
||||||
</td>
|
|
||||||
<td className='p-3 text-center font-bold'>
|
|
||||||
{profitLossProductSummary.totalRevenue > 0
|
|
||||||
? (
|
|
||||||
(profitLossProductSummary.totalGrossProfit / profitLossProductSummary.totalRevenue) *
|
|
||||||
100
|
|
||||||
).toFixed(1)
|
|
||||||
: 0}
|
|
||||||
%
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Payment Method Summary */}
|
{/* Payment Method Summary */}
|
||||||
<div className='px-8 pb-8'>
|
<div className='px-8 pb-8'>
|
||||||
<h3 className='text-xl font-bold mb-6' style={{ color: '#36175e' }}>
|
<h3 className='text-3xl font-bold mb-8' style={{ color: '#36175e' }}>
|
||||||
2. Ringkasan Metode Pembayaran
|
Ringkasan Metode Pembayaran
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div className='bg-gray-50 rounded-lg border border-gray-200 overflow-hidden'>
|
<div className='bg-gray-50 rounded-lg border border-gray-200 overflow-hidden'>
|
||||||
<table className='w-full'>
|
<table className='w-full'>
|
||||||
<thead>
|
<thead>
|
||||||
<tr style={{ backgroundColor: '#36175e' }} className='text-white'>
|
<tr className='text-gray-800 border-b-2 border-gray-300'>
|
||||||
<th className='text-left p-3 font-semibold'>Metode Pembayaran</th>
|
<th className='text-left text-xl p-4 font-semibold'>Metode Pembayaran</th>
|
||||||
<th className='text-center p-3 font-semibold'>Tipe</th>
|
<th className='text-center text-xl p-4 font-semibold'>Tipe</th>
|
||||||
<th className='text-center p-3 font-semibold'>Jumlah Order</th>
|
<th className='text-center text-xl p-4 font-semibold'>Jumlah Order</th>
|
||||||
<th className='text-right p-3 font-semibold'>Total Amount</th>
|
<th className='text-right text-xl p-4 font-semibold'>Total Amount</th>
|
||||||
<th className='text-center p-3 font-semibold'>Persentase</th>
|
<th className='text-center text-xl p-4 font-semibold'>Persentase</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{paymentAnalytics?.data?.map((payment, index) => (
|
{paymentAnalytics?.data?.map((payment, index) => (
|
||||||
<tr key={index} className={index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}>
|
<tr key={index} className={index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}>
|
||||||
<td className='p-3 font-medium text-gray-800'>{payment.payment_method_name}</td>
|
<td className='p-4 text-xl font-medium text-gray-800'>{payment.payment_method_name}</td>
|
||||||
<td className='p-3 text-center'>
|
<td className='p-4 text-center'>
|
||||||
<span
|
<span
|
||||||
className={`px-2 py-1 rounded-full text-xs font-medium ${
|
className={`px-3 py-1 rounded-full text-lg font-medium ${
|
||||||
payment.payment_method_type === 'cash'
|
payment.payment_method_type === 'cash'
|
||||||
? 'bg-green-100 text-green-800'
|
? 'bg-green-100 text-green-800'
|
||||||
: 'bg-blue-100 text-blue-800'
|
: 'bg-blue-100 text-blue-800'
|
||||||
@@ -350,123 +334,240 @@ const DailyPOSReport = () => {
|
|||||||
{payment.payment_method_type.toUpperCase()}
|
{payment.payment_method_type.toUpperCase()}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td className='p-3 text-center text-gray-700'>{payment.order_count}</td>
|
<td className='p-4 text-xl text-center text-gray-700'>{payment.order_count}</td>
|
||||||
<td className='p-3 text-right font-semibold text-gray-800'>
|
<td className='p-4 text-xl text-right font-semibold text-gray-800'>
|
||||||
{formatCurrency(payment.total_amount)}
|
{formatCurrency(payment.total_amount)}
|
||||||
</td>
|
</td>
|
||||||
<td className='p-3 text-center font-medium' style={{ color: '#36175e' }}>
|
<td className='p-4 text-xl text-center font-medium' style={{ color: '#36175e' }}>
|
||||||
{(payment.percentage ?? 0).toFixed(1)}%
|
{(payment.percentage ?? 0).toFixed(1)}%
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)) || []}
|
)) || []}
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr style={{ backgroundColor: '#36175e' }} className='text-white'>
|
<tr className='text-gray-800 border-t-2 border-gray-300'>
|
||||||
<td className='p-3 font-bold'>TOTAL</td>
|
<td className='p-4 text-xl font-bold'>TOTAL</td>
|
||||||
<td className='p-3'></td>
|
<td className='p-4'></td>
|
||||||
<td className='p-3 text-center font-bold'>{paymentAnalytics?.summary.total_orders ?? 0}</td>
|
<td className='p-4 text-xl text-center font-bold'>{paymentAnalytics?.summary.total_orders ?? 0}</td>
|
||||||
<td className='p-3 text-right font-bold'>
|
<td className='p-4 text-xl text-right font-bold'>
|
||||||
{formatCurrency(paymentAnalytics?.summary.total_amount ?? 0)}
|
{formatCurrency(paymentAnalytics?.summary.total_amount ?? 0)}
|
||||||
</td>
|
</td>
|
||||||
<td className='p-3 text-center font-bold'></td>
|
<td className='p-4 text-center font-bold'></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Category Summary */}
|
{/* Category Summary — +3 kolom baru */}
|
||||||
<div className='px-8 pb-8'>
|
<div className='px-8 pb-8'>
|
||||||
<h3 className='text-xl font-bold mb-6' style={{ color: '#36175e' }}>
|
<h3 className='text-3xl font-bold mb-8' style={{ color: '#36175e' }}>
|
||||||
2. Ringkasan Kategori
|
Ringkasan Kategori
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div className='bg-gray-50 rounded-lg border border-gray-200 overflow-hidden'>
|
<div className='bg-gray-50 rounded-lg border border-gray-200 overflow-hidden'>
|
||||||
<table className='w-full'>
|
<table className='w-full'>
|
||||||
<thead>
|
<thead>
|
||||||
<tr style={{ backgroundColor: '#36175e' }} className='text-white'>
|
<tr className='text-gray-800 border-b-2 border-gray-300'>
|
||||||
<th className='text-left p-3 font-semibold'>Nama</th>
|
<th className='text-left text-xl p-4 font-semibold'>Nama</th>
|
||||||
<th className='text-center p-3 font-semibold'>Total Produk</th>
|
<th className='text-center text-xl p-4 font-semibold'>Qty</th>
|
||||||
<th className='text-center p-3 font-semibold'>Qty</th>
|
<th className='text-right text-xl p-4 font-semibold'>Pendapatan</th>
|
||||||
<th className='text-right p-3 font-semibold'>Jumlah Order</th>
|
<th className='text-center text-xl p-4 font-semibold'>% Std HPP</th>
|
||||||
<th className='text-center p-3 font-semibold'>Pendapatan</th>
|
<th className='text-center text-xl p-4 font-semibold'>% Real HPP</th>
|
||||||
|
<th className='text-center text-xl p-4 font-semibold'>Status</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{category?.data?.map((c, index) => (
|
{category?.data?.map((c, index) => {
|
||||||
<tr key={index} className={index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}>
|
const stdHpp = DUMMY_STD_HPP
|
||||||
<td className='p-3 font-medium text-gray-800'>{c.category_name}</td>
|
const realHpp = DUMMY_REAL_HPP
|
||||||
<td className='p-3 text-center text-gray-700'>{c.product_count}</td>
|
const status = getHppStatus(stdHpp, realHpp)
|
||||||
<td className='p-3 text-center text-gray-700'>{c.total_quantity}</td>
|
return (
|
||||||
<td className='p-3 text-center text-gray-700'>{c.order_count}</td>
|
<tr key={index} className={index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}>
|
||||||
<td className='p-3 text-right font-semibold' style={{ color: '#36175e' }}>
|
<td className='p-4 text-xl font-medium text-gray-800'>{c.category_name}</td>
|
||||||
{formatCurrency(c.total_revenue)}
|
<td className='p-4 text-xl text-center text-gray-700'>{c.total_quantity}</td>
|
||||||
|
<td className='p-4 text-xl text-right font-semibold' style={{ color: '#36175e' }}>
|
||||||
|
{formatCurrency(c.total_revenue)}
|
||||||
|
</td>
|
||||||
|
<td className='p-4 text-xl text-center text-gray-700'>{stdHpp}%</td>
|
||||||
|
<td className='p-4 text-xl text-center text-gray-700'>{realHpp}%</td>
|
||||||
|
<td className='p-4 text-center'>
|
||||||
|
<StatusBadge status={status} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)
|
||||||
|
}) || []}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr className='text-gray-800 border-t-2 border-gray-300'>
|
||||||
|
<td className='p-4 text-xl font-bold'>TOTAL</td>
|
||||||
|
<td className='p-4 text-xl text-center font-bold'>{categorySummary?.totalQuantity ?? 0}</td>
|
||||||
|
<td className='p-4 text-xl text-right font-bold'>
|
||||||
|
{formatCurrency(categorySummary?.totalRevenue ?? 0)}
|
||||||
|
</td>
|
||||||
|
<td className='p-4'></td>
|
||||||
|
<td className='p-4'></td>
|
||||||
|
<td className='p-4'></td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Product Summary — +3 kolom baru */}
|
||||||
|
<div className='px-8 pb-8'>
|
||||||
|
<h3 className='text-3xl font-bold mb-8' style={{ color: '#36175e' }}>
|
||||||
|
Ringkasan Item Per Kategori
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div className='space-y-12'>
|
||||||
|
{Object.keys(groupedProducts)
|
||||||
|
.sort((a, b) => {
|
||||||
|
const productsA = groupedProducts[a]
|
||||||
|
const productsB = groupedProducts[b]
|
||||||
|
const orderA = productsA[0]?.category_order ?? 999
|
||||||
|
const orderB = productsB[0]?.category_order ?? 999
|
||||||
|
return orderA - orderB
|
||||||
|
})
|
||||||
|
.map((categoryName, catIndex) => {
|
||||||
|
const categoryProducts = groupedProducts[categoryName].sort((a, b) => {
|
||||||
|
const skuA = a.product_sku || ''
|
||||||
|
const skuB = b.product_sku || ''
|
||||||
|
return skuA.localeCompare(skuB)
|
||||||
|
})
|
||||||
|
const categoryTotalQty = categoryProducts.reduce((sum, item) => sum + (item.quantity_sold || 0), 0)
|
||||||
|
const categoryTotalRevenue = categoryProducts.reduce((sum, item) => sum + (item.revenue || 0), 0)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={categoryName} style={{ display: 'block', marginBottom: '70px' }}>
|
||||||
|
<h4
|
||||||
|
className='text-2xl font-bold mb-0 px-4 py-4 bg-gray-100 rounded-t-lg'
|
||||||
|
style={{ color: '#36175e' }}
|
||||||
|
>
|
||||||
|
{categoryName.toUpperCase()}
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<div className='bg-gray-50 rounded-b-lg border-l-2 border-r-2 border-b-2 border-gray-300'>
|
||||||
|
<table
|
||||||
|
className='w-full'
|
||||||
|
style={{ borderCollapse: 'collapse', tableLayout: 'fixed', width: '100%' }}
|
||||||
|
>
|
||||||
|
<colgroup>
|
||||||
|
<col style={{ width: '28%' }} />
|
||||||
|
<col style={{ width: '10%' }} />
|
||||||
|
<col style={{ width: '22%' }} />
|
||||||
|
<col style={{ width: '13%' }} />
|
||||||
|
<col style={{ width: '13%' }} />
|
||||||
|
<col style={{ width: '14%' }} />
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr className='text-gray-800 border-b-2 border-gray-300 bg-gray-100'>
|
||||||
|
<th className='text-left text-xl p-5 font-semibold border-r border-gray-300'>Produk</th>
|
||||||
|
<th className='text-center text-xl p-5 font-semibold border-r border-gray-300'>Qty</th>
|
||||||
|
<th className='text-right text-xl p-5 font-semibold border-r border-gray-300'>
|
||||||
|
Pendapatan
|
||||||
|
</th>
|
||||||
|
<th className='text-center text-xl p-5 font-semibold border-r border-gray-300'>
|
||||||
|
% Std HPP
|
||||||
|
</th>
|
||||||
|
<th className='text-center text-xl p-5 font-semibold border-r border-gray-300'>
|
||||||
|
% Real HPP
|
||||||
|
</th>
|
||||||
|
<th className='text-center text-xl p-5 font-semibold'>Status</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{categoryProducts.map((item, index) => {
|
||||||
|
const stdHpp = DUMMY_STD_HPP
|
||||||
|
const realHpp = DUMMY_REAL_HPP
|
||||||
|
const status = getHppStatus(stdHpp, realHpp)
|
||||||
|
return (
|
||||||
|
<tr key={index} className={index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}>
|
||||||
|
<td className='p-5 text-xl font-medium text-gray-800 border-r border-gray-200'>
|
||||||
|
{item.product_name}
|
||||||
|
</td>
|
||||||
|
<td className='p-5 text-xl text-center text-gray-700 border-r border-gray-200'>
|
||||||
|
{item.quantity_sold}
|
||||||
|
</td>
|
||||||
|
<td className='p-5 text-xl text-right font-semibold text-gray-800 border-r border-gray-200'>
|
||||||
|
{formatCurrency(item.revenue)}
|
||||||
|
</td>
|
||||||
|
<td className='p-5 text-xl text-center text-gray-700 border-r border-gray-200'>
|
||||||
|
{stdHpp}%
|
||||||
|
</td>
|
||||||
|
<td className='p-5 text-xl text-center text-gray-700 border-r border-gray-200'>
|
||||||
|
{realHpp}%
|
||||||
|
</td>
|
||||||
|
<td className='p-5 text-center'>
|
||||||
|
<StatusBadge status={status} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr className='bg-gray-200 border-t-2 border-gray-400'>
|
||||||
|
<td className='p-5 text-xl font-bold text-gray-800 border-r border-gray-400'>
|
||||||
|
Subtotal {categoryName}
|
||||||
|
</td>
|
||||||
|
<td className='p-5 text-xl text-center font-bold text-gray-800 border-r border-gray-400'>
|
||||||
|
{categoryTotalQty}
|
||||||
|
</td>
|
||||||
|
<td className='p-5 text-xl text-right font-bold text-gray-800 border-r border-gray-400'>
|
||||||
|
{formatCurrency(categoryTotalRevenue)}
|
||||||
|
</td>
|
||||||
|
<td className='p-5 border-r border-gray-400'></td>
|
||||||
|
<td className='p-5 border-r border-gray-400'></td>
|
||||||
|
<td className='p-5'></td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
|
||||||
|
{/* Grand Total */}
|
||||||
|
<div className='bg-purple-50 rounded-lg border-2 border-purple-300 mt-6'>
|
||||||
|
<table className='w-full' style={{ borderCollapse: 'collapse', tableLayout: 'fixed' }}>
|
||||||
|
<colgroup>
|
||||||
|
<col style={{ width: '28%' }} />
|
||||||
|
<col style={{ width: '10%' }} />
|
||||||
|
<col style={{ width: '22%' }} />
|
||||||
|
<col style={{ width: '13%' }} />
|
||||||
|
<col style={{ width: '13%' }} />
|
||||||
|
<col style={{ width: '14%' }} />
|
||||||
|
</colgroup>
|
||||||
|
<tfoot>
|
||||||
|
<tr className='text-gray-800'>
|
||||||
|
<td className='p-5 text-2xl font-bold border-r-2 border-purple-300' style={{ color: '#36175e' }}>
|
||||||
|
TOTAL KESELURUHAN
|
||||||
</td>
|
</td>
|
||||||
|
<td
|
||||||
|
className='p-5 text-2xl text-center font-bold border-r-2 border-purple-300'
|
||||||
|
style={{ color: '#36175e' }}
|
||||||
|
>
|
||||||
|
{productSummary.totalQuantitySold ?? 0}
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
className='p-5 text-2xl text-right font-bold border-r-2 border-purple-300'
|
||||||
|
style={{ color: '#36175e' }}
|
||||||
|
>
|
||||||
|
{formatCurrency(productSummary.totalRevenue ?? 0)}
|
||||||
|
</td>
|
||||||
|
<td className='p-5 border-r-2 border-purple-300'></td>
|
||||||
|
<td className='p-5 border-r-2 border-purple-300'></td>
|
||||||
|
<td className='p-5'></td>
|
||||||
</tr>
|
</tr>
|
||||||
)) || []}
|
</tfoot>
|
||||||
</tbody>
|
</table>
|
||||||
<tfoot>
|
</div>
|
||||||
<tr style={{ backgroundColor: '#36175e' }} className='text-white'>
|
|
||||||
<td className='p-3 font-bold'>TOTAL</td>
|
|
||||||
<td className='p-3 text-center font-bold'>{categorySummary?.productCount ?? 0}</td>
|
|
||||||
<td className='p-3 text-center font-bold'>{categorySummary?.totalQuantity ?? 0}</td>
|
|
||||||
<td className='p-3 text-center font-bold'>{categorySummary?.orderCount ?? 0}</td>
|
|
||||||
<td className='p-3 text-right font-bold'>{formatCurrency(categorySummary?.totalRevenue ?? 0)}</td>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Transaction Summary */}
|
|
||||||
<div className='px-8 pb-8'>
|
|
||||||
<h3 className='text-xl font-bold mb-6' style={{ color: '#36175e' }}>
|
|
||||||
4. Ringkasan Item
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<div className='bg-gray-50 rounded-lg border border-gray-200 overflow-hidden'>
|
|
||||||
<table className='w-full'>
|
|
||||||
<thead>
|
|
||||||
<tr style={{ backgroundColor: '#36175e' }} className='text-white'>
|
|
||||||
<th className='text-left p-3 font-semibold'>Produk</th>
|
|
||||||
<th className='text-left p-3 font-semibold'>Kategori</th>
|
|
||||||
<th className='text-center p-3 font-semibold'>Qty</th>
|
|
||||||
<th className='text-right p-3 font-semibold'>Order</th>
|
|
||||||
<th className='text-right p-3 font-semibold'>Pendapatan</th>
|
|
||||||
<th className='text-right p-3 font-semibold'>Rata Rata</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{products?.data?.map((item, index) => (
|
|
||||||
<tr key={index} className={index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}>
|
|
||||||
<td className='p-3 font-medium text-gray-800'>{item.product_name}</td>
|
|
||||||
<td className='p-3 font-medium text-gray-800'>{item.category_name}</td>
|
|
||||||
<td className='p-3 text-center text-gray-700'>{item.quantity_sold}</td>
|
|
||||||
<td className='p-3 text-center text-gray-700'>{item.order_count ?? 0}</td>
|
|
||||||
<td className='p-3 text-right font-semibold text-gray-800'>{formatCurrency(item.revenue)}</td>
|
|
||||||
<td className='p-3 text-right font-medium text-gray-800'>{formatCurrency(item.average_price)}</td>
|
|
||||||
</tr>
|
|
||||||
)) || []}
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr style={{ backgroundColor: '#36175e' }} className='text-white'>
|
|
||||||
<td className='p-3 font-bold'>TOTAL</td>
|
|
||||||
<td className='p-3 text-center'></td>
|
|
||||||
<td className='p-3 text-center font-bold'>{productSummary.totalQuantitySold ?? 0}</td>
|
|
||||||
<td className='p-3 text-right font-bold'>{productSummary.totalOrders ?? 0}</td>
|
|
||||||
<td className='p-3 text-right font-bold'>{formatCurrency(productSummary.totalRevenue ?? 0)}</td>
|
|
||||||
<td className='p-3 text-right font-bold'></td>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Profit Loss Product Table */}
|
|
||||||
|
|
||||||
{/* Footer */}
|
{/* Footer */}
|
||||||
<div className='px-8 py-6 border-t-2 border-gray-200 mt-8'>
|
<div className='px-8 py-6 border-t-2 border-gray-200 mt-8'>
|
||||||
<div className='flex justify-between items-center text-sm text-gray-600'>
|
<div className='flex justify-between items-center text-base text-gray-600'>
|
||||||
<p>© 2025 Apskel - Sistem POS Terpadu</p>
|
<p>© 2025 Apskel - Sistem POS Terpadu</p>
|
||||||
<p></p>
|
<p></p>
|
||||||
<p>Dicetak pada: {now.toLocaleDateString('id-ID')}</p>
|
<p>Dicetak pada: {now.toLocaleDateString('id-ID')}</p>
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ import { TextField, Typography, useTheme } from '@mui/material'
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import Loading from '../../../../../../components/layout/shared/Loading'
|
import Loading from '../../../../../../components/layout/shared/Loading'
|
||||||
import { useDashboardAnalytics } from '../../../../../../services/queries/analytics'
|
import { useDashboardAnalytics } from '../../../../../../services/queries/analytics'
|
||||||
import { formatDateDDMMYYYY, formatForInputDate, formatShortCurrency } from '../../../../../../utils/transform'
|
import {
|
||||||
|
formatCurrency,
|
||||||
|
formatDateDDMMYYYY,
|
||||||
|
formatForInputDate,
|
||||||
|
formatShortCurrency
|
||||||
|
} from '../../../../../../utils/transform'
|
||||||
import OrdersReport from '../../../../../../views/dashboards/orders/OrdersReport'
|
import OrdersReport from '../../../../../../views/dashboards/orders/OrdersReport'
|
||||||
import PaymentMethodReport from '../../../../../../views/dashboards/payment-methods/PaymentMethodReport'
|
import PaymentMethodReport from '../../../../../../views/dashboards/payment-methods/PaymentMethodReport'
|
||||||
import ProductSales from '../../../../../../views/dashboards/products/ProductSales'
|
import ProductSales from '../../../../../../views/dashboards/products/ProductSales'
|
||||||
@@ -115,14 +120,14 @@ const DashboardOverview = () => {
|
|||||||
<MetricCard
|
<MetricCard
|
||||||
iconClass='tabler-cash'
|
iconClass='tabler-cash'
|
||||||
title='Total Sales'
|
title='Total Sales'
|
||||||
value={formatShortCurrency(salesData.overview.total_sales)}
|
value={formatCurrency(salesData.overview.total_sales)}
|
||||||
bgColor='bg-green-500'
|
bgColor='bg-green-500'
|
||||||
isCurrency={true}
|
isCurrency={true}
|
||||||
/>
|
/>
|
||||||
<MetricCard
|
<MetricCard
|
||||||
iconClass='tabler-trending-up'
|
iconClass='tabler-trending-up'
|
||||||
title='Average Order Value'
|
title='Average Order Value'
|
||||||
value={formatShortCurrency(salesData.overview.average_order_value)}
|
value={formatCurrency(salesData.overview.average_order_value)}
|
||||||
bgColor='bg-purple-500'
|
bgColor='bg-purple-500'
|
||||||
isCurrency={true}
|
isCurrency={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -162,21 +162,21 @@ const DashboardProfitloss = () => {
|
|||||||
<MetricCard
|
<MetricCard
|
||||||
iconClass='tabler-currency-dollar'
|
iconClass='tabler-currency-dollar'
|
||||||
title='Total Revenue'
|
title='Total Revenue'
|
||||||
value={formatShortCurrency(profitData.summary.total_revenue)}
|
value={formatCurrency(profitData.summary.total_revenue)}
|
||||||
bgColor='bg-green-500'
|
bgColor='bg-green-500'
|
||||||
isCurrency={true}
|
isCurrency={true}
|
||||||
/>
|
/>
|
||||||
<MetricCard
|
<MetricCard
|
||||||
iconClass='tabler-receipt'
|
iconClass='tabler-receipt'
|
||||||
title='Total Cost'
|
title='Total Cost'
|
||||||
value={formatShortCurrency(profitData.summary.total_cost)}
|
value={formatCurrency(profitData.summary.total_cost)}
|
||||||
bgColor='bg-red-500'
|
bgColor='bg-red-500'
|
||||||
isCurrency={true}
|
isCurrency={true}
|
||||||
/>
|
/>
|
||||||
<MetricCard
|
<MetricCard
|
||||||
iconClass='tabler-trending-up'
|
iconClass='tabler-trending-up'
|
||||||
title='Gross Profit'
|
title='Gross Profit'
|
||||||
value={formatShortCurrency(profitData.summary.gross_profit)}
|
value={formatCurrency(profitData.summary.gross_profit)}
|
||||||
subtitle={`Margin: ${formatPercentage(profitData.summary.gross_profit_margin)}`}
|
subtitle={`Margin: ${formatPercentage(profitData.summary.gross_profit_margin)}`}
|
||||||
bgColor='bg-blue-500'
|
bgColor='bg-blue-500'
|
||||||
isNegative={profitData.summary.gross_profit < 0}
|
isNegative={profitData.summary.gross_profit < 0}
|
||||||
@@ -186,7 +186,7 @@ const DashboardProfitloss = () => {
|
|||||||
iconClass='tabler-percentage'
|
iconClass='tabler-percentage'
|
||||||
title='Profitability Ratio'
|
title='Profitability Ratio'
|
||||||
value={formatPercentage(profitData.summary.profitability_ratio)}
|
value={formatPercentage(profitData.summary.profitability_ratio)}
|
||||||
subtitle={`Avg Profit: ${formatShortCurrency(profitData.summary.average_profit)}`}
|
subtitle={`Avg Profit: ${formatCurrency(profitData.summary.average_profit)}`}
|
||||||
bgColor='bg-purple-500'
|
bgColor='bg-purple-500'
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -199,7 +199,7 @@ const DashboardProfitloss = () => {
|
|||||||
<h3 className='text-lg font-semibold text-gray-900'>Net Profit</h3>
|
<h3 className='text-lg font-semibold text-gray-900'>Net Profit</h3>
|
||||||
</div>
|
</div>
|
||||||
<p className='text-3xl font-bold text-green-600 mb-2'>
|
<p className='text-3xl font-bold text-green-600 mb-2'>
|
||||||
Rp {formatShortCurrency(profitData.summary.net_profit)}
|
{formatCurrency(profitData.summary.net_profit)}
|
||||||
</p>
|
</p>
|
||||||
<p className='text-sm text-gray-600'>
|
<p className='text-sm text-gray-600'>
|
||||||
Margin: {formatPercentage(profitData.summary.net_profit_margin)}
|
Margin: {formatPercentage(profitData.summary.net_profit_margin)}
|
||||||
|
|||||||
@@ -0,0 +1,291 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
// React Imports
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
// MUI Imports
|
||||||
|
import type { BoxProps } from '@mui/material/Box'
|
||||||
|
import Button from '@mui/material/Button'
|
||||||
|
import IconButton from '@mui/material/IconButton'
|
||||||
|
import List from '@mui/material/List'
|
||||||
|
import ListItem from '@mui/material/ListItem'
|
||||||
|
import Typography from '@mui/material/Typography'
|
||||||
|
import { styled } from '@mui/material/styles'
|
||||||
|
|
||||||
|
// Third-party Imports
|
||||||
|
import { useDropzone } from 'react-dropzone'
|
||||||
|
|
||||||
|
// Component Imports
|
||||||
|
import Link from '@components/Link'
|
||||||
|
import CustomAvatar from '@core/components/mui/Avatar'
|
||||||
|
|
||||||
|
// Styled Component Imports
|
||||||
|
import AppReactDropzone from '@/libs/styles/AppReactDropzone'
|
||||||
|
|
||||||
|
type FileProp = {
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
size: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImageUploadProps {
|
||||||
|
// Required props
|
||||||
|
onUpload: (file: File) => Promise<string> | string // Returns image URL
|
||||||
|
|
||||||
|
// Optional customization props
|
||||||
|
title?: string | null // Made nullable
|
||||||
|
currentImageUrl?: string
|
||||||
|
onImageRemove?: () => void
|
||||||
|
onImageChange?: (url: string) => void
|
||||||
|
|
||||||
|
// Upload state
|
||||||
|
isUploading?: boolean
|
||||||
|
|
||||||
|
// UI customization
|
||||||
|
maxFileSize?: number // in bytes
|
||||||
|
acceptedFileTypes?: string[]
|
||||||
|
showUrlOption?: boolean
|
||||||
|
uploadButtonText?: string
|
||||||
|
browseButtonText?: string
|
||||||
|
dragDropText?: string
|
||||||
|
replaceText?: string
|
||||||
|
|
||||||
|
// Style customization
|
||||||
|
className?: string
|
||||||
|
disabled?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
// Styled Dropzone Component
|
||||||
|
const Dropzone = styled(AppReactDropzone)<BoxProps>(({ theme }) => ({
|
||||||
|
'& .dropzone': {
|
||||||
|
minHeight: 'unset',
|
||||||
|
padding: theme.spacing(12),
|
||||||
|
[theme.breakpoints.down('sm')]: {
|
||||||
|
paddingInline: theme.spacing(5)
|
||||||
|
},
|
||||||
|
'&+.MuiList-root .MuiListItem-root .file-name': {
|
||||||
|
fontWeight: theme.typography.body1.fontWeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
const ImageUpload: React.FC<ImageUploadProps> = ({
|
||||||
|
onUpload,
|
||||||
|
title = null, // Default to null
|
||||||
|
currentImageUrl = '',
|
||||||
|
onImageRemove,
|
||||||
|
onImageChange,
|
||||||
|
isUploading = false,
|
||||||
|
maxFileSize = 5 * 1024 * 1024, // 5MB default
|
||||||
|
acceptedFileTypes = ['image/*'],
|
||||||
|
showUrlOption = true,
|
||||||
|
uploadButtonText = 'Upload',
|
||||||
|
browseButtonText = 'Browse Image',
|
||||||
|
dragDropText = 'Drag and Drop Your Image Here.',
|
||||||
|
replaceText = 'Drop New Image to Replace',
|
||||||
|
className = '',
|
||||||
|
disabled = false
|
||||||
|
}) => {
|
||||||
|
// States
|
||||||
|
const [files, setFiles] = useState<File[]>([])
|
||||||
|
const [error, setError] = useState<string>('')
|
||||||
|
|
||||||
|
const handleUpload = async () => {
|
||||||
|
if (!files.length) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
setError('')
|
||||||
|
const imageUrl = await onUpload(files[0])
|
||||||
|
|
||||||
|
if (typeof imageUrl === 'string') {
|
||||||
|
onImageChange?.(imageUrl)
|
||||||
|
setFiles([]) // Clear files after successful upload
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Upload failed')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks
|
||||||
|
const { getRootProps, getInputProps } = useDropzone({
|
||||||
|
onDrop: (acceptedFiles: File[]) => {
|
||||||
|
setError('')
|
||||||
|
|
||||||
|
if (acceptedFiles.length === 0) return
|
||||||
|
|
||||||
|
const file = acceptedFiles[0]
|
||||||
|
|
||||||
|
// Validate file size
|
||||||
|
if (file.size > maxFileSize) {
|
||||||
|
setError(`File size should be less than ${formatFileSize(maxFileSize)}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace files instead of adding to them
|
||||||
|
setFiles([file])
|
||||||
|
},
|
||||||
|
accept: acceptedFileTypes.reduce((acc, type) => ({ ...acc, [type]: [] }), {}),
|
||||||
|
disabled: disabled || isUploading
|
||||||
|
})
|
||||||
|
|
||||||
|
const formatFileSize = (bytes: number): string => {
|
||||||
|
if (bytes === 0) return '0 Bytes'
|
||||||
|
const k = 1024
|
||||||
|
const sizes = ['Bytes', 'KB', 'MB', 'GB']
|
||||||
|
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||||
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderFilePreview = (file: FileProp) => {
|
||||||
|
if (file.type.startsWith('image')) {
|
||||||
|
return <img width={38} height={38} alt={file.name} src={URL.createObjectURL(file as any)} />
|
||||||
|
} else {
|
||||||
|
return <i className='tabler-file-description' />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRemoveFile = (file: FileProp) => {
|
||||||
|
const filtered = files.filter((i: FileProp) => i.name !== file.name)
|
||||||
|
setFiles(filtered)
|
||||||
|
setError('')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRemoveCurrentImage = () => {
|
||||||
|
onImageRemove?.()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRemoveAllFiles = () => {
|
||||||
|
setFiles([])
|
||||||
|
setError('')
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileList = files.map((file: FileProp) => (
|
||||||
|
<ListItem key={file.name} className='pis-4 plb-3'>
|
||||||
|
<div className='file-details'>
|
||||||
|
<div className='file-preview'>{renderFilePreview(file)}</div>
|
||||||
|
<div>
|
||||||
|
<Typography className='file-name font-medium' color='text.primary'>
|
||||||
|
{file.name}
|
||||||
|
</Typography>
|
||||||
|
<Typography className='file-size' variant='body2'>
|
||||||
|
{formatFileSize(file.size)}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<IconButton onClick={() => handleRemoveFile(file)} disabled={isUploading}>
|
||||||
|
<i className='tabler-x text-xl' />
|
||||||
|
</IconButton>
|
||||||
|
</ListItem>
|
||||||
|
))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dropzone className={className}>
|
||||||
|
{/* Conditional title and URL option header */}
|
||||||
|
{title && (
|
||||||
|
<div className='flex justify-between items-center mb-4'>
|
||||||
|
<Typography variant='h6' component='h2'>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
{showUrlOption && (
|
||||||
|
<Typography component={Link} color='primary.main' className='font-medium'>
|
||||||
|
Add media from URL
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div {...getRootProps({ className: 'dropzone' })}>
|
||||||
|
<input {...getInputProps()} />
|
||||||
|
<div className='flex items-center flex-col gap-2 text-center'>
|
||||||
|
<CustomAvatar variant='rounded' skin='light' color='secondary'>
|
||||||
|
<i className='tabler-upload' />
|
||||||
|
</CustomAvatar>
|
||||||
|
<Typography variant='h4'>{currentImageUrl && !files.length ? replaceText : dragDropText}</Typography>
|
||||||
|
<Typography color='text.disabled'>or</Typography>
|
||||||
|
<Button variant='tonal' size='small' disabled={disabled || isUploading}>
|
||||||
|
{browseButtonText}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Error Message */}
|
||||||
|
{error && (
|
||||||
|
<Typography color='error' variant='body2' className='mt-2 text-center'>
|
||||||
|
{error}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Show current image if it exists */}
|
||||||
|
{currentImageUrl && !files.length && (
|
||||||
|
<div className='current-image mb-4'>
|
||||||
|
<Typography variant='subtitle2' className='mb-2'>
|
||||||
|
Current Image:
|
||||||
|
</Typography>
|
||||||
|
<div className='flex items-center justify-between p-3 border border-gray-200 rounded'>
|
||||||
|
<div className='flex items-center gap-3'>
|
||||||
|
<img width={60} height={60} alt='Current image' src={currentImageUrl} className='rounded object-cover' />
|
||||||
|
<div>
|
||||||
|
<Typography className='font-medium' color='text.primary'>
|
||||||
|
Current image
|
||||||
|
</Typography>
|
||||||
|
<Typography variant='body2' color='text.secondary'>
|
||||||
|
Uploaded image
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{onImageRemove && (
|
||||||
|
<IconButton onClick={handleRemoveCurrentImage} color='error' disabled={isUploading}>
|
||||||
|
<i className='tabler-x text-xl' />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* File list and upload buttons */}
|
||||||
|
{files.length > 0 && (
|
||||||
|
<>
|
||||||
|
<List>{fileList}</List>
|
||||||
|
<div className='buttons'>
|
||||||
|
<Button color='error' variant='tonal' onClick={handleRemoveAllFiles} disabled={isUploading}>
|
||||||
|
Remove All
|
||||||
|
</Button>
|
||||||
|
<Button variant='contained' onClick={handleUpload} disabled={isUploading}>
|
||||||
|
{isUploading ? 'Uploading...' : uploadButtonText}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Dropzone>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ImageUpload
|
||||||
|
|
||||||
|
// ===== USAGE EXAMPLES =====
|
||||||
|
|
||||||
|
// 1. Without title
|
||||||
|
// <ImageUpload
|
||||||
|
// onUpload={handleUpload}
|
||||||
|
// currentImageUrl={imageUrl}
|
||||||
|
// onImageChange={setImageUrl}
|
||||||
|
// onImageRemove={() => setImageUrl('')}
|
||||||
|
// />
|
||||||
|
|
||||||
|
// 2. With title
|
||||||
|
// <ImageUpload
|
||||||
|
// title="Product Image"
|
||||||
|
// onUpload={handleUpload}
|
||||||
|
// currentImageUrl={imageUrl}
|
||||||
|
// onImageChange={setImageUrl}
|
||||||
|
// onImageRemove={() => setImageUrl('')}
|
||||||
|
// />
|
||||||
|
|
||||||
|
// 3. Explicitly set title to null
|
||||||
|
// <ImageUpload
|
||||||
|
// title={null}
|
||||||
|
// onUpload={handleUpload}
|
||||||
|
// currentImageUrl={imageUrl}
|
||||||
|
// onImageChange={setImageUrl}
|
||||||
|
// onImageRemove={() => setImageUrl('')}
|
||||||
|
// />
|
||||||
@@ -0,0 +1,465 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
// React Imports
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
// MUI Imports
|
||||||
|
import type { BoxProps } from '@mui/material/Box'
|
||||||
|
import Button from '@mui/material/Button'
|
||||||
|
import IconButton from '@mui/material/IconButton'
|
||||||
|
import List from '@mui/material/List'
|
||||||
|
import ListItem from '@mui/material/ListItem'
|
||||||
|
import Typography from '@mui/material/Typography'
|
||||||
|
import Chip from '@mui/material/Chip'
|
||||||
|
import LinearProgress from '@mui/material/LinearProgress'
|
||||||
|
import { styled } from '@mui/material/styles'
|
||||||
|
|
||||||
|
// Third-party Imports
|
||||||
|
import { useDropzone } from 'react-dropzone'
|
||||||
|
|
||||||
|
// Component Imports
|
||||||
|
import Link from '@components/Link'
|
||||||
|
import CustomAvatar from '@core/components/mui/Avatar'
|
||||||
|
|
||||||
|
// Styled Component Imports
|
||||||
|
import AppReactDropzone from '@/libs/styles/AppReactDropzone'
|
||||||
|
|
||||||
|
type FileProp = {
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
size: number
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadedImage = {
|
||||||
|
id: string
|
||||||
|
url: string
|
||||||
|
name: string
|
||||||
|
size: number
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadProgress = {
|
||||||
|
[fileId: string]: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MultipleImageUploadProps {
|
||||||
|
// Required props
|
||||||
|
onUpload: (files: File[]) => Promise<string[]> | string[] // Returns array of image URLs
|
||||||
|
onSingleUpload?: (file: File) => Promise<string> | string // For individual file upload
|
||||||
|
|
||||||
|
// Optional customization props
|
||||||
|
title?: string | null
|
||||||
|
currentImages?: UploadedImage[]
|
||||||
|
onImagesChange?: (images: UploadedImage[]) => void
|
||||||
|
onImageRemove?: (imageId: string) => void
|
||||||
|
|
||||||
|
// Upload state
|
||||||
|
isUploading?: boolean
|
||||||
|
uploadProgress?: UploadProgress
|
||||||
|
|
||||||
|
// Limits
|
||||||
|
maxFiles?: number
|
||||||
|
maxFileSize?: number // in bytes
|
||||||
|
acceptedFileTypes?: string[]
|
||||||
|
|
||||||
|
// UI customization
|
||||||
|
showUrlOption?: boolean
|
||||||
|
uploadButtonText?: string
|
||||||
|
browseButtonText?: string
|
||||||
|
dragDropText?: string
|
||||||
|
replaceText?: string
|
||||||
|
maxFilesText?: string
|
||||||
|
|
||||||
|
// Style customization
|
||||||
|
className?: string
|
||||||
|
disabled?: boolean
|
||||||
|
|
||||||
|
// Upload modes
|
||||||
|
uploadMode?: 'batch' | 'individual' // batch: upload all at once, individual: upload one by one
|
||||||
|
}
|
||||||
|
|
||||||
|
// Styled Dropzone Component
|
||||||
|
const Dropzone = styled(AppReactDropzone)<BoxProps>(({ theme }) => ({
|
||||||
|
'& .dropzone': {
|
||||||
|
minHeight: 'unset',
|
||||||
|
padding: theme.spacing(12),
|
||||||
|
[theme.breakpoints.down('sm')]: {
|
||||||
|
paddingInline: theme.spacing(5)
|
||||||
|
},
|
||||||
|
'&+.MuiList-root .MuiListItem-root .file-name': {
|
||||||
|
fontWeight: theme.typography.body1.fontWeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
const MultipleImageUpload: React.FC<MultipleImageUploadProps> = ({
|
||||||
|
onUpload,
|
||||||
|
onSingleUpload,
|
||||||
|
title = null,
|
||||||
|
currentImages = [],
|
||||||
|
onImagesChange,
|
||||||
|
onImageRemove,
|
||||||
|
isUploading = false,
|
||||||
|
uploadProgress = {},
|
||||||
|
maxFiles = 10,
|
||||||
|
maxFileSize = 5 * 1024 * 1024, // 5MB default
|
||||||
|
acceptedFileTypes = ['image/*'],
|
||||||
|
showUrlOption = true,
|
||||||
|
uploadButtonText = 'Upload All',
|
||||||
|
browseButtonText = 'Browse Images',
|
||||||
|
dragDropText = 'Drag and Drop Your Images Here.',
|
||||||
|
replaceText = 'Drop Images to Add More',
|
||||||
|
maxFilesText = 'Maximum {max} files allowed',
|
||||||
|
className = '',
|
||||||
|
disabled = false,
|
||||||
|
uploadMode = 'batch'
|
||||||
|
}) => {
|
||||||
|
// States
|
||||||
|
const [files, setFiles] = useState<File[]>([])
|
||||||
|
const [error, setError] = useState<string>('')
|
||||||
|
const [individualUploading, setIndividualUploading] = useState<Set<string>>(new Set())
|
||||||
|
|
||||||
|
const handleBatchUpload = async () => {
|
||||||
|
if (!files.length) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
setError('')
|
||||||
|
const imageUrls = await onUpload(files)
|
||||||
|
|
||||||
|
if (Array.isArray(imageUrls)) {
|
||||||
|
const newImages: UploadedImage[] = files.map((file, index) => ({
|
||||||
|
id: `${Date.now()}-${index}`,
|
||||||
|
url: imageUrls[index],
|
||||||
|
name: file.name,
|
||||||
|
size: file.size
|
||||||
|
}))
|
||||||
|
|
||||||
|
const updatedImages = [...currentImages, ...newImages]
|
||||||
|
onImagesChange?.(updatedImages)
|
||||||
|
setFiles([]) // Clear files after successful upload
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Upload failed')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleIndividualUpload = async (file: File, fileIndex: number) => {
|
||||||
|
if (!onSingleUpload) return
|
||||||
|
|
||||||
|
const fileId = `${file.name}-${fileIndex}`
|
||||||
|
setIndividualUploading(prev => new Set(prev).add(fileId))
|
||||||
|
|
||||||
|
try {
|
||||||
|
setError('')
|
||||||
|
const imageUrl = await onSingleUpload(file)
|
||||||
|
|
||||||
|
if (typeof imageUrl === 'string') {
|
||||||
|
const newImage: UploadedImage = {
|
||||||
|
id: `${Date.now()}-${fileIndex}`,
|
||||||
|
url: imageUrl,
|
||||||
|
name: file.name,
|
||||||
|
size: file.size
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedImages = [...currentImages, newImage]
|
||||||
|
onImagesChange?.(updatedImages)
|
||||||
|
|
||||||
|
// Remove uploaded file from pending files
|
||||||
|
setFiles(prev => prev.filter((_, index) => index !== fileIndex))
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Upload failed')
|
||||||
|
} finally {
|
||||||
|
setIndividualUploading(prev => {
|
||||||
|
const newSet = new Set(prev)
|
||||||
|
newSet.delete(fileId)
|
||||||
|
return newSet
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks
|
||||||
|
const { getRootProps, getInputProps } = useDropzone({
|
||||||
|
onDrop: (acceptedFiles: File[]) => {
|
||||||
|
setError('')
|
||||||
|
|
||||||
|
if (acceptedFiles.length === 0) return
|
||||||
|
|
||||||
|
const totalFiles = currentImages.length + files.length + acceptedFiles.length
|
||||||
|
|
||||||
|
if (totalFiles > maxFiles) {
|
||||||
|
setError(`Cannot upload more than ${maxFiles} files. Current: ${currentImages.length + files.length}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate file sizes
|
||||||
|
const invalidFiles = acceptedFiles.filter(file => file.size > maxFileSize)
|
||||||
|
if (invalidFiles.length > 0) {
|
||||||
|
setError(`Some files exceed ${formatFileSize(maxFileSize)} limit`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add to existing files
|
||||||
|
setFiles(prev => [...prev, ...acceptedFiles])
|
||||||
|
},
|
||||||
|
accept: acceptedFileTypes.reduce((acc, type) => ({ ...acc, [type]: [] }), {}),
|
||||||
|
disabled: disabled || isUploading,
|
||||||
|
multiple: true
|
||||||
|
})
|
||||||
|
|
||||||
|
const formatFileSize = (bytes: number): string => {
|
||||||
|
if (bytes === 0) return '0 Bytes'
|
||||||
|
const k = 1024
|
||||||
|
const sizes = ['Bytes', 'KB', 'MB', 'GB']
|
||||||
|
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||||
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderFilePreview = (file: FileProp) => {
|
||||||
|
if (file.type.startsWith('image')) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
width={38}
|
||||||
|
height={38}
|
||||||
|
alt={file.name}
|
||||||
|
src={URL.createObjectURL(file as any)}
|
||||||
|
className='rounded object-cover'
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return <i className='tabler-file-description' />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRemoveFile = (fileIndex: number) => {
|
||||||
|
setFiles(prev => prev.filter((_, index) => index !== fileIndex))
|
||||||
|
setError('')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRemoveCurrentImage = (imageId: string) => {
|
||||||
|
onImageRemove?.(imageId)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRemoveAllFiles = () => {
|
||||||
|
setFiles([])
|
||||||
|
setError('')
|
||||||
|
}
|
||||||
|
|
||||||
|
const isIndividualUploading = (file: File, index: number) => {
|
||||||
|
const fileId = `${file.name}-${index}`
|
||||||
|
return individualUploading.has(fileId)
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileList = files.map((file: File, index: number) => {
|
||||||
|
const isFileUploading = isIndividualUploading(file, index)
|
||||||
|
const progress = uploadProgress[`${file.name}-${index}`] || 0
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ListItem key={`${file.name}-${index}`} className='pis-4 plb-3'>
|
||||||
|
<div className='file-details flex-1'>
|
||||||
|
<div className='file-preview'>{renderFilePreview(file)}</div>
|
||||||
|
<div className='flex-1'>
|
||||||
|
<Typography className='file-name font-medium' color='text.primary'>
|
||||||
|
{file.name}
|
||||||
|
</Typography>
|
||||||
|
<Typography className='file-size' variant='body2'>
|
||||||
|
{formatFileSize(file.size)}
|
||||||
|
</Typography>
|
||||||
|
{isFileUploading && progress > 0 && (
|
||||||
|
<LinearProgress variant='determinate' value={progress} className='mt-1' />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center gap-2'>
|
||||||
|
{uploadMode === 'individual' && onSingleUpload && (
|
||||||
|
<Button
|
||||||
|
variant='outlined'
|
||||||
|
size='small'
|
||||||
|
onClick={() => handleIndividualUpload(file, index)}
|
||||||
|
disabled={isUploading || isFileUploading}
|
||||||
|
>
|
||||||
|
{isFileUploading ? 'Uploading...' : 'Upload'}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<IconButton onClick={() => handleRemoveFile(index)} disabled={isUploading || isFileUploading}>
|
||||||
|
<i className='tabler-x text-xl' />
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
</ListItem>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
const currentImagesList = currentImages.map(image => (
|
||||||
|
<ListItem key={image.id} className='pis-4 plb-3'>
|
||||||
|
<div className='file-details flex-1'>
|
||||||
|
<div className='file-preview'>
|
||||||
|
<img width={38} height={38} alt={image.name} src={image.url} className='rounded object-cover' />
|
||||||
|
</div>
|
||||||
|
<div className='flex-1'>
|
||||||
|
<Typography className='file-name font-medium' color='text.primary'>
|
||||||
|
{image.name}
|
||||||
|
</Typography>
|
||||||
|
<Typography className='file-size' variant='body2'>
|
||||||
|
{formatFileSize(image.size)}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center gap-2'>
|
||||||
|
<Chip label='Uploaded' color='success' size='small' />
|
||||||
|
{onImageRemove && (
|
||||||
|
<IconButton onClick={() => handleRemoveCurrentImage(image.id)} color='error' disabled={isUploading}>
|
||||||
|
<i className='tabler-x text-xl' />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ListItem>
|
||||||
|
))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dropzone className={className}>
|
||||||
|
{/* Conditional title and URL option header */}
|
||||||
|
{title && (
|
||||||
|
<div className='flex justify-between items-center mb-4'>
|
||||||
|
<Typography variant='h6' component='h2'>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
{showUrlOption && (
|
||||||
|
<Typography component={Link} color='primary.main' className='font-medium'>
|
||||||
|
Add media from URL
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* File limits info */}
|
||||||
|
<div className='flex justify-between items-center mb-4'>
|
||||||
|
<Typography variant='body2' color='text.secondary'>
|
||||||
|
{maxFilesText.replace('{max}', maxFiles.toString())}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant='body2' color='text.secondary'>
|
||||||
|
{currentImages.length + files.length} / {maxFiles} files
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div {...getRootProps({ className: 'dropzone' })}>
|
||||||
|
<input {...getInputProps()} />
|
||||||
|
<div className='flex items-center flex-col gap-2 text-center'>
|
||||||
|
<CustomAvatar variant='rounded' skin='light' color='secondary'>
|
||||||
|
<i className='tabler-upload' />
|
||||||
|
</CustomAvatar>
|
||||||
|
<Typography variant='h4'>
|
||||||
|
{currentImages.length > 0 || files.length > 0 ? replaceText : dragDropText}
|
||||||
|
</Typography>
|
||||||
|
<Typography color='text.disabled'>or</Typography>
|
||||||
|
<Button variant='tonal' size='small' disabled={disabled || isUploading}>
|
||||||
|
{browseButtonText}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Error Message */}
|
||||||
|
{error && (
|
||||||
|
<Typography color='error' variant='body2' className='mt-2 text-center'>
|
||||||
|
{error}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Current uploaded images */}
|
||||||
|
{currentImages.length > 0 && (
|
||||||
|
<div className='mt-4'>
|
||||||
|
<Typography variant='subtitle2' className='mb-2'>
|
||||||
|
Uploaded Images ({currentImages.length}):
|
||||||
|
</Typography>
|
||||||
|
<List>{currentImagesList}</List>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Pending files list and upload buttons */}
|
||||||
|
{files.length > 0 && (
|
||||||
|
<div className='mt-4'>
|
||||||
|
<Typography variant='subtitle2' className='mb-2'>
|
||||||
|
Pending Files ({files.length}):
|
||||||
|
</Typography>
|
||||||
|
<List>{fileList}</List>
|
||||||
|
<div className='buttons flex gap-2 mt-3'>
|
||||||
|
<Button color='error' variant='tonal' onClick={handleRemoveAllFiles} disabled={isUploading}>
|
||||||
|
Remove All
|
||||||
|
</Button>
|
||||||
|
{uploadMode === 'batch' && (
|
||||||
|
<Button variant='contained' onClick={handleBatchUpload} disabled={isUploading || files.length === 0}>
|
||||||
|
{isUploading ? 'Uploading...' : `${uploadButtonText} (${files.length})`}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Dropzone>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MultipleImageUpload
|
||||||
|
|
||||||
|
// ===== USAGE EXAMPLES =====
|
||||||
|
|
||||||
|
// 1. Batch upload mode (upload all files at once)
|
||||||
|
// const [images, setImages] = useState<UploadedImage[]>([])
|
||||||
|
//
|
||||||
|
// <MultipleImageUpload
|
||||||
|
// title="Product Images"
|
||||||
|
// onUpload={handleBatchUpload}
|
||||||
|
// currentImages={images}
|
||||||
|
// onImagesChange={setImages}
|
||||||
|
// onImageRemove={(id) => setImages(prev => prev.filter(img => img.id !== id))}
|
||||||
|
// maxFiles={5}
|
||||||
|
// uploadMode="batch"
|
||||||
|
// />
|
||||||
|
|
||||||
|
// 2. Individual upload mode (upload files one by one)
|
||||||
|
// <MultipleImageUpload
|
||||||
|
// title="Gallery Images"
|
||||||
|
// onUpload={handleBatchUpload}
|
||||||
|
// onSingleUpload={handleSingleUpload}
|
||||||
|
// currentImages={images}
|
||||||
|
// onImagesChange={setImages}
|
||||||
|
// onImageRemove={(id) => setImages(prev => prev.filter(img => img.id !== id))}
|
||||||
|
// maxFiles={10}
|
||||||
|
// uploadMode="individual"
|
||||||
|
// uploadProgress={uploadProgress}
|
||||||
|
// />
|
||||||
|
|
||||||
|
// 3. Without title, custom limits
|
||||||
|
// <MultipleImageUpload
|
||||||
|
// title={null}
|
||||||
|
// onUpload={handleBatchUpload}
|
||||||
|
// currentImages={images}
|
||||||
|
// onImagesChange={setImages}
|
||||||
|
// maxFiles={3}
|
||||||
|
// maxFileSize={2 * 1024 * 1024} // 2MB
|
||||||
|
// acceptedFileTypes={['image/jpeg', 'image/png']}
|
||||||
|
// />
|
||||||
|
|
||||||
|
// 4. Example upload handlers
|
||||||
|
// const handleBatchUpload = async (files: File[]): Promise<string[]> => {
|
||||||
|
// const formData = new FormData()
|
||||||
|
// files.forEach(file => formData.append('images', file))
|
||||||
|
//
|
||||||
|
// const response = await fetch('/api/upload-multiple', {
|
||||||
|
// method: 'POST',
|
||||||
|
// body: formData
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// const result = await response.json()
|
||||||
|
// return result.urls // Array of uploaded image URLs
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// const handleSingleUpload = async (file: File): Promise<string> => {
|
||||||
|
// const formData = new FormData()
|
||||||
|
// formData.append('image', file)
|
||||||
|
//
|
||||||
|
// const response = await fetch('/api/upload-single', {
|
||||||
|
// method: 'POST',
|
||||||
|
// body: formData
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// const result = await response.json()
|
||||||
|
// return result.url // Single uploaded image URL
|
||||||
|
// }
|
||||||
@@ -0,0 +1,276 @@
|
|||||||
|
// React Imports
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
// MUI Imports
|
||||||
|
import TextField from '@mui/material/TextField'
|
||||||
|
import Typography from '@mui/material/Typography'
|
||||||
|
import { useTheme } from '@mui/material/styles'
|
||||||
|
import type { TextFieldProps } from '@mui/material/TextField'
|
||||||
|
|
||||||
|
interface DateRangePickerProps {
|
||||||
|
/**
|
||||||
|
* Start date value (Date object or date string)
|
||||||
|
*/
|
||||||
|
startDate: Date | string | null
|
||||||
|
/**
|
||||||
|
* End date value (Date object or date string)
|
||||||
|
*/
|
||||||
|
endDate: Date | string | null
|
||||||
|
/**
|
||||||
|
* Callback when start date changes
|
||||||
|
*/
|
||||||
|
onStartDateChange: (date: Date | null) => void
|
||||||
|
/**
|
||||||
|
* Callback when end date changes
|
||||||
|
*/
|
||||||
|
onEndDateChange: (date: Date | null) => void
|
||||||
|
/**
|
||||||
|
* Label for start date field
|
||||||
|
*/
|
||||||
|
startLabel?: string
|
||||||
|
/**
|
||||||
|
* Label for end date field
|
||||||
|
*/
|
||||||
|
endLabel?: string
|
||||||
|
/**
|
||||||
|
* Placeholder for start date field
|
||||||
|
*/
|
||||||
|
startPlaceholder?: string
|
||||||
|
/**
|
||||||
|
* Placeholder for end date field
|
||||||
|
*/
|
||||||
|
endPlaceholder?: string
|
||||||
|
/**
|
||||||
|
* Size of the text fields
|
||||||
|
*/
|
||||||
|
size?: 'small' | 'medium'
|
||||||
|
/**
|
||||||
|
* Whether the fields are disabled
|
||||||
|
*/
|
||||||
|
disabled?: boolean
|
||||||
|
/**
|
||||||
|
* Whether the fields are required
|
||||||
|
*/
|
||||||
|
required?: boolean
|
||||||
|
/**
|
||||||
|
* Custom className for the container
|
||||||
|
*/
|
||||||
|
className?: string
|
||||||
|
/**
|
||||||
|
* Custom styles for the container
|
||||||
|
*/
|
||||||
|
containerStyle?: React.CSSProperties
|
||||||
|
/**
|
||||||
|
* Separator between date fields
|
||||||
|
*/
|
||||||
|
separator?: string
|
||||||
|
/**
|
||||||
|
* Custom props for start date TextField
|
||||||
|
*/
|
||||||
|
startTextFieldProps?: Omit<TextFieldProps, 'type' | 'value' | 'onChange'>
|
||||||
|
/**
|
||||||
|
* Custom props for end date TextField
|
||||||
|
*/
|
||||||
|
endTextFieldProps?: Omit<TextFieldProps, 'type' | 'value' | 'onChange'>
|
||||||
|
/**
|
||||||
|
* Error state for start date
|
||||||
|
*/
|
||||||
|
startError?: boolean
|
||||||
|
/**
|
||||||
|
* Error state for end date
|
||||||
|
*/
|
||||||
|
endError?: boolean
|
||||||
|
/**
|
||||||
|
* Helper text for start date
|
||||||
|
*/
|
||||||
|
startHelperText?: string
|
||||||
|
/**
|
||||||
|
* Helper text for end date
|
||||||
|
*/
|
||||||
|
endHelperText?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utility functions
|
||||||
|
const formatDateForInput = (date: Date | string | null): string => {
|
||||||
|
if (!date) return ''
|
||||||
|
|
||||||
|
const dateObj = typeof date === 'string' ? new Date(date) : date
|
||||||
|
|
||||||
|
if (isNaN(dateObj.getTime())) return ''
|
||||||
|
|
||||||
|
return dateObj.toISOString().split('T')[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
const parseDateFromInput = (dateString: string): Date | null => {
|
||||||
|
if (!dateString) return null
|
||||||
|
|
||||||
|
const date = new Date(dateString)
|
||||||
|
return isNaN(date.getTime()) ? null : date
|
||||||
|
}
|
||||||
|
|
||||||
|
const DateRangePicker: React.FC<DateRangePickerProps> = ({
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
onStartDateChange,
|
||||||
|
onEndDateChange,
|
||||||
|
startLabel,
|
||||||
|
endLabel,
|
||||||
|
startPlaceholder,
|
||||||
|
endPlaceholder,
|
||||||
|
size = 'small',
|
||||||
|
disabled = false,
|
||||||
|
required = false,
|
||||||
|
className = '',
|
||||||
|
containerStyle = {},
|
||||||
|
separator = '-',
|
||||||
|
startTextFieldProps = {},
|
||||||
|
endTextFieldProps = {},
|
||||||
|
startError = false,
|
||||||
|
endError = false,
|
||||||
|
startHelperText,
|
||||||
|
endHelperText
|
||||||
|
}) => {
|
||||||
|
const theme = useTheme()
|
||||||
|
|
||||||
|
const defaultTextFieldSx = {
|
||||||
|
'& .MuiOutlinedInput-root': {
|
||||||
|
'&.Mui-focused fieldset': {
|
||||||
|
borderColor: 'primary.main'
|
||||||
|
},
|
||||||
|
'& fieldset': {
|
||||||
|
borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleStartDateChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const date = parseDateFromInput(event.target.value)
|
||||||
|
onStartDateChange(date)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleEndDateChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const date = parseDateFromInput(event.target.value)
|
||||||
|
onEndDateChange(date)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`flex items-center gap-4 ${className}`} style={containerStyle}>
|
||||||
|
<TextField
|
||||||
|
type='date'
|
||||||
|
label={startLabel}
|
||||||
|
placeholder={startPlaceholder}
|
||||||
|
value={formatDateForInput(startDate)}
|
||||||
|
onChange={handleStartDateChange}
|
||||||
|
size={size}
|
||||||
|
disabled={disabled}
|
||||||
|
required={required}
|
||||||
|
error={startError}
|
||||||
|
helperText={startHelperText}
|
||||||
|
sx={{
|
||||||
|
...defaultTextFieldSx,
|
||||||
|
...startTextFieldProps.sx
|
||||||
|
}}
|
||||||
|
{...startTextFieldProps}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Typography
|
||||||
|
color='text.secondary'
|
||||||
|
sx={{
|
||||||
|
userSelect: 'none',
|
||||||
|
fontSize: size === 'small' ? '14px' : '16px'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{separator}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
type='date'
|
||||||
|
label={endLabel}
|
||||||
|
placeholder={endPlaceholder}
|
||||||
|
value={formatDateForInput(endDate)}
|
||||||
|
onChange={handleEndDateChange}
|
||||||
|
size={size}
|
||||||
|
disabled={disabled}
|
||||||
|
required={required}
|
||||||
|
error={endError}
|
||||||
|
helperText={endHelperText}
|
||||||
|
sx={{
|
||||||
|
...defaultTextFieldSx,
|
||||||
|
...endTextFieldProps.sx
|
||||||
|
}}
|
||||||
|
{...endTextFieldProps}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DateRangePicker
|
||||||
|
|
||||||
|
// Export utility functions for external use
|
||||||
|
export { formatDateForInput, parseDateFromInput }
|
||||||
|
|
||||||
|
// Example usage:
|
||||||
|
/*
|
||||||
|
import DateRangePicker from '@/components/DateRangePicker'
|
||||||
|
|
||||||
|
// In your component:
|
||||||
|
const [startDate, setStartDate] = useState<Date | null>(new Date())
|
||||||
|
const [endDate, setEndDate] = useState<Date | null>(new Date())
|
||||||
|
|
||||||
|
// Basic usage
|
||||||
|
<DateRangePicker
|
||||||
|
startDate={startDate}
|
||||||
|
endDate={endDate}
|
||||||
|
onStartDateChange={setStartDate}
|
||||||
|
onEndDateChange={setEndDate}
|
||||||
|
/>
|
||||||
|
|
||||||
|
// With labels and validation
|
||||||
|
<DateRangePicker
|
||||||
|
startDate={startDate}
|
||||||
|
endDate={endDate}
|
||||||
|
onStartDateChange={setStartDate}
|
||||||
|
onEndDateChange={setEndDate}
|
||||||
|
startLabel="Tanggal Mulai"
|
||||||
|
endLabel="Tanggal Selesai"
|
||||||
|
required
|
||||||
|
startError={startDate && endDate && startDate > endDate}
|
||||||
|
endError={startDate && endDate && startDate > endDate}
|
||||||
|
startHelperText={startDate && endDate && startDate > endDate ? "Tanggal mulai tidak boleh lebih besar dari tanggal selesai" : ""}
|
||||||
|
/>
|
||||||
|
|
||||||
|
// Custom styling
|
||||||
|
<DateRangePicker
|
||||||
|
startDate={startDate}
|
||||||
|
endDate={endDate}
|
||||||
|
onStartDateChange={setStartDate}
|
||||||
|
onEndDateChange={setEndDate}
|
||||||
|
separator="sampai"
|
||||||
|
size="medium"
|
||||||
|
className="my-custom-class"
|
||||||
|
startTextFieldProps={{
|
||||||
|
variant: "filled",
|
||||||
|
sx: { minWidth: '150px' }
|
||||||
|
}}
|
||||||
|
endTextFieldProps={{
|
||||||
|
variant: "filled",
|
||||||
|
sx: { minWidth: '150px' }
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
// Integration with your existing filter logic
|
||||||
|
const handleDateRangeChange = (start: Date | null, end: Date | null) => {
|
||||||
|
setFilter({
|
||||||
|
...filter,
|
||||||
|
date_from: start ? formatDateDDMMYYYY(start) : null,
|
||||||
|
date_to: end ? formatDateDDMMYYYY(end) : null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
<DateRangePicker
|
||||||
|
startDate={filter.date_from ? new Date(filter.date_from) : null}
|
||||||
|
endDate={filter.date_to ? new Date(filter.date_to) : null}
|
||||||
|
onStartDateChange={(date) => handleDateRangeChange(date, filter.date_to ? new Date(filter.date_to) : null)}
|
||||||
|
onEndDateChange={(date) => handleDateRangeChange(filter.date_from ? new Date(filter.date_from) : null, date)}
|
||||||
|
/>
|
||||||
|
*/
|
||||||
@@ -0,0 +1,257 @@
|
|||||||
|
// React Imports
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
|
// MUI Imports
|
||||||
|
import Button from '@mui/material/Button'
|
||||||
|
import Menu from '@mui/material/Menu'
|
||||||
|
import MenuItem from '@mui/material/MenuItem'
|
||||||
|
import { styled } from '@mui/material/styles'
|
||||||
|
|
||||||
|
function toTitleCase(str: string): string {
|
||||||
|
return str
|
||||||
|
.toLowerCase()
|
||||||
|
.split(/\s+/) // split by spaces
|
||||||
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||||
|
.join(' ')
|
||||||
|
}
|
||||||
|
|
||||||
|
const DropdownButton = styled(Button)(({ theme }) => ({
|
||||||
|
textTransform: 'none',
|
||||||
|
fontWeight: 400,
|
||||||
|
borderRadius: '8px',
|
||||||
|
borderColor: '#e0e0e0',
|
||||||
|
color: '#666',
|
||||||
|
'&:hover': {
|
||||||
|
borderColor: '#ccc',
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.04)'
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
interface StatusFilterTabsProps {
|
||||||
|
/**
|
||||||
|
* Array of status options to display as filter tabs
|
||||||
|
*/
|
||||||
|
statusOptions: string[]
|
||||||
|
/**
|
||||||
|
* Currently selected status filter
|
||||||
|
*/
|
||||||
|
selectedStatus: string
|
||||||
|
/**
|
||||||
|
* Callback function when a status is selected
|
||||||
|
*/
|
||||||
|
onStatusChange: (status: string) => void
|
||||||
|
/**
|
||||||
|
* Custom className for the container
|
||||||
|
*/
|
||||||
|
className?: string
|
||||||
|
/**
|
||||||
|
* Custom styles for the container
|
||||||
|
*/
|
||||||
|
containerStyle?: React.CSSProperties
|
||||||
|
/**
|
||||||
|
* Size of the buttons
|
||||||
|
*/
|
||||||
|
buttonSize?: 'small' | 'medium' | 'large'
|
||||||
|
/**
|
||||||
|
* Maximum number of status options to show as buttons before switching to dropdown
|
||||||
|
*/
|
||||||
|
maxButtonsBeforeDropdown?: number
|
||||||
|
/**
|
||||||
|
* Label for the dropdown when there are many options
|
||||||
|
*/
|
||||||
|
dropdownLabel?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const StatusFilterTabs: React.FC<StatusFilterTabsProps> = ({
|
||||||
|
statusOptions,
|
||||||
|
selectedStatus,
|
||||||
|
onStatusChange,
|
||||||
|
className = '',
|
||||||
|
containerStyle = {},
|
||||||
|
buttonSize = 'small',
|
||||||
|
maxButtonsBeforeDropdown = 5,
|
||||||
|
dropdownLabel = 'Lainnya'
|
||||||
|
}) => {
|
||||||
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null)
|
||||||
|
const open = Boolean(anchorEl)
|
||||||
|
|
||||||
|
const handleDropdownClick = (event: React.MouseEvent<HTMLElement>) => {
|
||||||
|
setAnchorEl(event.currentTarget)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDropdownClose = () => {
|
||||||
|
setAnchorEl(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDropdownItemClick = (status: string) => {
|
||||||
|
onStatusChange(status)
|
||||||
|
handleDropdownClose()
|
||||||
|
}
|
||||||
|
|
||||||
|
// If status options are <= maxButtonsBeforeDropdown, show all as buttons
|
||||||
|
if (statusOptions.length <= maxButtonsBeforeDropdown) {
|
||||||
|
return (
|
||||||
|
<div className='flex flex-wrap gap-2'>
|
||||||
|
{statusOptions.map(status => (
|
||||||
|
<Button
|
||||||
|
key={status}
|
||||||
|
variant={selectedStatus === status ? 'contained' : 'outlined'}
|
||||||
|
color={selectedStatus === status ? 'primary' : 'inherit'}
|
||||||
|
onClick={() => onStatusChange(status)}
|
||||||
|
size={buttonSize}
|
||||||
|
className='rounded-lg'
|
||||||
|
sx={{
|
||||||
|
textTransform: 'none',
|
||||||
|
fontWeight: selectedStatus === status ? 600 : 400,
|
||||||
|
borderRadius: '8px',
|
||||||
|
...(selectedStatus !== status && {
|
||||||
|
borderColor: '#e0e0e0',
|
||||||
|
color: '#666'
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{toTitleCase(status)}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If more than maxButtonsBeforeDropdown, show first few as buttons and rest in dropdown
|
||||||
|
const buttonStatuses = statusOptions.slice(0, maxButtonsBeforeDropdown - 1)
|
||||||
|
const dropdownStatuses = statusOptions.slice(maxButtonsBeforeDropdown - 1)
|
||||||
|
const isDropdownItemSelected = dropdownStatuses.includes(selectedStatus)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='flex flex-wrap gap-2'>
|
||||||
|
{/* Regular buttons for first few statuses */}
|
||||||
|
{buttonStatuses.map(status => (
|
||||||
|
<Button
|
||||||
|
key={status}
|
||||||
|
variant={selectedStatus === status ? 'contained' : 'outlined'}
|
||||||
|
color={selectedStatus === status ? 'primary' : 'inherit'}
|
||||||
|
onClick={() => onStatusChange(status)}
|
||||||
|
size={buttonSize}
|
||||||
|
className='rounded-lg'
|
||||||
|
sx={{
|
||||||
|
textTransform: 'none',
|
||||||
|
fontWeight: selectedStatus === status ? 600 : 400,
|
||||||
|
borderRadius: '8px',
|
||||||
|
...(selectedStatus !== status && {
|
||||||
|
borderColor: '#e0e0e0',
|
||||||
|
color: '#666'
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{toTitleCase(status)}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{/* Dropdown button for remaining statuses */}
|
||||||
|
<DropdownButton
|
||||||
|
variant='outlined'
|
||||||
|
onClick={handleDropdownClick}
|
||||||
|
size={buttonSize}
|
||||||
|
endIcon={<i className='tabler-chevron-down' />}
|
||||||
|
sx={{
|
||||||
|
...(isDropdownItemSelected && {
|
||||||
|
backgroundColor: 'primary.main',
|
||||||
|
color: 'primary.contrastText',
|
||||||
|
borderColor: 'primary.main',
|
||||||
|
fontWeight: 600,
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor: 'primary.dark',
|
||||||
|
borderColor: 'primary.dark'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isDropdownItemSelected ? toTitleCase(selectedStatus) : dropdownLabel}
|
||||||
|
</DropdownButton>
|
||||||
|
|
||||||
|
<Menu
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
open={open}
|
||||||
|
onClose={handleDropdownClose}
|
||||||
|
PaperProps={{
|
||||||
|
elevation: 3,
|
||||||
|
sx: {
|
||||||
|
mt: 1,
|
||||||
|
borderRadius: '8px',
|
||||||
|
minWidth: '160px'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
transformOrigin={{ horizontal: 'left', vertical: 'top' }}
|
||||||
|
anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }}
|
||||||
|
>
|
||||||
|
{dropdownStatuses.map(status => (
|
||||||
|
<MenuItem
|
||||||
|
key={status}
|
||||||
|
onClick={() => handleDropdownItemClick(status)}
|
||||||
|
selected={selectedStatus === status}
|
||||||
|
sx={{
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeight: selectedStatus === status ? 600 : 400,
|
||||||
|
color: selectedStatus === status ? 'primary.main' : 'text.primary'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{toTitleCase(status)}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default StatusFilterTabs
|
||||||
|
|
||||||
|
// Example usage:
|
||||||
|
/*
|
||||||
|
import StatusFilterTabs from '@/components/StatusFilterTabs'
|
||||||
|
|
||||||
|
// In your component:
|
||||||
|
const [statusFilter, setStatusFilter] = useState('Semua')
|
||||||
|
|
||||||
|
// For few statuses (will show all as buttons)
|
||||||
|
const expenseStatusOptions = ['Semua', 'Belum Dibayar', 'Dibayar Sebagian', 'Lunas']
|
||||||
|
|
||||||
|
// For many statuses (will show some buttons + dropdown)
|
||||||
|
const manyStatusOptions = [
|
||||||
|
'Semua',
|
||||||
|
'Belum Dibayar',
|
||||||
|
'Dibayar Sebagian',
|
||||||
|
'Lunas',
|
||||||
|
'Void',
|
||||||
|
'Retur',
|
||||||
|
'Jatuh Tempo',
|
||||||
|
'Transaksi Berulang',
|
||||||
|
'Ditangguhkan',
|
||||||
|
'Dibatalkan'
|
||||||
|
]
|
||||||
|
|
||||||
|
<StatusFilterTabs
|
||||||
|
statusOptions={expenseStatusOptions}
|
||||||
|
selectedStatus={statusFilter}
|
||||||
|
onStatusChange={setStatusFilter}
|
||||||
|
/>
|
||||||
|
|
||||||
|
// With many options (will automatically use dropdown)
|
||||||
|
<StatusFilterTabs
|
||||||
|
statusOptions={manyStatusOptions}
|
||||||
|
selectedStatus={statusFilter}
|
||||||
|
onStatusChange={setStatusFilter}
|
||||||
|
maxButtonsBeforeDropdown={4} // Show 3 buttons + dropdown
|
||||||
|
dropdownLabel="Status Lain"
|
||||||
|
/>
|
||||||
|
|
||||||
|
// Custom configuration
|
||||||
|
<StatusFilterTabs
|
||||||
|
statusOptions={manyStatusOptions}
|
||||||
|
selectedStatus={statusFilter}
|
||||||
|
onStatusChange={setStatusFilter}
|
||||||
|
maxButtonsBeforeDropdown={3}
|
||||||
|
dropdownLabel="Lainnya"
|
||||||
|
buttonSize="medium"
|
||||||
|
showBorder={false}
|
||||||
|
/>
|
||||||
|
*/
|
||||||
@@ -32,7 +32,7 @@ const HorizontalWithSubtitle = (props: UserDataType) => {
|
|||||||
<div className='flex flex-col gap-1 flex-grow'>
|
<div className='flex flex-col gap-1 flex-grow'>
|
||||||
<Typography color='text.primary'>{title}</Typography>
|
<Typography color='text.primary'>{title}</Typography>
|
||||||
<div className='flex items-center gap-2 flex-wrap'>
|
<div className='flex items-center gap-2 flex-wrap'>
|
||||||
<Typography variant='h4'>{stats}</Typography>
|
<Typography variant='h5'>{stats}</Typography>
|
||||||
<Typography color={trend === 'negative' ? 'error.main' : 'success.main'}>
|
<Typography color={trend === 'negative' ? 'error.main' : 'success.main'}>
|
||||||
{`(${trend === 'negative' ? '-' : '+'}${trendNumber})`}
|
{`(${trend === 'negative' ? '-' : '+'}${trendNumber})`}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -43,12 +43,8 @@ const languageData: LanguageDataType[] = [
|
|||||||
langName: 'English'
|
langName: 'English'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
langCode: 'fr',
|
langCode: 'id',
|
||||||
langName: 'French'
|
langName: 'Indonesian'
|
||||||
},
|
|
||||||
{
|
|
||||||
langCode: 'ar',
|
|
||||||
langName: 'Arabic'
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,90 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
|
|||||||
<MenuItem href={`/${locale}/dashboards/daily-report`}>{dictionary['navigation'].dailyReport}</MenuItem>
|
<MenuItem href={`/${locale}/dashboards/daily-report`}>{dictionary['navigation'].dailyReport}</MenuItem>
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
<MenuSection label={dictionary['navigation'].appsPages}>
|
<MenuSection label={dictionary['navigation'].appsPages}>
|
||||||
|
{/* <SubMenu label={dictionary['navigation'].sales} icon={<i className='tabler-receipt-2' />}>
|
||||||
|
<MenuItem href={`/${locale}/apps/sales/overview`}>{dictionary['navigation'].overview}</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/apps/sales/sales-bills`}>{dictionary['navigation'].invoices}</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/apps/sales/sales-deliveries`}>{dictionary['navigation'].deliveries}</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/apps/sales/sales-orders`}>{dictionary['navigation'].sales_orders}</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/apps/sales/sales-quotes`}>{dictionary['navigation'].quotes}</MenuItem>
|
||||||
|
</SubMenu> */}
|
||||||
|
<SubMenu label={dictionary['navigation'].purchase_text} icon={<i className='tabler-shopping-cart' />}>
|
||||||
|
<MenuItem href={`/${locale}/apps/purchase/overview`}>{dictionary['navigation'].overview}</MenuItem>
|
||||||
|
{/* <MenuItem href={`/${locale}/apps/purchase/purchase-bills`}>
|
||||||
|
{dictionary['navigation'].purchase_bills}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/apps/purchase/purchase-deliveries`}>
|
||||||
|
{dictionary['navigation'].purchase_delivery}
|
||||||
|
</MenuItem> */}
|
||||||
|
<MenuItem href={`/${locale}/apps/purchase/purchase-orders`}>
|
||||||
|
{dictionary['navigation'].purchase_orders}
|
||||||
|
</MenuItem>
|
||||||
|
{/* <MenuItem href={`/${locale}/apps/purchase/purchase-quotes`}>
|
||||||
|
{dictionary['navigation'].purchase_quotes}
|
||||||
|
</MenuItem> */}
|
||||||
|
</SubMenu>
|
||||||
|
<MenuItem
|
||||||
|
href={`/${locale}/apps/expense`}
|
||||||
|
icon={<i className='tabler-cash' />}
|
||||||
|
exactMatch={false}
|
||||||
|
activeUrl='/apps/expense'
|
||||||
|
>
|
||||||
|
{dictionary['navigation'].expenses}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
href={`/${locale}/apps/cash-bank`}
|
||||||
|
icon={<i className='tabler-building-bank' />}
|
||||||
|
exactMatch={false}
|
||||||
|
activeUrl='/apps/cash-bank'
|
||||||
|
>
|
||||||
|
{dictionary['navigation'].cash_and_bank}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
href={`/${locale}/apps/account`}
|
||||||
|
icon={<i className='tabler-align-box-left-stretch' />}
|
||||||
|
exactMatch={false}
|
||||||
|
activeUrl='/apps/account'
|
||||||
|
>
|
||||||
|
{dictionary['navigation'].account}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
href={`/${locale}/apps/fixed-assets`}
|
||||||
|
icon={<i className='tabler-apps' />}
|
||||||
|
exactMatch={false}
|
||||||
|
activeUrl='/apps/fixed-assets'
|
||||||
|
>
|
||||||
|
{dictionary['navigation'].fixed_assets}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
href={`/${locale}/apps/report`}
|
||||||
|
icon={<i className='tabler-file-analytics' />}
|
||||||
|
exactMatch={false}
|
||||||
|
activeUrl='/apps/report'
|
||||||
|
>
|
||||||
|
{dictionary['navigation'].reports}
|
||||||
|
</MenuItem>
|
||||||
|
<SubMenu label={dictionary['navigation'].marketing} icon={<i className='tabler-shopping-cart' />}>
|
||||||
|
{/* <MenuItem href={`/${locale}/apps/marketing/loyalty`}>{dictionary['navigation'].loyalty}</MenuItem> */}
|
||||||
|
<MenuItem href={`/${locale}/apps/marketing/reward`}>{dictionary['navigation'].reward}</MenuItem>
|
||||||
|
{/* <SubMenu label={dictionary['navigation'].gamification}>
|
||||||
|
<MenuItem href={`/${locale}/apps/marketing/gamification/wheel-spin`}>
|
||||||
|
{dictionary['navigation'].wheel_spin}
|
||||||
|
</MenuItem>
|
||||||
|
</SubMenu> */}
|
||||||
|
<SubMenu label={dictionary['navigation'].games}>
|
||||||
|
<MenuItem href={`/${locale}/apps/marketing/games/list`}>{dictionary['navigation'].list}</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/apps/marketing/games/game-prizes`}>
|
||||||
|
{dictionary['navigation'].game_prizes}
|
||||||
|
</MenuItem>
|
||||||
|
</SubMenu>
|
||||||
|
<MenuItem href={`/${locale}/apps/marketing/campaign`}>{dictionary['navigation'].campaign}</MenuItem>
|
||||||
|
{/* <MenuItem href={`/${locale}/apps/marketing/customer-analytics`}>
|
||||||
|
{dictionary['navigation'].customer_analytics}
|
||||||
|
</MenuItem> */}
|
||||||
|
{/* <MenuItem href={`/${locale}/apps/marketing/voucher`}>{dictionary['navigation'].voucher}</MenuItem> */}
|
||||||
|
<MenuItem href={`/${locale}/apps/marketing/tier`}>{dictionary['navigation'].tiers_text}</MenuItem>
|
||||||
|
{/* <MenuItem href={`/${locale}/apps/marketing/discount`}>{dictionary['navigation'].discount}</MenuItem> */}
|
||||||
|
</SubMenu>
|
||||||
<SubMenu label={dictionary['navigation'].inventory} icon={<i className='tabler-salad' />}>
|
<SubMenu label={dictionary['navigation'].inventory} icon={<i className='tabler-salad' />}>
|
||||||
<SubMenu label={dictionary['navigation'].products}>
|
<SubMenu label={dictionary['navigation'].products}>
|
||||||
<MenuItem href={`/${locale}/apps/inventory/products/list`}>{dictionary['navigation'].list}</MenuItem>
|
<MenuItem href={`/${locale}/apps/inventory/products/list`}>{dictionary['navigation'].list}</MenuItem>
|
||||||
@@ -120,9 +204,7 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
|
|||||||
</SubMenu>
|
</SubMenu>
|
||||||
<SubMenu label={dictionary['navigation'].stock}>
|
<SubMenu label={dictionary['navigation'].stock}>
|
||||||
<MenuItem href={`/${locale}/apps/inventory/stock/list`}>{dictionary['navigation'].list}</MenuItem>
|
<MenuItem href={`/${locale}/apps/inventory/stock/list`}>{dictionary['navigation'].list}</MenuItem>
|
||||||
<MenuItem href={`/${locale}/apps/inventory/stock/restock`}>
|
<MenuItem href={`/${locale}/apps/inventory/stock/restock`}>{dictionary['navigation'].restock}</MenuItem>
|
||||||
{dictionary['navigation'].restock}
|
|
||||||
</MenuItem>
|
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
{/* <MenuItem href={`/${locale}/apps/inventory/settings`}>{dictionary['navigation'].settings}</MenuItem> */}
|
{/* <MenuItem href={`/${locale}/apps/inventory/settings`}>{dictionary['navigation'].settings}</MenuItem> */}
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
@@ -136,10 +218,25 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
|
|||||||
<MenuItem href={`/${locale}/apps/finance/payment-methods/list`}>{dictionary['navigation'].list}</MenuItem>
|
<MenuItem href={`/${locale}/apps/finance/payment-methods/list`}>{dictionary['navigation'].list}</MenuItem>
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
<SubMenu label={dictionary['navigation'].user} icon={<i className='tabler-user' />}>
|
<MenuItem
|
||||||
<MenuItem href={`/${locale}/apps/user/list`}>{dictionary['navigation'].list}</MenuItem>
|
href={`/${locale}/apps/user/list`}
|
||||||
{/* <MenuItem href={`/${locale}/apps/user/view`}>{dictionary['navigation'].view}</MenuItem> */}
|
icon={<i className='tabler-user' />}
|
||||||
</SubMenu>
|
exactMatch={false}
|
||||||
|
activeUrl='/apps/user/list'
|
||||||
|
>
|
||||||
|
{dictionary['navigation'].user}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
href={`/${locale}/apps/vendor/list`}
|
||||||
|
icon={<i className='tabler-building' />}
|
||||||
|
exactMatch={false}
|
||||||
|
activeUrl='/apps/vendor/list'
|
||||||
|
>
|
||||||
|
{dictionary['navigation'].vendor}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/draw`} icon={<i className='tabler-building' />} target='_blank'>
|
||||||
|
Random Draw
|
||||||
|
</MenuItem>
|
||||||
</MenuSection>
|
</MenuSection>
|
||||||
</Menu>
|
</Menu>
|
||||||
</ScrollWrapper>
|
</ScrollWrapper>
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { Box, Typography, Paper } from '@mui/material'
|
||||||
|
|
||||||
|
// Types
|
||||||
|
type ReportItemHeaderProps = {
|
||||||
|
title: string
|
||||||
|
date?: string
|
||||||
|
amount?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReportItemSubheaderProps = {
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReportItemProps = {
|
||||||
|
accountCode: string
|
||||||
|
accountName: string
|
||||||
|
amount: number
|
||||||
|
onClick?: () => void
|
||||||
|
isSubtitle?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReportItemFooterProps = {
|
||||||
|
title: string
|
||||||
|
amount: number
|
||||||
|
children?: React.ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to format currency
|
||||||
|
const formatCurrency = (amount: number) => {
|
||||||
|
return new Intl.NumberFormat('id-ID', {
|
||||||
|
minimumFractionDigits: 0,
|
||||||
|
maximumFractionDigits: 0
|
||||||
|
}).format(amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReportItemHeader Component
|
||||||
|
export const ReportItemHeader: React.FC<ReportItemHeaderProps> = ({ title, date, amount }) => {
|
||||||
|
return (
|
||||||
|
<Box className='bg-slate-200 px-6 py-4 flex justify-between items-center'>
|
||||||
|
<Typography variant='h6' className='text-primary font-semibold'>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant='body1' className='text-primary font-medium'>
|
||||||
|
{amount ? formatCurrency(amount) : date}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReportItemSubheader Component
|
||||||
|
export const ReportItemSubheader: React.FC<ReportItemSubheaderProps> = ({ title }) => {
|
||||||
|
return (
|
||||||
|
<Box className='px-6 py-3 bg-white border-b border-gray-300 hover:bg-gray-50 transition-colors'>
|
||||||
|
<Typography variant='subtitle1' className='font-semibold text-gray-900'>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReportItem Component
|
||||||
|
export const ReportItem: React.FC<ReportItemProps> = ({
|
||||||
|
accountCode,
|
||||||
|
accountName,
|
||||||
|
amount,
|
||||||
|
onClick,
|
||||||
|
isSubtitle = true
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
onClick={onClick}
|
||||||
|
className={`px-6 py-3 flex justify-between items-center bg-white border-b border-gray-300 transition-all duration-200 ease-in-out ${
|
||||||
|
onClick ? 'cursor-pointer hover:bg-gray-50' : 'cursor-default'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<Typography variant='body1' className={`text-gray-900 font-normal ${isSubtitle ? 'ml-4' : ''}`}>
|
||||||
|
{accountCode} {accountName}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant='body1' className='text-primary font-medium text-right'>
|
||||||
|
{formatCurrency(amount)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReportItemFooter Component
|
||||||
|
export const ReportItemFooter: React.FC<ReportItemFooterProps> = ({ title, amount, children }) => {
|
||||||
|
return (
|
||||||
|
<Box className='px-6 py-4 border-b border-gray-300 hover:bg-gray-50 transition-colors'>
|
||||||
|
<Box className='flex justify-between items-center'>
|
||||||
|
<Typography variant='subtitle1' className='font-bold text-gray-900'>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant='subtitle1' className='text-primary font-bold text-right'>
|
||||||
|
{formatCurrency(amount)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
{children && <Box className='mt-2'>{children}</Box>}
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
// MUI Imports
|
||||||
|
import Button from '@mui/material/Button'
|
||||||
|
import Typography from '@mui/material/Typography'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReportTitle = ({ title }: Props) => {
|
||||||
|
return (
|
||||||
|
<div className='flex flex-wrap sm:items-center justify-between max-sm:flex-col gap-6'>
|
||||||
|
<div>
|
||||||
|
<Typography variant='h4' className='mbe-1'>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ReportTitle
|
||||||
+2
-1
@@ -1,9 +1,10 @@
|
|||||||
export const i18n = {
|
export const i18n = {
|
||||||
defaultLocale: 'en',
|
defaultLocale: 'en',
|
||||||
locales: ['en', 'fr', 'ar'],
|
locales: ['en', 'id'],
|
||||||
langDirection: {
|
langDirection: {
|
||||||
en: 'ltr',
|
en: 'ltr',
|
||||||
fr: 'ltr',
|
fr: 'ltr',
|
||||||
|
id: 'ltr',
|
||||||
ar: 'rtl'
|
ar: 'rtl'
|
||||||
}
|
}
|
||||||
} as const
|
} as const
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
{
|
|
||||||
"navigation": {
|
|
||||||
"dashboards": "لوحات القيادة",
|
|
||||||
"analytics": "تحليلات",
|
|
||||||
"inventory": "تجزئة الكترونية",
|
|
||||||
"stock": "المخزون",
|
|
||||||
"academy": "أكاديمية",
|
|
||||||
"logistics": "اللوجستية",
|
|
||||||
"frontPages": "الصفحات الأولى",
|
|
||||||
"landing": "الهبوط",
|
|
||||||
"pricing": "التسعير",
|
|
||||||
"payment": "قسط",
|
|
||||||
"checkout": "الدفع",
|
|
||||||
"helpCenter": "مركز المساعدة",
|
|
||||||
"appsPages": "التطبيقات والصفحات",
|
|
||||||
"apps": "تطبيقات",
|
|
||||||
"dashboard": "لوحة القيادة",
|
|
||||||
"products": "منتجات",
|
|
||||||
"list": "قائمة",
|
|
||||||
"add": "يضيف",
|
|
||||||
"restock": "استرجاع",
|
|
||||||
"category": "فئة",
|
|
||||||
"overview": "نظرة عامة",
|
|
||||||
"profitloss": "الربح والخسارة",
|
|
||||||
"finance": "مالية",
|
|
||||||
"paymentMethods": "طرق الدفع",
|
|
||||||
"organization": "المنظمة",
|
|
||||||
"outlet": "مخزن",
|
|
||||||
"units": "وحدات",
|
|
||||||
"reports": "تقارير",
|
|
||||||
"ingredients": "مكونات",
|
|
||||||
"orders": "أوامر",
|
|
||||||
"details": "تفاصيل",
|
|
||||||
"customers": "العملاء",
|
|
||||||
"manageReviews": "إدارة المراجعات",
|
|
||||||
"referrals": "الإحالات",
|
|
||||||
"settings": "إعدادات",
|
|
||||||
"myCourses": "دوراتي",
|
|
||||||
"courseDetails": "تفاصيل الدورة",
|
|
||||||
"fleet": "أسطول",
|
|
||||||
"email": "البريد الإلكتروني",
|
|
||||||
"chat": "محادثة",
|
|
||||||
"calendar": "تقويم",
|
|
||||||
"kanban": "كانبان",
|
|
||||||
"invoice": "فاتورة",
|
|
||||||
"preview": "معاينة",
|
|
||||||
"edit": "يحرر",
|
|
||||||
"user": "المستعمل",
|
|
||||||
"view": "رأي",
|
|
||||||
"rolesPermissions": "الأدوار والأذونات",
|
|
||||||
"roles": "الأدوار",
|
|
||||||
"permissions": "أذونات",
|
|
||||||
"pages": "الصفحات",
|
|
||||||
"userProfile": "ملف تعريفي للمستخدم",
|
|
||||||
"accountSettings": "إعدادت الحساب",
|
|
||||||
"faq": "التعليمات",
|
|
||||||
"miscellaneous": "متفرقات",
|
|
||||||
"comingSoon": "قريبا",
|
|
||||||
"underMaintenance": "تحت الصيانة",
|
|
||||||
"pageNotFound404": "الصفحة غير موجودة - 404",
|
|
||||||
"notAuthorized401": "غير مصرح به - 401",
|
|
||||||
"authPages": "صفحات المصادقة",
|
|
||||||
"login": "تسجيل الدخول",
|
|
||||||
"loginV1": "تسجيل الدخول v1",
|
|
||||||
"loginV2": "تسجيل الدخول الإصدار 2",
|
|
||||||
"register": "يسجل",
|
|
||||||
"registerV1": "تسجيل الإصدار 1",
|
|
||||||
"registerV2": "تسجيل الإصدار 2",
|
|
||||||
"registerMultiSteps": "تسجيل متعدد الخطوات",
|
|
||||||
"verifyEmail": "التحقق من البريد الإلكتروني",
|
|
||||||
"verifyEmailV1": "التحقق من البريد الإلكتروني الإصدار 1",
|
|
||||||
"verifyEmailV2": "التحقق من البريد الإلكتروني الإصدار 2",
|
|
||||||
"forgotPassword": "هل نسيت كلمة السر",
|
|
||||||
"forgotPasswordV1": "نسيت كلمة المرور v1",
|
|
||||||
"forgotPasswordV2": "نسيت كلمة المرور v2",
|
|
||||||
"resetPassword": "إعادة تعيين كلمة المرور",
|
|
||||||
"resetPasswordV1": "إعادة تعيين كلمة المرور v1",
|
|
||||||
"resetPasswordV2": "إعادة تعيين كلمة المرور الإصدار 2",
|
|
||||||
"twoSteps": "خطوتين",
|
|
||||||
"twoStepsV1": "خطوتين v1",
|
|
||||||
"twoStepsV2": "خطوتان - الإصدار 2",
|
|
||||||
"wizardExamples": "أمثلة على المعالج",
|
|
||||||
"propertyListing": "قائمة الممتلكات",
|
|
||||||
"createDeal": "إنشاء صفقة",
|
|
||||||
"dialogExamples": "أمثلة الحوار",
|
|
||||||
"widgetExamples": "أمثلة القطعة",
|
|
||||||
"basic": "أساسي",
|
|
||||||
"advanced": "متقدم",
|
|
||||||
"statistics": "إحصائيات",
|
|
||||||
"actions": "أجراءات",
|
|
||||||
"formsAndTables": "النماذج والجداول",
|
|
||||||
"formLayouts": "تخطيطات النموذج",
|
|
||||||
"formValidation": "التحقق من صحة النموذج",
|
|
||||||
"formWizard": "معالج النماذج",
|
|
||||||
"reactTable": "جدول رد الفعل",
|
|
||||||
"formELements": "عناصر النماذج",
|
|
||||||
"muiTables": "جداول MUI",
|
|
||||||
"chartsMisc": "الرسوم البيانية ومتفرقات",
|
|
||||||
"charts": "الرسوم البيانية",
|
|
||||||
"recharts": "يعيد رسم الخرائط",
|
|
||||||
"apex": "ذروة",
|
|
||||||
"foundation": "مؤسسة",
|
|
||||||
"components": "عناصر",
|
|
||||||
"menuExamples": "أمثلة القائمة",
|
|
||||||
"raiseSupport": "رفع الدعم",
|
|
||||||
"documentation": "توثيق",
|
|
||||||
"others": "آحرون",
|
|
||||||
"itemWithBadge": "العنصر مع شارة",
|
|
||||||
"externalLink": "رابط خارجي",
|
|
||||||
"menuLevels": "مستويات القائمة",
|
|
||||||
"menuLevel2": "مستوى القائمة 2",
|
|
||||||
"menuLevel3": "مستوى القائمة 3",
|
|
||||||
"disabledMenu": "قائمة المعوقين",
|
|
||||||
"dailyReport": "تقرير يومي"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -111,6 +111,33 @@
|
|||||||
"menuLevel2": "Menu Level 2",
|
"menuLevel2": "Menu Level 2",
|
||||||
"menuLevel3": "Menu Level 3",
|
"menuLevel3": "Menu Level 3",
|
||||||
"disabledMenu": "Disabled Menu",
|
"disabledMenu": "Disabled Menu",
|
||||||
"dailyReport": "Daily Report"
|
"dailyReport": "Daily Report",
|
||||||
|
"vendor": "Vendor",
|
||||||
|
"sales": "Sales",
|
||||||
|
"purchase_text": "Purchase",
|
||||||
|
"purchase_orders": "Purchase Orders",
|
||||||
|
"purchase_bills": "Purchase Bills",
|
||||||
|
"purchase_delivery": "Purchase Delivery",
|
||||||
|
"purchase_quotes": "Purchase Quotes",
|
||||||
|
"invoices": "Invoices",
|
||||||
|
"deliveries": "Deliveries",
|
||||||
|
"sales_orders": "Orders",
|
||||||
|
"quotes": "Quotes",
|
||||||
|
"expenses": "Expenses",
|
||||||
|
"cash_and_bank": "Cash & Bank",
|
||||||
|
"account": "Account",
|
||||||
|
"fixed_assets": "Fixed Assets",
|
||||||
|
"marketing": "Marketing",
|
||||||
|
"loyalty": "Loyalty",
|
||||||
|
"reward": "Reward",
|
||||||
|
"gamification": "Gamification",
|
||||||
|
"wheel_spin": "Wheel Spin",
|
||||||
|
"campaign": "Campaign",
|
||||||
|
"customer_analytics": "Customer Analytics",
|
||||||
|
"voucher": "Voucher",
|
||||||
|
"tiers_text": "Tiers",
|
||||||
|
"games": "Games",
|
||||||
|
"game_prizes": "Game Prizes",
|
||||||
|
"discount": "Discount"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
{
|
|
||||||
"navigation": {
|
|
||||||
"dashboards": "Tableaux de bord",
|
|
||||||
"analytics": "Analytique",
|
|
||||||
"inventory": "Inventaire",
|
|
||||||
"stock": "Stock",
|
|
||||||
"academy": "Académie",
|
|
||||||
"logistics": "Logistique",
|
|
||||||
"frontPages": "Premières pages",
|
|
||||||
"landing": "Atterrissage",
|
|
||||||
"pricing": "Tarifs",
|
|
||||||
"payment": "Paiement",
|
|
||||||
"checkout": "Vérifier",
|
|
||||||
"helpCenter": "Centre d'aide",
|
|
||||||
"appsPages": "Applications et pages",
|
|
||||||
"apps": "Apps",
|
|
||||||
"dashboard": "Tableau de bord",
|
|
||||||
"products": "Produits",
|
|
||||||
"list": "Liste",
|
|
||||||
"add": "Ajouter",
|
|
||||||
"restock": "Rapprocher",
|
|
||||||
"category": "Catégorie",
|
|
||||||
"overview": "Aperçu",
|
|
||||||
"profitloss": "Profit et perte",
|
|
||||||
"finance": "Finance",
|
|
||||||
"paymentMethods": "Méthodes de paiement",
|
|
||||||
"organization": "Organisation",
|
|
||||||
"outlet": "Point de vente",
|
|
||||||
"units": "Unites",
|
|
||||||
"reports": "Rapports",
|
|
||||||
"ingredients": "Ingrédients",
|
|
||||||
"orders": "Ordres",
|
|
||||||
"details": "Détails",
|
|
||||||
"customers": "Clientes",
|
|
||||||
"manageReviews": "Gérer les avis",
|
|
||||||
"referrals": "Références",
|
|
||||||
"settings": "Paramètres",
|
|
||||||
"myCourses": "Mes cours",
|
|
||||||
"courseDetails": "Détails du cours",
|
|
||||||
"fleet": "Flotte",
|
|
||||||
"email": "E-mail",
|
|
||||||
"chat": "chatte",
|
|
||||||
"calendar": "Calendrier",
|
|
||||||
"kanban": "Kanban",
|
|
||||||
"invoice": "Facture d'achat",
|
|
||||||
"preview": "Aperçu",
|
|
||||||
"edit": "Éditer",
|
|
||||||
"user": "Utilisateur",
|
|
||||||
"view": "Voir",
|
|
||||||
"rolesPermissions": "Rôles et autorisations",
|
|
||||||
"roles": "Les rôles",
|
|
||||||
"permissions": "Autorisations",
|
|
||||||
"pages": "Pages",
|
|
||||||
"userProfile": "Profil de l'utilisateur",
|
|
||||||
"accountSettings": "Paramètres du compte",
|
|
||||||
"faq": "FAQ",
|
|
||||||
"miscellaneous": "Divers",
|
|
||||||
"comingSoon": "À venir",
|
|
||||||
"underMaintenance": "En maintenance",
|
|
||||||
"pageNotFound404": "Page non trouvée - 404",
|
|
||||||
"notAuthorized401": "Non autorisé - 401",
|
|
||||||
"authPages": "Pages d'authentification",
|
|
||||||
"login": "Connexion",
|
|
||||||
"loginV1": "Connexion v1",
|
|
||||||
"loginV2": "Connexion v2",
|
|
||||||
"register": "S'inscrire",
|
|
||||||
"registerV1": "Enregistrer v1",
|
|
||||||
"registerV2": "Enregistrer v2",
|
|
||||||
"registerMultiSteps": "Enregistrer plusieurs étapes",
|
|
||||||
"verifyEmail": "Vérifier les courriels",
|
|
||||||
"verifyEmailV1": "Vérifier l'e-mail v1",
|
|
||||||
"verifyEmailV2": "Vérifier l'e-mail v2",
|
|
||||||
"forgotPassword": "Mot de passe oublié",
|
|
||||||
"forgotPasswordV1": "Mot de passe oublié v1",
|
|
||||||
"forgotPasswordV2": "Mot de passe oublié v2",
|
|
||||||
"resetPassword": "Réinitialiser le mot de passe",
|
|
||||||
"resetPasswordV1": "Réinitialiser le mot de passe v1",
|
|
||||||
"resetPasswordV2": "Réinitialiser le mot de passe v2",
|
|
||||||
"twoSteps": "Deux étapes",
|
|
||||||
"twoStepsV1": "Deux étapes v1",
|
|
||||||
"twoStepsV2": "Deux étapes v2",
|
|
||||||
"wizardExamples": "Exemples d'assistants",
|
|
||||||
"propertyListing": "Liste des biens",
|
|
||||||
"createDeal": "Créer un accord",
|
|
||||||
"dialogExamples": "Exemples de dialogue",
|
|
||||||
"widgetExamples": "Exemples de widgets",
|
|
||||||
"basic": "Basique",
|
|
||||||
"advanced": "Avancée",
|
|
||||||
"statistics": "Statistiques",
|
|
||||||
"actions": "Actions",
|
|
||||||
"formsAndTables": "Formulaires et tableaux",
|
|
||||||
"formLayouts": "Dispositions de formulaire",
|
|
||||||
"formValidation": "Validation du formulaire",
|
|
||||||
"formWizard": "Assistant de formulaire",
|
|
||||||
"reactTable": "Tableau de réaction",
|
|
||||||
"formELements": "Éléments de formulaire",
|
|
||||||
"muiTables": "Tableaux MUI",
|
|
||||||
"chartsMisc": "Graphiques & Divers",
|
|
||||||
"charts": "Graphiques",
|
|
||||||
"recharts": "Regraphiques",
|
|
||||||
"apex": "Sommet",
|
|
||||||
"foundation": "fondation",
|
|
||||||
"components": "Composants",
|
|
||||||
"menuExamples": "Exemples de menus",
|
|
||||||
"raiseSupport": "Augmenter le soutien",
|
|
||||||
"documentation": "Documentation",
|
|
||||||
"others": "Les autres",
|
|
||||||
"itemWithBadge": "Article avec badge",
|
|
||||||
"externalLink": "Lien Externe",
|
|
||||||
"menuLevels": "Niveaux de menus",
|
|
||||||
"menuLevel2": "Niveau menu 2",
|
|
||||||
"menuLevel3": "Niveau menu 3",
|
|
||||||
"disabledMenu": "Menu désactivé",
|
|
||||||
"dailyReport": "Rapport quotidien"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
{
|
||||||
|
"navigation": {
|
||||||
|
"dashboards": "Dasbor",
|
||||||
|
"analytics": "Analitik",
|
||||||
|
"inventory": "Inventaris",
|
||||||
|
"stock": "Stok",
|
||||||
|
"academy": "Akademi",
|
||||||
|
"logistics": "Logistik",
|
||||||
|
"frontPages": "Halaman Depan",
|
||||||
|
"landing": "Beranda",
|
||||||
|
"pricing": "Harga",
|
||||||
|
"payment": "Pembayaran",
|
||||||
|
"checkout": "Checkout",
|
||||||
|
"helpCenter": "Pusat Bantuan",
|
||||||
|
"appsPages": "Aplikasi & Halaman",
|
||||||
|
"apps": "Aplikasi",
|
||||||
|
"dashboard": "Dasbor",
|
||||||
|
"products": "Produk",
|
||||||
|
"list": "Daftar",
|
||||||
|
"add": "Tambah",
|
||||||
|
"restock": "Isi Ulang Stok",
|
||||||
|
"category": "Kategori",
|
||||||
|
"overview": "Ringkasan",
|
||||||
|
"profitloss": "Laba Rugi",
|
||||||
|
"units": "Unit",
|
||||||
|
"reports": "Laporan",
|
||||||
|
"finance": "Keuangan",
|
||||||
|
"paymentMethods": "Metode Pembayaran",
|
||||||
|
"organization": "Organisasi",
|
||||||
|
"outlet": "Outlet",
|
||||||
|
"ingredients": "Bahan",
|
||||||
|
"orders": "Pesanan",
|
||||||
|
"details": "Detail",
|
||||||
|
"customers": "Pelanggan",
|
||||||
|
"manageReviews": "Kelola Ulasan",
|
||||||
|
"referrals": "Rujukan",
|
||||||
|
"settings": "Pengaturan",
|
||||||
|
"myCourses": "Kursus Saya",
|
||||||
|
"courseDetails": "Detail Kursus",
|
||||||
|
"fleet": "Armada",
|
||||||
|
"email": "Email",
|
||||||
|
"chat": "Chat",
|
||||||
|
"calendar": "Kalender",
|
||||||
|
"kanban": "Kanban",
|
||||||
|
"invoice": "Faktur",
|
||||||
|
"preview": "Pratinjau",
|
||||||
|
"edit": "Edit",
|
||||||
|
"user": "Pengguna",
|
||||||
|
"view": "Lihat",
|
||||||
|
"rolesPermissions": "Peran & Izin",
|
||||||
|
"roles": "Peran",
|
||||||
|
"permissions": "Izin",
|
||||||
|
"pages": "Halaman",
|
||||||
|
"userProfile": "Profil Pengguna",
|
||||||
|
"accountSettings": "Pengaturan Akun",
|
||||||
|
"faq": "FAQ",
|
||||||
|
"miscellaneous": "Lain-lain",
|
||||||
|
"comingSoon": "Segera Hadir",
|
||||||
|
"underMaintenance": "Dalam Pemeliharaan",
|
||||||
|
"pageNotFound404": "Halaman Tidak Ditemukan - 404",
|
||||||
|
"notAuthorized401": "Tidak Diizinkan - 401",
|
||||||
|
"authPages": "Halaman Autentikasi",
|
||||||
|
"login": "Masuk",
|
||||||
|
"loginV1": "Masuk v1",
|
||||||
|
"loginV2": "Masuk v2",
|
||||||
|
"register": "Daftar",
|
||||||
|
"registerV1": "Daftar v1",
|
||||||
|
"registerV2": "Daftar v2",
|
||||||
|
"registerMultiSteps": "Daftar Multi-Langkah",
|
||||||
|
"verifyEmail": "Verifikasi Email",
|
||||||
|
"verifyEmailV1": "Verifikasi Email v1",
|
||||||
|
"verifyEmailV2": "Verifikasi Email v2",
|
||||||
|
"forgotPassword": "Lupa Kata Sandi",
|
||||||
|
"forgotPasswordV1": "Lupa Kata Sandi v1",
|
||||||
|
"forgotPasswordV2": "Lupa Kata Sandi v2",
|
||||||
|
"resetPassword": "Reset Kata Sandi",
|
||||||
|
"resetPasswordV1": "Reset Kata Sandi v1",
|
||||||
|
"resetPasswordV2": "Reset Kata Sandi v2",
|
||||||
|
"twoSteps": "Dua Langkah",
|
||||||
|
"twoStepsV1": "Dua Langkah v1",
|
||||||
|
"twoStepsV2": "Dua Langkah v2",
|
||||||
|
"wizardExamples": "Contoh Wizard",
|
||||||
|
"propertyListing": "Daftar Properti",
|
||||||
|
"createDeal": "Buat Penawaran",
|
||||||
|
"dialogExamples": "Contoh Dialog",
|
||||||
|
"widgetExamples": "Contoh Widget",
|
||||||
|
"basic": "Dasar",
|
||||||
|
"advanced": "Lanjutan",
|
||||||
|
"statistics": "Statistik",
|
||||||
|
"actions": "Aksi",
|
||||||
|
"formsAndTables": "Form & Tabel",
|
||||||
|
"formLayouts": "Layout Form",
|
||||||
|
"formValidation": "Validasi Form",
|
||||||
|
"formWizard": "Wizard Form",
|
||||||
|
"reactTable": "Tabel React",
|
||||||
|
"formELements": "Elemen Form",
|
||||||
|
"muiTables": "Tabel MUI",
|
||||||
|
"chartsMisc": "Grafik & Lain-lain",
|
||||||
|
"charts": "Grafik",
|
||||||
|
"recharts": "Recharts",
|
||||||
|
"apex": "Apex",
|
||||||
|
"foundation": "Fondasi",
|
||||||
|
"components": "Komponen",
|
||||||
|
"menuExamples": "Contoh Menu",
|
||||||
|
"raiseSupport": "Buat Tiket Dukungan",
|
||||||
|
"documentation": "Dokumentasi",
|
||||||
|
"others": "Lainnya",
|
||||||
|
"itemWithBadge": "Item dengan Badge",
|
||||||
|
"externalLink": "Link Eksternal",
|
||||||
|
"menuLevels": "Level Menu",
|
||||||
|
"menuLevel2": "Level Menu 2",
|
||||||
|
"menuLevel3": "Level Menu 3",
|
||||||
|
"disabledMenu": "Menu Nonaktif",
|
||||||
|
"dailyReport": "Laporan Harian",
|
||||||
|
"vendor": "Vendor",
|
||||||
|
"sales": "Penjualan",
|
||||||
|
"purchase_text": "Pembelian",
|
||||||
|
"purchase_orders": "Pesanan Pembelian",
|
||||||
|
"purchase_bills": "Tagihan Pembelian",
|
||||||
|
"purchase_delivery": "Pengiriman Pembelian",
|
||||||
|
"purchase_quotes": "Penawaran Pembelian",
|
||||||
|
"invoices": "Tagihan",
|
||||||
|
"deliveries": "Pengiriman",
|
||||||
|
"sales_orders": "Pemesanan",
|
||||||
|
"quotes": "Penawaran",
|
||||||
|
"expenses": "Biaya",
|
||||||
|
"cash_and_bank": "Kas & Bank",
|
||||||
|
"account": "Akun",
|
||||||
|
"fixed_assets": "Aset Tetap",
|
||||||
|
"marketing": "Pemasaran",
|
||||||
|
"loyalty": "Loyalti",
|
||||||
|
"reward": "Reward",
|
||||||
|
"gamification": "Gamifikasi",
|
||||||
|
"wheel_spin": "Wheel Spin",
|
||||||
|
"campaign": "Kampanye",
|
||||||
|
"customer_analytics": "Analisis Pelanggan",
|
||||||
|
"voucher": "Vocher",
|
||||||
|
"tiers_text": "Tiers",
|
||||||
|
"games": "Permainan",
|
||||||
|
"game_prizes": "Hadiah Permainan",
|
||||||
|
"Discount": "Diskon"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
import { ExpenseType } from '@/types/apps/expenseTypes'
|
||||||
|
|
||||||
|
export const expenseData: ExpenseType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
date: '2025-01-05',
|
||||||
|
number: 'EXP/2025/001',
|
||||||
|
reference: 'REF-EXP-001',
|
||||||
|
benefeciaryName: 'Budi Santoso',
|
||||||
|
benefeciaryCompany: 'PT Maju Jaya',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
balanceDue: 5000000,
|
||||||
|
total: 5000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
date: '2025-01-06',
|
||||||
|
number: 'EXP/2025/002',
|
||||||
|
reference: 'REF-EXP-002',
|
||||||
|
benefeciaryName: 'Siti Aminah',
|
||||||
|
benefeciaryCompany: 'CV Sentosa Abadi',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
balanceDue: 2500000,
|
||||||
|
total: 6000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
date: '2025-01-07',
|
||||||
|
number: 'EXP/2025/003',
|
||||||
|
reference: 'REF-EXP-003',
|
||||||
|
benefeciaryName: 'Agus Prasetyo',
|
||||||
|
benefeciaryCompany: 'UD Makmur',
|
||||||
|
status: 'Lunas',
|
||||||
|
balanceDue: 0,
|
||||||
|
total: 4200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
date: '2025-01-08',
|
||||||
|
number: 'EXP/2025/004',
|
||||||
|
reference: 'REF-EXP-004',
|
||||||
|
benefeciaryName: 'Rina Wulandari',
|
||||||
|
benefeciaryCompany: 'PT Sejahtera Bersama',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
balanceDue: 3200000,
|
||||||
|
total: 3200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
date: '2025-01-09',
|
||||||
|
number: 'EXP/2025/005',
|
||||||
|
reference: 'REF-EXP-005',
|
||||||
|
benefeciaryName: 'Dedi Kurniawan',
|
||||||
|
benefeciaryCompany: 'CV Bintang Terang',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
balanceDue: 1500000,
|
||||||
|
total: 7000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
date: '2025-01-10',
|
||||||
|
number: 'EXP/2025/006',
|
||||||
|
reference: 'REF-EXP-006',
|
||||||
|
benefeciaryName: 'Sri Lestari',
|
||||||
|
benefeciaryCompany: 'PT Barokah Jaya',
|
||||||
|
status: 'Lunas',
|
||||||
|
balanceDue: 0,
|
||||||
|
total: 2800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
date: '2025-01-11',
|
||||||
|
number: 'EXP/2025/007',
|
||||||
|
reference: 'REF-EXP-007',
|
||||||
|
benefeciaryName: 'Joko Widodo',
|
||||||
|
benefeciaryCompany: 'UD Sumber Rejeki',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
balanceDue: 8000000,
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
date: '2025-01-12',
|
||||||
|
number: 'EXP/2025/008',
|
||||||
|
reference: 'REF-EXP-008',
|
||||||
|
benefeciaryName: 'Maya Kartika',
|
||||||
|
benefeciaryCompany: 'PT Bumi Lestari',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
balanceDue: 2000000,
|
||||||
|
total: 9000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
date: '2025-01-13',
|
||||||
|
number: 'EXP/2025/009',
|
||||||
|
reference: 'REF-EXP-009',
|
||||||
|
benefeciaryName: 'Eko Yulianto',
|
||||||
|
benefeciaryCompany: 'CV Cahaya Baru',
|
||||||
|
status: 'Lunas',
|
||||||
|
balanceDue: 0,
|
||||||
|
total: 3500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
date: '2025-01-14',
|
||||||
|
number: 'EXP/2025/010',
|
||||||
|
reference: 'REF-EXP-010',
|
||||||
|
benefeciaryName: 'Nina Rahmawati',
|
||||||
|
benefeciaryCompany: 'PT Gemilang',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
balanceDue: 4700000,
|
||||||
|
total: 4700000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
date: '2025-01-15',
|
||||||
|
number: 'EXP/2025/011',
|
||||||
|
reference: 'REF-EXP-011',
|
||||||
|
benefeciaryName: 'Andi Saputra',
|
||||||
|
benefeciaryCompany: 'CV Harmoni',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
balanceDue: 1200000,
|
||||||
|
total: 6000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
date: '2025-01-16',
|
||||||
|
number: 'EXP/2025/012',
|
||||||
|
reference: 'REF-EXP-012',
|
||||||
|
benefeciaryName: 'Yuni Astuti',
|
||||||
|
benefeciaryCompany: 'PT Surya Abadi',
|
||||||
|
status: 'Lunas',
|
||||||
|
balanceDue: 0,
|
||||||
|
total: 5200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
date: '2025-01-17',
|
||||||
|
number: 'EXP/2025/013',
|
||||||
|
reference: 'REF-EXP-013',
|
||||||
|
benefeciaryName: 'Ridwan Hidayat',
|
||||||
|
benefeciaryCompany: 'UD Berkah',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
balanceDue: 2900000,
|
||||||
|
total: 2900000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
date: '2025-01-18',
|
||||||
|
number: 'EXP/2025/014',
|
||||||
|
reference: 'REF-EXP-014',
|
||||||
|
benefeciaryName: 'Ratna Sari',
|
||||||
|
benefeciaryCompany: 'PT Amanah Sentosa',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
balanceDue: 1000000,
|
||||||
|
total: 4000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
date: '2025-01-19',
|
||||||
|
number: 'EXP/2025/015',
|
||||||
|
reference: 'REF-EXP-015',
|
||||||
|
benefeciaryName: 'Hendra Gunawan',
|
||||||
|
benefeciaryCompany: 'CV Murni',
|
||||||
|
status: 'Lunas',
|
||||||
|
balanceDue: 0,
|
||||||
|
total: 2500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
date: '2025-01-20',
|
||||||
|
number: 'EXP/2025/016',
|
||||||
|
reference: 'REF-EXP-016',
|
||||||
|
benefeciaryName: 'Mega Putri',
|
||||||
|
benefeciaryCompany: 'PT Citra Mandiri',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
balanceDue: 6100000,
|
||||||
|
total: 6100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
date: '2025-01-21',
|
||||||
|
number: 'EXP/2025/017',
|
||||||
|
reference: 'REF-EXP-017',
|
||||||
|
benefeciaryName: 'Bayu Saputra',
|
||||||
|
benefeciaryCompany: 'UD Lancar Jaya',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
balanceDue: 1700000,
|
||||||
|
total: 5000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
date: '2025-01-22',
|
||||||
|
number: 'EXP/2025/018',
|
||||||
|
reference: 'REF-EXP-018',
|
||||||
|
benefeciaryName: 'Dian Anggraini',
|
||||||
|
benefeciaryCompany: 'CV Sumber Cahaya',
|
||||||
|
status: 'Lunas',
|
||||||
|
balanceDue: 0,
|
||||||
|
total: 3300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
date: '2025-01-23',
|
||||||
|
number: 'EXP/2025/019',
|
||||||
|
reference: 'REF-EXP-019',
|
||||||
|
benefeciaryName: 'Rizky Aditya',
|
||||||
|
benefeciaryCompany: 'PT Mandiri Abadi',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
balanceDue: 7000000,
|
||||||
|
total: 7000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
date: '2025-01-24',
|
||||||
|
number: 'EXP/2025/020',
|
||||||
|
reference: 'REF-EXP-020',
|
||||||
|
benefeciaryName: 'Lina Marlina',
|
||||||
|
benefeciaryCompany: 'CV Anugerah',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
balanceDue: 2000000,
|
||||||
|
total: 6500000
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,244 @@
|
|||||||
|
import { PurchaseBillType } from '@/types/apps/purchaseBillType'
|
||||||
|
|
||||||
|
export const purchaseBillsData: PurchaseBillType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'PB-001',
|
||||||
|
vendorName: 'Andi Wijaya',
|
||||||
|
vendorCompany: 'PT Sumber Makmur',
|
||||||
|
reference: 'REF-001',
|
||||||
|
date: '2025-09-01',
|
||||||
|
dueDate: '2025-09-15',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 5000000,
|
||||||
|
total: 5000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'PB-002',
|
||||||
|
vendorName: 'Siti Rahma',
|
||||||
|
vendorCompany: 'CV Cahaya Abadi',
|
||||||
|
reference: 'REF-002',
|
||||||
|
date: '2025-08-28',
|
||||||
|
dueDate: '2025-09-12',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 2000000,
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'PB-003',
|
||||||
|
vendorName: 'Budi Santoso',
|
||||||
|
vendorCompany: 'UD Sejahtera',
|
||||||
|
reference: 'REF-003',
|
||||||
|
date: '2025-09-05',
|
||||||
|
dueDate: '2025-09-20',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 3500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'PB-004',
|
||||||
|
vendorName: 'Rina Kartika',
|
||||||
|
vendorCompany: 'PT Mitra Jaya',
|
||||||
|
reference: 'REF-004',
|
||||||
|
date: '2025-08-30',
|
||||||
|
dueDate: '2025-09-14',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 12000000,
|
||||||
|
total: 12000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'PB-005',
|
||||||
|
vendorName: 'Agus Salim',
|
||||||
|
vendorCompany: 'CV Bumi Persada',
|
||||||
|
reference: 'REF-005',
|
||||||
|
date: '2025-09-03',
|
||||||
|
dueDate: '2025-09-18',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 1500000,
|
||||||
|
total: 6000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'PB-006',
|
||||||
|
vendorName: 'Maya Lestari',
|
||||||
|
vendorCompany: 'PT Tunas Baru',
|
||||||
|
reference: 'REF-006',
|
||||||
|
date: '2025-09-06',
|
||||||
|
dueDate: '2025-09-21',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 9000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'PB-007',
|
||||||
|
vendorName: 'Hendra Gunawan',
|
||||||
|
vendorCompany: 'UD Prima Sentosa',
|
||||||
|
reference: 'REF-007',
|
||||||
|
date: '2025-09-02',
|
||||||
|
dueDate: '2025-09-17',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 7200000,
|
||||||
|
total: 7200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'PB-008',
|
||||||
|
vendorName: 'Dewi Anggraini',
|
||||||
|
vendorCompany: 'CV Inti Mandiri',
|
||||||
|
reference: 'REF-008',
|
||||||
|
date: '2025-08-27',
|
||||||
|
dueDate: '2025-09-11',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 3000000,
|
||||||
|
total: 10000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'PB-009',
|
||||||
|
vendorName: 'Yusuf Arifin',
|
||||||
|
vendorCompany: 'PT Surya Kencana',
|
||||||
|
reference: 'REF-009',
|
||||||
|
date: '2025-09-04',
|
||||||
|
dueDate: '2025-09-19',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 4500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'PB-010',
|
||||||
|
vendorName: 'Nurhayati',
|
||||||
|
vendorCompany: 'UD Cahaya Mulia',
|
||||||
|
reference: 'REF-010',
|
||||||
|
date: '2025-09-07',
|
||||||
|
dueDate: '2025-09-22',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 2500000,
|
||||||
|
total: 2500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'PB-011',
|
||||||
|
vendorName: 'Fajar Hidayat',
|
||||||
|
vendorCompany: 'PT Bina Karya',
|
||||||
|
reference: 'REF-011',
|
||||||
|
date: '2025-09-01',
|
||||||
|
dueDate: '2025-09-16',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 1000000,
|
||||||
|
total: 7000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'PB-012',
|
||||||
|
vendorName: 'Ratna Sari',
|
||||||
|
vendorCompany: 'CV Mega Utama',
|
||||||
|
reference: 'REF-012',
|
||||||
|
date: '2025-09-08',
|
||||||
|
dueDate: '2025-09-23',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 5600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'PB-013',
|
||||||
|
vendorName: 'Tono Prasetyo',
|
||||||
|
vendorCompany: 'UD Karya Indah',
|
||||||
|
reference: 'REF-013',
|
||||||
|
date: '2025-08-29',
|
||||||
|
dueDate: '2025-09-13',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 8000000,
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'PB-014',
|
||||||
|
vendorName: 'Lina Marlina',
|
||||||
|
vendorCompany: 'PT Harmoni Sejati',
|
||||||
|
reference: 'REF-014',
|
||||||
|
date: '2025-09-05',
|
||||||
|
dueDate: '2025-09-20',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 4000000,
|
||||||
|
total: 10000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'PB-015',
|
||||||
|
vendorName: 'Arman Saputra',
|
||||||
|
vendorCompany: 'CV Sentra Niaga',
|
||||||
|
reference: 'REF-015',
|
||||||
|
date: '2025-09-03',
|
||||||
|
dueDate: '2025-09-18',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 3000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'PB-016',
|
||||||
|
vendorName: 'Indah Permata',
|
||||||
|
vendorCompany: 'PT Citra Abadi',
|
||||||
|
reference: 'REF-016',
|
||||||
|
date: '2025-08-31',
|
||||||
|
dueDate: '2025-09-15',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 6700000,
|
||||||
|
total: 6700000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'PB-017',
|
||||||
|
vendorName: 'Adi Putra',
|
||||||
|
vendorCompany: 'UD Makmur Bersama',
|
||||||
|
reference: 'REF-017',
|
||||||
|
date: '2025-09-02',
|
||||||
|
dueDate: '2025-09-17',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 2000000,
|
||||||
|
total: 9000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'PB-018',
|
||||||
|
vendorName: 'Sri Wahyuni',
|
||||||
|
vendorCompany: 'CV Bintang Terang',
|
||||||
|
reference: 'REF-018',
|
||||||
|
date: '2025-09-06',
|
||||||
|
dueDate: '2025-09-21',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 7200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'PB-019',
|
||||||
|
vendorName: 'Eko Prabowo',
|
||||||
|
vendorCompany: 'PT Mandiri Jaya',
|
||||||
|
reference: 'REF-019',
|
||||||
|
date: '2025-09-04',
|
||||||
|
dueDate: '2025-09-19',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 11000000,
|
||||||
|
total: 11000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'PB-020',
|
||||||
|
vendorName: 'Novi Astuti',
|
||||||
|
vendorCompany: 'UD Sinar Harapan',
|
||||||
|
reference: 'REF-020',
|
||||||
|
date: '2025-09-07',
|
||||||
|
dueDate: '2025-09-22',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 500000,
|
||||||
|
total: 4500000
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
import { PurchaseDeliveryType } from '@/types/apps/purchaseDeliveryTypes'
|
||||||
|
|
||||||
|
export const purchaseDeliveryData: PurchaseDeliveryType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'PD-001',
|
||||||
|
vendorName: 'Andi Wijaya',
|
||||||
|
vendorCompany: 'PT Sumber Makmur',
|
||||||
|
reference: 'REF-PD-001',
|
||||||
|
date: '2025-09-01',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'PD-002',
|
||||||
|
vendorName: 'Siti Rahma',
|
||||||
|
vendorCompany: 'CV Cahaya Abadi',
|
||||||
|
reference: 'REF-PD-002',
|
||||||
|
date: '2025-09-02',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'PD-003',
|
||||||
|
vendorName: 'Budi Santoso',
|
||||||
|
vendorCompany: 'UD Sejahtera',
|
||||||
|
reference: 'REF-PD-003',
|
||||||
|
date: '2025-09-03',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'PD-004',
|
||||||
|
vendorName: 'Rina Kartika',
|
||||||
|
vendorCompany: 'PT Mitra Jaya',
|
||||||
|
reference: 'REF-PD-004',
|
||||||
|
date: '2025-09-04',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'PD-005',
|
||||||
|
vendorName: 'Agus Salim',
|
||||||
|
vendorCompany: 'CV Bumi Persada',
|
||||||
|
reference: 'REF-PD-005',
|
||||||
|
date: '2025-09-05',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'PD-006',
|
||||||
|
vendorName: 'Maya Lestari',
|
||||||
|
vendorCompany: 'PT Tunas Baru',
|
||||||
|
reference: 'REF-PD-006',
|
||||||
|
date: '2025-09-06',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'PD-007',
|
||||||
|
vendorName: 'Hendra Gunawan',
|
||||||
|
vendorCompany: 'UD Prima Sentosa',
|
||||||
|
reference: 'REF-PD-007',
|
||||||
|
date: '2025-09-07',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'PD-008',
|
||||||
|
vendorName: 'Dewi Anggraini',
|
||||||
|
vendorCompany: 'CV Inti Mandiri',
|
||||||
|
reference: 'REF-PD-008',
|
||||||
|
date: '2025-09-08',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'PD-009',
|
||||||
|
vendorName: 'Yusuf Arifin',
|
||||||
|
vendorCompany: 'PT Surya Kencana',
|
||||||
|
reference: 'REF-PD-009',
|
||||||
|
date: '2025-09-09',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'PD-010',
|
||||||
|
vendorName: 'Nurhayati',
|
||||||
|
vendorCompany: 'UD Cahaya Mulia',
|
||||||
|
reference: 'REF-PD-010',
|
||||||
|
date: '2025-09-10',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'PD-011',
|
||||||
|
vendorName: 'Fajar Hidayat',
|
||||||
|
vendorCompany: 'PT Bina Karya',
|
||||||
|
reference: 'REF-PD-011',
|
||||||
|
date: '2025-09-11',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'PD-012',
|
||||||
|
vendorName: 'Ratna Sari',
|
||||||
|
vendorCompany: 'CV Mega Utama',
|
||||||
|
reference: 'REF-PD-012',
|
||||||
|
date: '2025-09-12',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'PD-013',
|
||||||
|
vendorName: 'Tono Prasetyo',
|
||||||
|
vendorCompany: 'UD Karya Indah',
|
||||||
|
reference: 'REF-PD-013',
|
||||||
|
date: '2025-09-13',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'PD-014',
|
||||||
|
vendorName: 'Lina Marlina',
|
||||||
|
vendorCompany: 'PT Harmoni Sejati',
|
||||||
|
reference: 'REF-PD-014',
|
||||||
|
date: '2025-09-14',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'PD-015',
|
||||||
|
vendorName: 'Arman Saputra',
|
||||||
|
vendorCompany: 'CV Sentra Niaga',
|
||||||
|
reference: 'REF-PD-015',
|
||||||
|
date: '2025-09-15',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'PD-016',
|
||||||
|
vendorName: 'Indah Permata',
|
||||||
|
vendorCompany: 'PT Citra Abadi',
|
||||||
|
reference: 'REF-PD-016',
|
||||||
|
date: '2025-09-16',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'PD-017',
|
||||||
|
vendorName: 'Adi Putra',
|
||||||
|
vendorCompany: 'UD Makmur Bersama',
|
||||||
|
reference: 'REF-PD-017',
|
||||||
|
date: '2025-09-17',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'PD-018',
|
||||||
|
vendorName: 'Sri Wahyuni',
|
||||||
|
vendorCompany: 'CV Bintang Terang',
|
||||||
|
reference: 'REF-PD-018',
|
||||||
|
date: '2025-09-18',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'PD-019',
|
||||||
|
vendorName: 'Eko Prabowo',
|
||||||
|
vendorCompany: 'PT Mandiri Jaya',
|
||||||
|
reference: 'REF-PD-019',
|
||||||
|
date: '2025-09-19',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'PD-020',
|
||||||
|
vendorName: 'Novi Astuti',
|
||||||
|
vendorCompany: 'UD Sinar Harapan',
|
||||||
|
reference: 'REF-PD-020',
|
||||||
|
date: '2025-09-20',
|
||||||
|
status: 'Selesai'
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
import { PurchaseOrderType } from '@/types/apps/purchaseOrderTypes'
|
||||||
|
|
||||||
|
export const purchaseOrdersData: PurchaseOrderType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'PO/00040',
|
||||||
|
vendorName: 'Kairav Wijaya Nababan',
|
||||||
|
vendorCompany: 'Yayasan Haryanto Tbk',
|
||||||
|
reference: '',
|
||||||
|
date: '05/09/2025',
|
||||||
|
dueDate: '19/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 2037170
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'PO/00041',
|
||||||
|
vendorName: 'Sari Melani Hutapea',
|
||||||
|
vendorCompany: 'PT Santoso Jaya',
|
||||||
|
reference: 'REF-2025-001',
|
||||||
|
date: '03/09/2025',
|
||||||
|
dueDate: '17/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 1875500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'PO/00042',
|
||||||
|
vendorName: 'Budi Prasetyo Manullang',
|
||||||
|
vendorCompany: 'CV Wijaya Makmur',
|
||||||
|
reference: 'REF-2025-002',
|
||||||
|
date: '07/09/2025',
|
||||||
|
dueDate: '21/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 3250750
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'PO/00043',
|
||||||
|
vendorName: 'Maya Sari Lumban Gaol',
|
||||||
|
vendorCompany: 'PT Indah Permata',
|
||||||
|
reference: '',
|
||||||
|
date: '02/09/2025',
|
||||||
|
dueDate: '16/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 980250
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'PO/00044',
|
||||||
|
vendorName: 'Rahman Hakim Siahaan',
|
||||||
|
vendorCompany: 'Toko Bahagia Sejahtera',
|
||||||
|
reference: 'REF-2025-003',
|
||||||
|
date: '08/09/2025',
|
||||||
|
dueDate: '22/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 4125890
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'PO/00045',
|
||||||
|
vendorName: 'Dewi Anggraini Panjaitan',
|
||||||
|
vendorCompany: 'PT Maju Bersama',
|
||||||
|
reference: 'REF-2025-004',
|
||||||
|
date: '01/09/2025',
|
||||||
|
dueDate: '15/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 2678300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'PO/00046',
|
||||||
|
vendorName: 'Agung Wijaya Simbolon',
|
||||||
|
vendorCompany: 'CV Karya Mandiri',
|
||||||
|
reference: '',
|
||||||
|
date: '06/09/2025',
|
||||||
|
dueDate: '20/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 1456780
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'PO/00047',
|
||||||
|
vendorName: 'Fitri Handayani Sitorus',
|
||||||
|
vendorCompany: 'PT Global Nusantara',
|
||||||
|
reference: 'REF-2025-005',
|
||||||
|
date: '04/09/2025',
|
||||||
|
dueDate: '18/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 5892450
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'PO/00048',
|
||||||
|
vendorName: 'Andi Setiawan Tampubolon',
|
||||||
|
vendorCompany: 'Yayasan Pembangunan Tbk',
|
||||||
|
reference: 'REF-2025-006',
|
||||||
|
date: '09/09/2025',
|
||||||
|
dueDate: '23/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 3567120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'PO/00049',
|
||||||
|
vendorName: 'Rina Maharani Hutasoit',
|
||||||
|
vendorCompany: 'PT Sejahtera Abadi',
|
||||||
|
reference: '',
|
||||||
|
date: '05/09/2025',
|
||||||
|
dueDate: '19/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 2234680
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'PO/00050',
|
||||||
|
vendorName: 'Joko Santoso Nainggolan',
|
||||||
|
vendorCompany: 'CV Berkah Jaya',
|
||||||
|
reference: 'REF-2025-007',
|
||||||
|
date: '03/09/2025',
|
||||||
|
dueDate: '17/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 1789560
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'PO/00051',
|
||||||
|
vendorName: 'Linda Safitri Simanjuntak',
|
||||||
|
vendorCompany: 'PT Harapan Bangsa',
|
||||||
|
reference: 'REF-2025-008',
|
||||||
|
date: '07/09/2025',
|
||||||
|
dueDate: '21/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 4321870
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'PO/00052',
|
||||||
|
vendorName: 'Irfan Maulana Pasaribu',
|
||||||
|
vendorCompany: 'CV Sumber Rejeki',
|
||||||
|
reference: 'REF-2025-009',
|
||||||
|
date: '10/09/2025',
|
||||||
|
dueDate: '24/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 2567890
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'PO/00053',
|
||||||
|
vendorName: 'Siska Permata Sinaga',
|
||||||
|
vendorCompany: 'PT Mitra Sukses',
|
||||||
|
reference: '',
|
||||||
|
date: '11/09/2025',
|
||||||
|
dueDate: '25/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 3456780
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'PO/00054',
|
||||||
|
vendorName: 'Rizky Aditya Siregar',
|
||||||
|
vendorCompany: 'Toko Aman Sentosa',
|
||||||
|
reference: 'REF-2025-010',
|
||||||
|
date: '08/09/2025',
|
||||||
|
dueDate: '22/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 1234567
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'PO/00055',
|
||||||
|
vendorName: 'Nina Sari Hutabarat',
|
||||||
|
vendorCompany: 'PT Cahaya Terang',
|
||||||
|
reference: 'REF-2025-011',
|
||||||
|
date: '12/09/2025',
|
||||||
|
dueDate: '26/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 5678900
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'PO/00056',
|
||||||
|
vendorName: 'Doni Prasetya Situmorang',
|
||||||
|
vendorCompany: 'CV Barokah Makmur',
|
||||||
|
reference: '',
|
||||||
|
date: '09/09/2025',
|
||||||
|
dueDate: '23/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 987654
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'PO/00057',
|
||||||
|
vendorName: 'Anita Dewi Marpaung',
|
||||||
|
vendorCompany: 'Yayasan Karya Bhakti',
|
||||||
|
reference: 'REF-2025-012',
|
||||||
|
date: '06/09/2025',
|
||||||
|
dueDate: '20/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 4567123
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'PO/00058',
|
||||||
|
vendorName: 'Tommy Wijaya Samosir',
|
||||||
|
vendorCompany: 'PT Bintang Timur',
|
||||||
|
reference: 'REF-2025-013',
|
||||||
|
date: '13/09/2025',
|
||||||
|
dueDate: '27/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 2345678
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'PO/00059',
|
||||||
|
vendorName: 'Lestari Indah Pakpahan',
|
||||||
|
vendorCompany: 'CV Harmoni Jaya',
|
||||||
|
reference: '',
|
||||||
|
date: '05/09/2025',
|
||||||
|
dueDate: '19/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 3789012
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
import { PurchaseQuoteType } from '@/types/apps/purchaseQuoteTypes'
|
||||||
|
|
||||||
|
export const purchaseQuoteData: PurchaseQuoteType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'PQ-001',
|
||||||
|
vendorName: 'Andi Wijaya',
|
||||||
|
vendorCompany: 'PT Sumber Makmur',
|
||||||
|
reference: 'REF-PQ-001',
|
||||||
|
date: '2025-09-01',
|
||||||
|
dueDate: '2025-09-10',
|
||||||
|
status: 'Open',
|
||||||
|
total: 4500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'PQ-002',
|
||||||
|
vendorName: 'Siti Rahma',
|
||||||
|
vendorCompany: 'CV Cahaya Abadi',
|
||||||
|
reference: 'REF-PQ-002',
|
||||||
|
date: '2025-09-02',
|
||||||
|
dueDate: '2025-09-12',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 7200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'PQ-003',
|
||||||
|
vendorName: 'Budi Santoso',
|
||||||
|
vendorCompany: 'UD Sejahtera',
|
||||||
|
reference: 'REF-PQ-003',
|
||||||
|
date: '2025-09-03',
|
||||||
|
dueDate: '2025-09-13',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 3100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'PQ-004',
|
||||||
|
vendorName: 'Rina Kartika',
|
||||||
|
vendorCompany: 'PT Mitra Jaya',
|
||||||
|
reference: 'REF-PQ-004',
|
||||||
|
date: '2025-09-04',
|
||||||
|
dueDate: '2025-09-15',
|
||||||
|
status: 'Open',
|
||||||
|
total: 5800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'PQ-005',
|
||||||
|
vendorName: 'Agus Salim',
|
||||||
|
vendorCompany: 'CV Bumi Persada',
|
||||||
|
reference: 'REF-PQ-005',
|
||||||
|
date: '2025-09-05',
|
||||||
|
dueDate: '2025-09-16',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'PQ-006',
|
||||||
|
vendorName: 'Maya Lestari',
|
||||||
|
vendorCompany: 'PT Tunas Baru',
|
||||||
|
reference: 'REF-PQ-006',
|
||||||
|
date: '2025-09-06',
|
||||||
|
dueDate: '2025-09-17',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 2600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'PQ-007',
|
||||||
|
vendorName: 'Hendra Gunawan',
|
||||||
|
vendorCompany: 'UD Prima Sentosa',
|
||||||
|
reference: 'REF-PQ-007',
|
||||||
|
date: '2025-09-07',
|
||||||
|
dueDate: '2025-09-18',
|
||||||
|
status: 'Open',
|
||||||
|
total: 9300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'PQ-008',
|
||||||
|
vendorName: 'Dewi Anggraini',
|
||||||
|
vendorCompany: 'CV Inti Mandiri',
|
||||||
|
reference: 'REF-PQ-008',
|
||||||
|
date: '2025-09-08',
|
||||||
|
dueDate: '2025-09-19',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 4100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'PQ-009',
|
||||||
|
vendorName: 'Yusuf Arifin',
|
||||||
|
vendorCompany: 'PT Surya Kencana',
|
||||||
|
reference: 'REF-PQ-009',
|
||||||
|
date: '2025-09-09',
|
||||||
|
dueDate: '2025-09-20',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 6900000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'PQ-010',
|
||||||
|
vendorName: 'Nurhayati',
|
||||||
|
vendorCompany: 'UD Cahaya Mulia',
|
||||||
|
reference: 'REF-PQ-010',
|
||||||
|
date: '2025-09-10',
|
||||||
|
dueDate: '2025-09-21',
|
||||||
|
status: 'Open',
|
||||||
|
total: 5500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'PQ-011',
|
||||||
|
vendorName: 'Fajar Hidayat',
|
||||||
|
vendorCompany: 'PT Bina Karya',
|
||||||
|
reference: 'REF-PQ-011',
|
||||||
|
date: '2025-09-11',
|
||||||
|
dueDate: '2025-09-22',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 12000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'PQ-012',
|
||||||
|
vendorName: 'Ratna Sari',
|
||||||
|
vendorCompany: 'CV Mega Utama',
|
||||||
|
reference: 'REF-PQ-012',
|
||||||
|
date: '2025-09-12',
|
||||||
|
dueDate: '2025-09-23',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 3300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'PQ-013',
|
||||||
|
vendorName: 'Tono Prasetyo',
|
||||||
|
vendorCompany: 'UD Karya Indah',
|
||||||
|
reference: 'REF-PQ-013',
|
||||||
|
date: '2025-09-13',
|
||||||
|
dueDate: '2025-09-24',
|
||||||
|
status: 'Open',
|
||||||
|
total: 7500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'PQ-014',
|
||||||
|
vendorName: 'Lina Marlina',
|
||||||
|
vendorCompany: 'PT Harmoni Sejati',
|
||||||
|
reference: 'REF-PQ-014',
|
||||||
|
date: '2025-09-14',
|
||||||
|
dueDate: '2025-09-25',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 8600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'PQ-015',
|
||||||
|
vendorName: 'Arman Saputra',
|
||||||
|
vendorCompany: 'CV Sentra Niaga',
|
||||||
|
reference: 'REF-PQ-015',
|
||||||
|
date: '2025-09-15',
|
||||||
|
dueDate: '2025-09-26',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 2950000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'PQ-016',
|
||||||
|
vendorName: 'Indah Permata',
|
||||||
|
vendorCompany: 'PT Citra Abadi',
|
||||||
|
reference: 'REF-PQ-016',
|
||||||
|
date: '2025-09-16',
|
||||||
|
dueDate: '2025-09-27',
|
||||||
|
status: 'Open',
|
||||||
|
total: 6800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'PQ-017',
|
||||||
|
vendorName: 'Adi Putra',
|
||||||
|
vendorCompany: 'UD Makmur Bersama',
|
||||||
|
reference: 'REF-PQ-017',
|
||||||
|
date: '2025-09-17',
|
||||||
|
dueDate: '2025-09-28',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 4700000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'PQ-018',
|
||||||
|
vendorName: 'Sri Wahyuni',
|
||||||
|
vendorCompany: 'CV Bintang Terang',
|
||||||
|
reference: 'REF-PQ-018',
|
||||||
|
date: '2025-09-18',
|
||||||
|
dueDate: '2025-09-29',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 5300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'PQ-019',
|
||||||
|
vendorName: 'Eko Prabowo',
|
||||||
|
vendorCompany: 'PT Mandiri Jaya',
|
||||||
|
reference: 'REF-PQ-019',
|
||||||
|
date: '2025-09-19',
|
||||||
|
dueDate: '2025-09-30',
|
||||||
|
status: 'Open',
|
||||||
|
total: 9500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'PQ-020',
|
||||||
|
vendorName: 'Novi Astuti',
|
||||||
|
vendorCompany: 'UD Sinar Harapan',
|
||||||
|
reference: 'REF-PQ-020',
|
||||||
|
date: '2025-09-20',
|
||||||
|
dueDate: '2025-10-01',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 4200000
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,873 @@
|
|||||||
|
import { SalesBillType, SalesDeliveryType, SalesOrderType, SalesQuoteType } from '@/types/apps/salesTypes'
|
||||||
|
|
||||||
|
export const salesBillData: SalesBillType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'INV/001',
|
||||||
|
customerName: 'Andi Wijaya',
|
||||||
|
customerCompany: 'PT Nusantara Abadi',
|
||||||
|
reference: 'REF-SB-001',
|
||||||
|
date: '2025-09-01',
|
||||||
|
dueDate: '2025-09-15',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 5000000,
|
||||||
|
total: 5000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'INV/002',
|
||||||
|
customerName: 'Siti Rahma',
|
||||||
|
customerCompany: 'CV Cahaya Abadi',
|
||||||
|
reference: 'REF-SB-002',
|
||||||
|
date: '2025-09-02',
|
||||||
|
dueDate: '2025-09-16',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 2000000,
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'INV/003',
|
||||||
|
customerName: 'Budi Santoso',
|
||||||
|
customerCompany: 'UD Sejahtera',
|
||||||
|
reference: 'REF-SB-003',
|
||||||
|
date: '2025-09-03',
|
||||||
|
dueDate: '2025-09-17',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 3500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'INV/004',
|
||||||
|
customerName: 'Rina Kartika',
|
||||||
|
customerCompany: 'PT Mitra Jaya',
|
||||||
|
reference: 'REF-SB-004',
|
||||||
|
date: '2025-09-04',
|
||||||
|
dueDate: '2025-09-18',
|
||||||
|
status: 'Void',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 4200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'INV/005',
|
||||||
|
customerName: 'Agus Salim',
|
||||||
|
customerCompany: 'CV Bumi Persada',
|
||||||
|
reference: 'REF-SB-005',
|
||||||
|
date: '2025-09-05',
|
||||||
|
dueDate: '2025-09-19',
|
||||||
|
status: 'Retur',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 6100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'INV/006',
|
||||||
|
customerName: 'Maya Lestari',
|
||||||
|
customerCompany: 'PT Tunas Baru',
|
||||||
|
reference: 'REF-SB-006',
|
||||||
|
date: '2025-09-06',
|
||||||
|
dueDate: '2025-09-20',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 9000000,
|
||||||
|
total: 9000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'INV/007',
|
||||||
|
customerName: 'Hendra Gunawan',
|
||||||
|
customerCompany: 'UD Prima Sentosa',
|
||||||
|
reference: 'REF-SB-007',
|
||||||
|
date: '2025-09-07',
|
||||||
|
dueDate: '2025-09-21',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 1500000,
|
||||||
|
total: 7500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'INV/008',
|
||||||
|
customerName: 'Dewi Anggraini',
|
||||||
|
customerCompany: 'CV Inti Mandiri',
|
||||||
|
reference: 'REF-SB-008',
|
||||||
|
date: '2025-09-08',
|
||||||
|
dueDate: '2025-09-22',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 4500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'INV/009',
|
||||||
|
customerName: 'Yusuf Arifin',
|
||||||
|
customerCompany: 'PT Surya Kencana',
|
||||||
|
reference: 'REF-SB-009',
|
||||||
|
date: '2025-09-09',
|
||||||
|
dueDate: '2025-09-23',
|
||||||
|
status: 'Void',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 5000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'INV/010',
|
||||||
|
customerName: 'Nurhayati',
|
||||||
|
customerCompany: 'UD Cahaya Mulia',
|
||||||
|
reference: 'REF-SB-010',
|
||||||
|
date: '2025-09-10',
|
||||||
|
dueDate: '2025-09-24',
|
||||||
|
status: 'Retur',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 3000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'INV/011',
|
||||||
|
customerName: 'Fajar Hidayat',
|
||||||
|
customerCompany: 'PT Bina Karya',
|
||||||
|
reference: 'REF-SB-011',
|
||||||
|
date: '2025-09-11',
|
||||||
|
dueDate: '2025-09-25',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 6000000,
|
||||||
|
total: 6000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'INV/012',
|
||||||
|
customerName: 'Ratna Sari',
|
||||||
|
customerCompany: 'CV Mega Utama',
|
||||||
|
reference: 'REF-SB-012',
|
||||||
|
date: '2025-09-12',
|
||||||
|
dueDate: '2025-09-26',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 2500000,
|
||||||
|
total: 10000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'INV/013',
|
||||||
|
customerName: 'Tono Prasetyo',
|
||||||
|
customerCompany: 'UD Karya Indah',
|
||||||
|
reference: 'REF-SB-013',
|
||||||
|
date: '2025-09-13',
|
||||||
|
dueDate: '2025-09-27',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 7000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'INV/014',
|
||||||
|
customerName: 'Lina Marlina',
|
||||||
|
customerCompany: 'PT Harmoni Sejati',
|
||||||
|
reference: 'REF-SB-014',
|
||||||
|
date: '2025-09-14',
|
||||||
|
dueDate: '2025-09-28',
|
||||||
|
status: 'Void',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 3200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'INV/015',
|
||||||
|
customerName: 'Arman Saputra',
|
||||||
|
customerCompany: 'CV Sentra Niaga',
|
||||||
|
reference: 'REF-SB-015',
|
||||||
|
date: '2025-09-15',
|
||||||
|
dueDate: '2025-09-29',
|
||||||
|
status: 'Retur',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 5400000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'INV/016',
|
||||||
|
customerName: 'Indah Permata',
|
||||||
|
customerCompany: 'PT Citra Abadi',
|
||||||
|
reference: 'REF-SB-016',
|
||||||
|
date: '2025-09-16',
|
||||||
|
dueDate: '2025-09-30',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 8000000,
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'INV/017',
|
||||||
|
customerName: 'Adi Putra',
|
||||||
|
customerCompany: 'UD Makmur Bersama',
|
||||||
|
reference: 'REF-SB-017',
|
||||||
|
date: '2025-09-17',
|
||||||
|
dueDate: '2025-10-01',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 1200000,
|
||||||
|
total: 6200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'INV/018',
|
||||||
|
customerName: 'Sri Wahyuni',
|
||||||
|
customerCompany: 'CV Bintang Terang',
|
||||||
|
reference: 'REF-SB-018',
|
||||||
|
date: '2025-09-18',
|
||||||
|
dueDate: '2025-10-02',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 9200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'INV/019',
|
||||||
|
customerName: 'Eko Prabowo',
|
||||||
|
customerCompany: 'PT Mandiri Jaya',
|
||||||
|
reference: 'REF-SB-019',
|
||||||
|
date: '2025-09-19',
|
||||||
|
dueDate: '2025-10-03',
|
||||||
|
status: 'Void',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 2500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'INV/020',
|
||||||
|
customerName: 'Novi Astuti',
|
||||||
|
customerCompany: 'UD Sinar Harapan',
|
||||||
|
reference: 'REF-SB-020',
|
||||||
|
date: '2025-09-20',
|
||||||
|
dueDate: '2025-10-04',
|
||||||
|
status: 'Retur',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 4800000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const salesDeliveryData: SalesDeliveryType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'INV-001',
|
||||||
|
vendorName: 'Andi Wijaya',
|
||||||
|
vendorCompany: 'PT Sumber Makmur',
|
||||||
|
reference: 'REF-INV-001',
|
||||||
|
date: '2025-09-01',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'INV-002',
|
||||||
|
vendorName: 'Siti Rahma',
|
||||||
|
vendorCompany: 'CV Cahaya Abadi',
|
||||||
|
reference: 'REF-INV-002',
|
||||||
|
date: '2025-09-02',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'INV-003',
|
||||||
|
vendorName: 'Budi Santoso',
|
||||||
|
vendorCompany: 'UD Sejahtera',
|
||||||
|
reference: 'REF-INV-003',
|
||||||
|
date: '2025-09-03',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'INV-004',
|
||||||
|
vendorName: 'Rina Kartika',
|
||||||
|
vendorCompany: 'PT Mitra Jaya',
|
||||||
|
reference: 'REF-INV-004',
|
||||||
|
date: '2025-09-04',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'INV-005',
|
||||||
|
vendorName: 'Agus Salim',
|
||||||
|
vendorCompany: 'CV Bumi Persada',
|
||||||
|
reference: 'REF-INV-005',
|
||||||
|
date: '2025-09-05',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'INV-006',
|
||||||
|
vendorName: 'Maya Lestari',
|
||||||
|
vendorCompany: 'PT Tunas Baru',
|
||||||
|
reference: 'REF-INV-006',
|
||||||
|
date: '2025-09-06',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'INV-007',
|
||||||
|
vendorName: 'Hendra Gunawan',
|
||||||
|
vendorCompany: 'UD Prima Sentosa',
|
||||||
|
reference: 'REF-INV-007',
|
||||||
|
date: '2025-09-07',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'INV-008',
|
||||||
|
vendorName: 'Dewi Anggraini',
|
||||||
|
vendorCompany: 'CV Inti Mandiri',
|
||||||
|
reference: 'REF-INV-008',
|
||||||
|
date: '2025-09-08',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'INV-009',
|
||||||
|
vendorName: 'Yusuf Arifin',
|
||||||
|
vendorCompany: 'PT Surya Kencana',
|
||||||
|
reference: 'REF-INV-009',
|
||||||
|
date: '2025-09-09',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'INV-010',
|
||||||
|
vendorName: 'Nurhayati',
|
||||||
|
vendorCompany: 'UD Cahaya Mulia',
|
||||||
|
reference: 'REF-INV-010',
|
||||||
|
date: '2025-09-10',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'INV-011',
|
||||||
|
vendorName: 'Fajar Hidayat',
|
||||||
|
vendorCompany: 'PT Bina Karya',
|
||||||
|
reference: 'REF-INV-011',
|
||||||
|
date: '2025-09-11',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'INV-012',
|
||||||
|
vendorName: 'Ratna Sari',
|
||||||
|
vendorCompany: 'CV Mega Utama',
|
||||||
|
reference: 'REF-INV-012',
|
||||||
|
date: '2025-09-12',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'INV-013',
|
||||||
|
vendorName: 'Tono Prasetyo',
|
||||||
|
vendorCompany: 'UD Karya Indah',
|
||||||
|
reference: 'REF-INV-013',
|
||||||
|
date: '2025-09-13',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'INV-014',
|
||||||
|
vendorName: 'Lina Marlina',
|
||||||
|
vendorCompany: 'PT Harmoni Sejati',
|
||||||
|
reference: 'REF-INV-014',
|
||||||
|
date: '2025-09-14',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'INV-015',
|
||||||
|
vendorName: 'Arman Saputra',
|
||||||
|
vendorCompany: 'CV Sentra Niaga',
|
||||||
|
reference: 'REF-INV-015',
|
||||||
|
date: '2025-09-15',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'INV-016',
|
||||||
|
vendorName: 'Indah Permata',
|
||||||
|
vendorCompany: 'PT Citra Abadi',
|
||||||
|
reference: 'REF-INV-016',
|
||||||
|
date: '2025-09-16',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'INV-017',
|
||||||
|
vendorName: 'Adi Putra',
|
||||||
|
vendorCompany: 'UD Makmur Bersama',
|
||||||
|
reference: 'REF-INV-017',
|
||||||
|
date: '2025-09-17',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'INV-018',
|
||||||
|
vendorName: 'Sri Wahyuni',
|
||||||
|
vendorCompany: 'CV Bintang Terang',
|
||||||
|
reference: 'REF-INV-018',
|
||||||
|
date: '2025-09-18',
|
||||||
|
status: 'Selesai'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'INV-019',
|
||||||
|
vendorName: 'Eko Prabowo',
|
||||||
|
vendorCompany: 'PT Mandiri Jaya',
|
||||||
|
reference: 'REF-INV-019',
|
||||||
|
date: '2025-09-19',
|
||||||
|
status: 'Open'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'INV-020',
|
||||||
|
vendorName: 'Novi Astuti',
|
||||||
|
vendorCompany: 'UD Sinar Harapan',
|
||||||
|
reference: 'REF-INV-020',
|
||||||
|
date: '2025-09-20',
|
||||||
|
status: 'Selesai'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const salesOrdersData: SalesOrderType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'PO/00040',
|
||||||
|
vendorName: 'Kairav Wijaya Nababan',
|
||||||
|
vendorCompany: 'Yayasan Haryanto Tbk',
|
||||||
|
reference: '',
|
||||||
|
date: '05/09/2025',
|
||||||
|
dueDate: '19/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 2037170
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'PO/00041',
|
||||||
|
vendorName: 'Sari Melani Hutapea',
|
||||||
|
vendorCompany: 'PT Santoso Jaya',
|
||||||
|
reference: 'REF-2025-001',
|
||||||
|
date: '03/09/2025',
|
||||||
|
dueDate: '17/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 1875500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'PO/00042',
|
||||||
|
vendorName: 'Budi Prasetyo Manullang',
|
||||||
|
vendorCompany: 'CV Wijaya Makmur',
|
||||||
|
reference: 'REF-2025-002',
|
||||||
|
date: '07/09/2025',
|
||||||
|
dueDate: '21/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 3250750
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'PO/00043',
|
||||||
|
vendorName: 'Maya Sari Lumban Gaol',
|
||||||
|
vendorCompany: 'PT Indah Permata',
|
||||||
|
reference: '',
|
||||||
|
date: '02/09/2025',
|
||||||
|
dueDate: '16/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 980250
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'PO/00044',
|
||||||
|
vendorName: 'Rahman Hakim Siahaan',
|
||||||
|
vendorCompany: 'Toko Bahagia Sejahtera',
|
||||||
|
reference: 'REF-2025-003',
|
||||||
|
date: '08/09/2025',
|
||||||
|
dueDate: '22/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 4125890
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'PO/00045',
|
||||||
|
vendorName: 'Dewi Anggraini Panjaitan',
|
||||||
|
vendorCompany: 'PT Maju Bersama',
|
||||||
|
reference: 'REF-2025-004',
|
||||||
|
date: '01/09/2025',
|
||||||
|
dueDate: '15/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 2678300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'PO/00046',
|
||||||
|
vendorName: 'Agung Wijaya Simbolon',
|
||||||
|
vendorCompany: 'CV Karya Mandiri',
|
||||||
|
reference: '',
|
||||||
|
date: '06/09/2025',
|
||||||
|
dueDate: '20/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 1456780
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'PO/00047',
|
||||||
|
vendorName: 'Fitri Handayani Sitorus',
|
||||||
|
vendorCompany: 'PT Global Nusantara',
|
||||||
|
reference: 'REF-2025-005',
|
||||||
|
date: '04/09/2025',
|
||||||
|
dueDate: '18/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 5892450
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'PO/00048',
|
||||||
|
vendorName: 'Andi Setiawan Tampubolon',
|
||||||
|
vendorCompany: 'Yayasan Pembangunan Tbk',
|
||||||
|
reference: 'REF-2025-006',
|
||||||
|
date: '09/09/2025',
|
||||||
|
dueDate: '23/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 3567120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'PO/00049',
|
||||||
|
vendorName: 'Rina Maharani Hutasoit',
|
||||||
|
vendorCompany: 'PT Sejahtera Abadi',
|
||||||
|
reference: '',
|
||||||
|
date: '05/09/2025',
|
||||||
|
dueDate: '19/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 2234680
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'PO/00050',
|
||||||
|
vendorName: 'Joko Santoso Nainggolan',
|
||||||
|
vendorCompany: 'CV Berkah Jaya',
|
||||||
|
reference: 'REF-2025-007',
|
||||||
|
date: '03/09/2025',
|
||||||
|
dueDate: '17/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 1789560
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'PO/00051',
|
||||||
|
vendorName: 'Linda Safitri Simanjuntak',
|
||||||
|
vendorCompany: 'PT Harapan Bangsa',
|
||||||
|
reference: 'REF-2025-008',
|
||||||
|
date: '07/09/2025',
|
||||||
|
dueDate: '21/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 4321870
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'PO/00052',
|
||||||
|
vendorName: 'Irfan Maulana Pasaribu',
|
||||||
|
vendorCompany: 'CV Sumber Rejeki',
|
||||||
|
reference: 'REF-2025-009',
|
||||||
|
date: '10/09/2025',
|
||||||
|
dueDate: '24/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 2567890
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'PO/00053',
|
||||||
|
vendorName: 'Siska Permata Sinaga',
|
||||||
|
vendorCompany: 'PT Mitra Sukses',
|
||||||
|
reference: '',
|
||||||
|
date: '11/09/2025',
|
||||||
|
dueDate: '25/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 3456780
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'PO/00054',
|
||||||
|
vendorName: 'Rizky Aditya Siregar',
|
||||||
|
vendorCompany: 'Toko Aman Sentosa',
|
||||||
|
reference: 'REF-2025-010',
|
||||||
|
date: '08/09/2025',
|
||||||
|
dueDate: '22/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 1234567
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'PO/00055',
|
||||||
|
vendorName: 'Nina Sari Hutabarat',
|
||||||
|
vendorCompany: 'PT Cahaya Terang',
|
||||||
|
reference: 'REF-2025-011',
|
||||||
|
date: '12/09/2025',
|
||||||
|
dueDate: '26/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 5678900
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'PO/00056',
|
||||||
|
vendorName: 'Doni Prasetya Situmorang',
|
||||||
|
vendorCompany: 'CV Barokah Makmur',
|
||||||
|
reference: '',
|
||||||
|
date: '09/09/2025',
|
||||||
|
dueDate: '23/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 987654
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'PO/00057',
|
||||||
|
vendorName: 'Anita Dewi Marpaung',
|
||||||
|
vendorCompany: 'Yayasan Karya Bhakti',
|
||||||
|
reference: 'REF-2025-012',
|
||||||
|
date: '06/09/2025',
|
||||||
|
dueDate: '20/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 4567123
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'PO/00058',
|
||||||
|
vendorName: 'Tommy Wijaya Samosir',
|
||||||
|
vendorCompany: 'PT Bintang Timur',
|
||||||
|
reference: 'REF-2025-013',
|
||||||
|
date: '13/09/2025',
|
||||||
|
dueDate: '27/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 2345678
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'PO/00059',
|
||||||
|
vendorName: 'Lestari Indah Pakpahan',
|
||||||
|
vendorCompany: 'CV Harmoni Jaya',
|
||||||
|
reference: '',
|
||||||
|
date: '05/09/2025',
|
||||||
|
dueDate: '19/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 3789012
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const salesQuoteData: SalesQuoteType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'PQ-001',
|
||||||
|
vendorName: 'Andi Wijaya',
|
||||||
|
vendorCompany: 'PT Sumber Makmur',
|
||||||
|
reference: 'REF-PQ-001',
|
||||||
|
date: '2025-09-01',
|
||||||
|
dueDate: '2025-09-10',
|
||||||
|
status: 'Open',
|
||||||
|
total: 4500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'PQ-002',
|
||||||
|
vendorName: 'Siti Rahma',
|
||||||
|
vendorCompany: 'CV Cahaya Abadi',
|
||||||
|
reference: 'REF-PQ-002',
|
||||||
|
date: '2025-09-02',
|
||||||
|
dueDate: '2025-09-12',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 7200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'PQ-003',
|
||||||
|
vendorName: 'Budi Santoso',
|
||||||
|
vendorCompany: 'UD Sejahtera',
|
||||||
|
reference: 'REF-PQ-003',
|
||||||
|
date: '2025-09-03',
|
||||||
|
dueDate: '2025-09-13',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 3100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'PQ-004',
|
||||||
|
vendorName: 'Rina Kartika',
|
||||||
|
vendorCompany: 'PT Mitra Jaya',
|
||||||
|
reference: 'REF-PQ-004',
|
||||||
|
date: '2025-09-04',
|
||||||
|
dueDate: '2025-09-15',
|
||||||
|
status: 'Open',
|
||||||
|
total: 5800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'PQ-005',
|
||||||
|
vendorName: 'Agus Salim',
|
||||||
|
vendorCompany: 'CV Bumi Persada',
|
||||||
|
reference: 'REF-PQ-005',
|
||||||
|
date: '2025-09-05',
|
||||||
|
dueDate: '2025-09-16',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'PQ-006',
|
||||||
|
vendorName: 'Maya Lestari',
|
||||||
|
vendorCompany: 'PT Tunas Baru',
|
||||||
|
reference: 'REF-PQ-006',
|
||||||
|
date: '2025-09-06',
|
||||||
|
dueDate: '2025-09-17',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 2600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'PQ-007',
|
||||||
|
vendorName: 'Hendra Gunawan',
|
||||||
|
vendorCompany: 'UD Prima Sentosa',
|
||||||
|
reference: 'REF-PQ-007',
|
||||||
|
date: '2025-09-07',
|
||||||
|
dueDate: '2025-09-18',
|
||||||
|
status: 'Open',
|
||||||
|
total: 9300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'PQ-008',
|
||||||
|
vendorName: 'Dewi Anggraini',
|
||||||
|
vendorCompany: 'CV Inti Mandiri',
|
||||||
|
reference: 'REF-PQ-008',
|
||||||
|
date: '2025-09-08',
|
||||||
|
dueDate: '2025-09-19',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 4100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'PQ-009',
|
||||||
|
vendorName: 'Yusuf Arifin',
|
||||||
|
vendorCompany: 'PT Surya Kencana',
|
||||||
|
reference: 'REF-PQ-009',
|
||||||
|
date: '2025-09-09',
|
||||||
|
dueDate: '2025-09-20',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 6900000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'PQ-010',
|
||||||
|
vendorName: 'Nurhayati',
|
||||||
|
vendorCompany: 'UD Cahaya Mulia',
|
||||||
|
reference: 'REF-PQ-010',
|
||||||
|
date: '2025-09-10',
|
||||||
|
dueDate: '2025-09-21',
|
||||||
|
status: 'Open',
|
||||||
|
total: 5500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'PQ-011',
|
||||||
|
vendorName: 'Fajar Hidayat',
|
||||||
|
vendorCompany: 'PT Bina Karya',
|
||||||
|
reference: 'REF-PQ-011',
|
||||||
|
date: '2025-09-11',
|
||||||
|
dueDate: '2025-09-22',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 12000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'PQ-012',
|
||||||
|
vendorName: 'Ratna Sari',
|
||||||
|
vendorCompany: 'CV Mega Utama',
|
||||||
|
reference: 'REF-PQ-012',
|
||||||
|
date: '2025-09-12',
|
||||||
|
dueDate: '2025-09-23',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 3300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'PQ-013',
|
||||||
|
vendorName: 'Tono Prasetyo',
|
||||||
|
vendorCompany: 'UD Karya Indah',
|
||||||
|
reference: 'REF-PQ-013',
|
||||||
|
date: '2025-09-13',
|
||||||
|
dueDate: '2025-09-24',
|
||||||
|
status: 'Open',
|
||||||
|
total: 7500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'PQ-014',
|
||||||
|
vendorName: 'Lina Marlina',
|
||||||
|
vendorCompany: 'PT Harmoni Sejati',
|
||||||
|
reference: 'REF-PQ-014',
|
||||||
|
date: '2025-09-14',
|
||||||
|
dueDate: '2025-09-25',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 8600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'PQ-015',
|
||||||
|
vendorName: 'Arman Saputra',
|
||||||
|
vendorCompany: 'CV Sentra Niaga',
|
||||||
|
reference: 'REF-PQ-015',
|
||||||
|
date: '2025-09-15',
|
||||||
|
dueDate: '2025-09-26',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 2950000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'PQ-016',
|
||||||
|
vendorName: 'Indah Permata',
|
||||||
|
vendorCompany: 'PT Citra Abadi',
|
||||||
|
reference: 'REF-PQ-016',
|
||||||
|
date: '2025-09-16',
|
||||||
|
dueDate: '2025-09-27',
|
||||||
|
status: 'Open',
|
||||||
|
total: 6800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'PQ-017',
|
||||||
|
vendorName: 'Adi Putra',
|
||||||
|
vendorCompany: 'UD Makmur Bersama',
|
||||||
|
reference: 'REF-PQ-017',
|
||||||
|
date: '2025-09-17',
|
||||||
|
dueDate: '2025-09-28',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 4700000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'PQ-018',
|
||||||
|
vendorName: 'Sri Wahyuni',
|
||||||
|
vendorCompany: 'CV Bintang Terang',
|
||||||
|
reference: 'REF-PQ-018',
|
||||||
|
date: '2025-09-18',
|
||||||
|
dueDate: '2025-09-29',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 5300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'PQ-019',
|
||||||
|
vendorName: 'Eko Prabowo',
|
||||||
|
vendorCompany: 'PT Mandiri Jaya',
|
||||||
|
reference: 'REF-PQ-019',
|
||||||
|
date: '2025-09-19',
|
||||||
|
dueDate: '2025-09-30',
|
||||||
|
status: 'Open',
|
||||||
|
total: 9500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'PQ-020',
|
||||||
|
vendorName: 'Novi Astuti',
|
||||||
|
vendorCompany: 'UD Sinar Harapan',
|
||||||
|
reference: 'REF-PQ-020',
|
||||||
|
date: '2025-09-20',
|
||||||
|
dueDate: '2025-10-01',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 4200000
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,484 @@
|
|||||||
|
import { VendorDebsPayedType, VendorTransactionType, VendorType } from '@/types/apps/vendorTypes'
|
||||||
|
|
||||||
|
export const vendorDummyData: VendorType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
photo: '',
|
||||||
|
name: 'Budi Santoso',
|
||||||
|
company: 'PT Maju Bersama Sejahtera',
|
||||||
|
email: 'budi.santoso@majubersama.co.id',
|
||||||
|
telephone: '+62 21 5551234',
|
||||||
|
youPayable: 25500000,
|
||||||
|
theyPayable: 12300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
photo: '',
|
||||||
|
name: 'Siti Nurhaliza',
|
||||||
|
company: 'CV Berkah Mandiri',
|
||||||
|
email: 'siti.nurhaliza@berkahmandiri.com',
|
||||||
|
telephone: '+62 22 8887654',
|
||||||
|
youPayable: 18750000,
|
||||||
|
theyPayable: 8950000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
photo: '',
|
||||||
|
name: 'Ahmad Wijaya',
|
||||||
|
company: 'PT Teknologi Nusantara',
|
||||||
|
email: 'ahmad.wijaya@teknusantara.co.id',
|
||||||
|
telephone: '+62 24 3332211',
|
||||||
|
youPayable: 42100000,
|
||||||
|
theyPayable: 15600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
photo: '',
|
||||||
|
name: 'Dewi Sartika',
|
||||||
|
company: 'UD Sumber Rejeki',
|
||||||
|
email: 'dewi.sartika@sumberrejeki.net',
|
||||||
|
telephone: '+62 31 4445566',
|
||||||
|
youPayable: 9800000,
|
||||||
|
theyPayable: 22100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
photo: '',
|
||||||
|
name: 'Rudi Hermawan',
|
||||||
|
company: 'PT Indah Karya Persada',
|
||||||
|
email: 'rudi.hermawan@indahkarya.co.id',
|
||||||
|
telephone: '+62 274 7778899',
|
||||||
|
youPayable: 33250000,
|
||||||
|
theyPayable: 5400000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
photo: '',
|
||||||
|
name: 'Maya Sari',
|
||||||
|
company: 'CV Harapan Jaya',
|
||||||
|
email: 'maya.sari@harapanjaya.com',
|
||||||
|
telephone: '+62 261 1112233',
|
||||||
|
youPayable: 16900000,
|
||||||
|
theyPayable: 28750000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
photo: '',
|
||||||
|
name: 'Andi Prasetyo',
|
||||||
|
company: 'PT Cipta Mandiri Utama',
|
||||||
|
email: 'andi.prasetyo@ciptamandiri.co.id',
|
||||||
|
telephone: '+62 411 5556677',
|
||||||
|
youPayable: 21400000,
|
||||||
|
theyPayable: 11850000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
photo: '',
|
||||||
|
name: 'Fitri Ramadhani',
|
||||||
|
company: 'UD Barokah Sukses',
|
||||||
|
email: 'fitri.ramadhani@barokahsukses.net',
|
||||||
|
telephone: '+62 751 9998877',
|
||||||
|
youPayable: 12650000,
|
||||||
|
theyPayable: 19300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
photo: '',
|
||||||
|
name: 'Agus Setiawan',
|
||||||
|
company: 'PT Nusantara Prima',
|
||||||
|
email: 'agus.setiawan@nusantaraprima.co.id',
|
||||||
|
telephone: '+62 541 3334455',
|
||||||
|
youPayable: 38800000,
|
||||||
|
theyPayable: 7200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
photo: '',
|
||||||
|
name: 'Rina Sulastri',
|
||||||
|
company: 'CV Mitra Sejati',
|
||||||
|
email: 'rina.sulastri@mitrasejati.com',
|
||||||
|
telephone: '+62 778 6667788',
|
||||||
|
youPayable: 14300000,
|
||||||
|
theyPayable: 24950000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
photo: '',
|
||||||
|
name: 'Bambang Kurniawan',
|
||||||
|
company: 'PT Harmoni Bersama',
|
||||||
|
email: 'bambang.kurniawan@harmonibersama.co.id',
|
||||||
|
telephone: '+62 21 7779900',
|
||||||
|
youPayable: 29150000,
|
||||||
|
theyPayable: 13750000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
photo: '',
|
||||||
|
name: 'Indah Permatasari',
|
||||||
|
company: 'UD Cahaya Abadi',
|
||||||
|
email: 'indah.permatasari@cahayaabadi.net',
|
||||||
|
telephone: '+62 361 2223344',
|
||||||
|
youPayable: 8900000,
|
||||||
|
theyPayable: 31200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
photo: '',
|
||||||
|
name: 'Dodi Supriadi',
|
||||||
|
company: 'PT Karya Gemilang',
|
||||||
|
email: 'dodi.supriadi@karyagemilang.co.id',
|
||||||
|
telephone: '+62 721 8889911',
|
||||||
|
youPayable: 36700000,
|
||||||
|
theyPayable: 9100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
photo: '',
|
||||||
|
name: 'Lestari Wulandari',
|
||||||
|
company: 'CV Anugrah Sentosa',
|
||||||
|
email: 'lestari.wulandari@anugrahsentosa.com',
|
||||||
|
telephone: '+62 741 4445566',
|
||||||
|
youPayable: 19850000,
|
||||||
|
theyPayable: 16400000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
photo: '',
|
||||||
|
name: 'Hendra Gunawan',
|
||||||
|
company: 'PT Surya Mandala',
|
||||||
|
email: 'hendra.gunawan@suryamandala.co.id',
|
||||||
|
telephone: '+62 511 7778800',
|
||||||
|
youPayable: 27300000,
|
||||||
|
theyPayable: 21650000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
photo: '',
|
||||||
|
name: 'Nurul Hidayah',
|
||||||
|
company: 'UD Rezeki Barokah',
|
||||||
|
email: 'nurul.hidayah@rezekibarokah.net',
|
||||||
|
telephone: '+62 431 1112200',
|
||||||
|
youPayable: 15200000,
|
||||||
|
theyPayable: 26800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
photo: '',
|
||||||
|
name: 'Teguh Prasetyo',
|
||||||
|
company: 'PT Dinamika Persada',
|
||||||
|
email: 'teguh.prasetyo@dinamikapersada.co.id',
|
||||||
|
telephone: '+62 62 5556600',
|
||||||
|
youPayable: 32900000,
|
||||||
|
theyPayable: 12150000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
photo: '',
|
||||||
|
name: 'Sri Mulyani',
|
||||||
|
company: 'CV Berkah Mulia',
|
||||||
|
email: 'sri.mulyani@berkahmulia.com',
|
||||||
|
telephone: '+62 771 3337799',
|
||||||
|
youPayable: 11700000,
|
||||||
|
theyPayable: 29400000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
photo: '',
|
||||||
|
name: 'Joko Widodo',
|
||||||
|
company: 'PT Makmur Sejahtera',
|
||||||
|
email: 'joko.widodo@makmursejahtera.co.id',
|
||||||
|
telephone: '+62 341 8882211',
|
||||||
|
youPayable: 24800000,
|
||||||
|
theyPayable: 18350000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
photo: '',
|
||||||
|
name: 'Ratna Sari',
|
||||||
|
company: 'UD Sari Indah',
|
||||||
|
email: 'ratna.sari@sariindah.net',
|
||||||
|
telephone: '+62 717 9990011',
|
||||||
|
youPayable: 17950000,
|
||||||
|
theyPayable: 23600000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// Dummy data untuk VendorDebsPayedType
|
||||||
|
export const vendorDebsPayedData: VendorDebsPayedType[] = [
|
||||||
|
{
|
||||||
|
date: '2024-08-15',
|
||||||
|
transaction: 'Hutang ke PT Supplier Bahan Kimia',
|
||||||
|
reference: 'DEBT-001-2024',
|
||||||
|
total: 4500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-08-22',
|
||||||
|
transaction: 'Invoice Belum Dibayar #INV-2024-789',
|
||||||
|
reference: 'DEBT-002-2024',
|
||||||
|
total: 2750000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-08-30',
|
||||||
|
transaction: 'Tagihan CV Mitra Sejahtera',
|
||||||
|
reference: 'DEBT-003-2024',
|
||||||
|
total: 1850000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-05',
|
||||||
|
transaction: 'Hutang Pembelian Peralatan Kantor',
|
||||||
|
reference: 'DEBT-004-2024',
|
||||||
|
total: 3200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-08',
|
||||||
|
transaction: 'Tagihan Listrik & Utilities Bulan Lalu',
|
||||||
|
reference: 'DEBT-005-2024',
|
||||||
|
total: 950000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-10',
|
||||||
|
transaction: 'Hutang ke PT Konstruksi Prima',
|
||||||
|
reference: 'DEBT-006-2024',
|
||||||
|
total: 12500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-12',
|
||||||
|
transaction: 'Invoice Jasa Konsultasi IT',
|
||||||
|
reference: 'DEBT-007-2024',
|
||||||
|
total: 6800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-15',
|
||||||
|
transaction: 'Tagihan Bahan Baku Produksi',
|
||||||
|
reference: 'DEBT-008-2024',
|
||||||
|
total: 8900000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-18',
|
||||||
|
transaction: 'Hutang ke Supplier Packaging',
|
||||||
|
reference: 'DEBT-009-2024',
|
||||||
|
total: 2100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-20',
|
||||||
|
transaction: 'Invoice Maintenance Equipment',
|
||||||
|
reference: 'DEBT-010-2024',
|
||||||
|
total: 4300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-22',
|
||||||
|
transaction: 'Tagihan Jasa Logistik & Pengiriman',
|
||||||
|
reference: 'DEBT-011-2024',
|
||||||
|
total: 1650000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-25',
|
||||||
|
transaction: 'Hutang Pembelian Software License',
|
||||||
|
reference: 'DEBT-012-2024',
|
||||||
|
total: 5400000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-28',
|
||||||
|
transaction: 'Invoice Jasa Cleaning Service',
|
||||||
|
reference: 'DEBT-013-2024',
|
||||||
|
total: 750000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-30',
|
||||||
|
transaction: 'Tagihan Sewa Gedung Bulan September',
|
||||||
|
reference: 'DEBT-014-2024',
|
||||||
|
total: 15000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-10-01',
|
||||||
|
transaction: 'Hutang ke CV Digital Marketing',
|
||||||
|
reference: 'DEBT-015-2024',
|
||||||
|
total: 3800000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const vendorReceivablesData: VendorDebsPayedType[] = [
|
||||||
|
{
|
||||||
|
date: '2024-08-20',
|
||||||
|
transaction: 'Piutang dari PT Mitra Sejahtera Abadi',
|
||||||
|
reference: 'RCV-001-2024',
|
||||||
|
total: 5500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-08-25',
|
||||||
|
transaction: 'Invoice Jual Produk #INV-2024-456',
|
||||||
|
reference: 'RCV-002-2024',
|
||||||
|
total: 3250000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-02',
|
||||||
|
transaction: 'Tagihan ke CV Berkah Mandiri',
|
||||||
|
reference: 'RCV-003-2024',
|
||||||
|
total: 2800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-05',
|
||||||
|
transaction: 'Piutang Penjualan Barang Jadi',
|
||||||
|
reference: 'RCV-004-2024',
|
||||||
|
total: 4200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-08',
|
||||||
|
transaction: 'Invoice Jasa Konsultasi',
|
||||||
|
reference: 'RCV-005-2024',
|
||||||
|
total: 1750000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-10',
|
||||||
|
transaction: 'Tagihan ke PT Digital Solutions',
|
||||||
|
reference: 'RCV-006-2024',
|
||||||
|
total: 8900000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-12',
|
||||||
|
transaction: 'Piutang dari Toko Elektronik Prima',
|
||||||
|
reference: 'RCV-007-2024',
|
||||||
|
total: 2450000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-15',
|
||||||
|
transaction: 'Invoice Penjualan Software License',
|
||||||
|
reference: 'RCV-008-2024',
|
||||||
|
total: 12500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-18',
|
||||||
|
transaction: 'Tagihan Jasa Maintenance Equipment',
|
||||||
|
reference: 'RCV-009-2024',
|
||||||
|
total: 3600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-20',
|
||||||
|
transaction: 'Piutang dari CV Kreatif Media',
|
||||||
|
reference: 'RCV-010-2024',
|
||||||
|
total: 1950000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-22',
|
||||||
|
transaction: 'Invoice Jual Material Konstruksi',
|
||||||
|
reference: 'RCV-011-2024',
|
||||||
|
total: 7200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-25',
|
||||||
|
transaction: 'Tagihan Jasa Pelatihan IT',
|
||||||
|
reference: 'RCV-012-2024',
|
||||||
|
total: 4800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-28',
|
||||||
|
transaction: 'Piutang dari PT Logistik Nusantara',
|
||||||
|
reference: 'RCV-013-2024',
|
||||||
|
total: 5300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-30',
|
||||||
|
transaction: 'Invoice Penjualan Peralatan Kantor',
|
||||||
|
reference: 'RCV-014-2024',
|
||||||
|
total: 2100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-10-02',
|
||||||
|
transaction: 'Tagihan ke Supplier Packaging',
|
||||||
|
reference: 'RCV-015-2024',
|
||||||
|
total: 3850000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const vendorTransactionData: VendorTransactionType[] = [
|
||||||
|
{
|
||||||
|
date: '2024-08-15',
|
||||||
|
transaction: 'Pembelian Bahan Baku Produksi',
|
||||||
|
none: 'PO-001-2024',
|
||||||
|
total: 4500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-08-18',
|
||||||
|
transaction: 'Pembayaran Invoice Supplier',
|
||||||
|
none: 'PAY-001-2024',
|
||||||
|
total: 2750000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-08-22',
|
||||||
|
transaction: 'Penjualan Produk ke Klien',
|
||||||
|
none: 'INV-001-2024',
|
||||||
|
total: 6200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-08-25',
|
||||||
|
transaction: 'Pembelian Peralatan Kantor',
|
||||||
|
none: 'PO-002-2024',
|
||||||
|
total: 1850000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-08-28',
|
||||||
|
transaction: 'Pembayaran Jasa Konsultasi',
|
||||||
|
none: 'PAY-002-2024',
|
||||||
|
total: 3200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-02',
|
||||||
|
transaction: 'Penjualan Software License',
|
||||||
|
none: 'INV-002-2024',
|
||||||
|
total: 8900000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-05',
|
||||||
|
transaction: 'Pembelian Material Konstruksi',
|
||||||
|
none: 'PO-003-2024',
|
||||||
|
total: 12500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-08',
|
||||||
|
transaction: 'Pembayaran Maintenance Equipment',
|
||||||
|
none: 'PAY-003-2024',
|
||||||
|
total: 2450000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-12',
|
||||||
|
transaction: 'Penjualan Jasa Pelatihan',
|
||||||
|
none: 'INV-003-2024',
|
||||||
|
total: 4800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-15',
|
||||||
|
transaction: 'Pembelian Bahan Kimia',
|
||||||
|
none: 'PO-004-2024',
|
||||||
|
total: 3600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-18',
|
||||||
|
transaction: 'Pembayaran Sewa Gedung',
|
||||||
|
none: 'PAY-004-2024',
|
||||||
|
total: 15000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-22',
|
||||||
|
transaction: 'Penjualan Peralatan Elektronik',
|
||||||
|
none: 'INV-004-2024',
|
||||||
|
total: 7200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-25',
|
||||||
|
transaction: 'Pembelian Packaging Materials',
|
||||||
|
none: 'PO-005-2024',
|
||||||
|
total: 1950000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-09-28',
|
||||||
|
transaction: 'Pembayaran Jasa Logistik',
|
||||||
|
none: 'PAY-005-2024',
|
||||||
|
total: 2100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2024-10-01',
|
||||||
|
transaction: 'Penjualan Produk Digital',
|
||||||
|
none: 'INV-005-2024',
|
||||||
|
total: 5300000
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -9,6 +9,8 @@ import orderReducer from '@/redux-store/slices/order'
|
|||||||
import productRecipeReducer from '@/redux-store/slices/productRecipe'
|
import productRecipeReducer from '@/redux-store/slices/productRecipe'
|
||||||
import organizationReducer from '@/redux-store/slices/organization'
|
import organizationReducer from '@/redux-store/slices/organization'
|
||||||
import userReducer from '@/redux-store/slices/user'
|
import userReducer from '@/redux-store/slices/user'
|
||||||
|
import vendorReducer from '@/redux-store/slices/vendor'
|
||||||
|
import discountReducer from '@/redux-store/slices/discount'
|
||||||
|
|
||||||
export const store = configureStore({
|
export const store = configureStore({
|
||||||
reducer: {
|
reducer: {
|
||||||
@@ -19,7 +21,9 @@ export const store = configureStore({
|
|||||||
orderReducer,
|
orderReducer,
|
||||||
productRecipeReducer,
|
productRecipeReducer,
|
||||||
organizationReducer,
|
organizationReducer,
|
||||||
userReducer
|
userReducer,
|
||||||
|
vendorReducer,
|
||||||
|
discountReducer
|
||||||
},
|
},
|
||||||
middleware: getDefaultMiddleware => getDefaultMiddleware({ serializableCheck: false })
|
middleware: getDefaultMiddleware => getDefaultMiddleware({ serializableCheck: false })
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,193 @@
|
|||||||
|
// redux-store/slices/discount.ts
|
||||||
|
|
||||||
|
import { CategoryRuleType, CreateDiscountPayload, ProductRuleType } from '@/types/services/discount'
|
||||||
|
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||||
|
|
||||||
|
// Temporary interfaces for rules before discount is created
|
||||||
|
interface TempProductRule {
|
||||||
|
product_id: string
|
||||||
|
product_name?: string
|
||||||
|
rule_type: ProductRuleType
|
||||||
|
quantity: number
|
||||||
|
free_quantity: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TempCategoryRule {
|
||||||
|
category_id: string
|
||||||
|
category_name?: string
|
||||||
|
rule_type: CategoryRuleType
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DiscountState {
|
||||||
|
discountRequest: CreateDiscountPayload
|
||||||
|
selectedOutlets: string[]
|
||||||
|
productRules: TempProductRule[]
|
||||||
|
categoryRules: TempCategoryRule[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialState: DiscountState = {
|
||||||
|
discountRequest: {
|
||||||
|
campaign_id: '',
|
||||||
|
code: '',
|
||||||
|
name: '',
|
||||||
|
type: 'percentage',
|
||||||
|
value: 0,
|
||||||
|
min_purchase_amount: 0,
|
||||||
|
min_purchase_qty: 0,
|
||||||
|
start_date: '',
|
||||||
|
end_date: '',
|
||||||
|
usage_limit_per_customer: undefined,
|
||||||
|
usage_limit_total: undefined,
|
||||||
|
customer_type: 'all',
|
||||||
|
is_stackable: false,
|
||||||
|
priority: 10
|
||||||
|
},
|
||||||
|
selectedOutlets: [],
|
||||||
|
productRules: [],
|
||||||
|
categoryRules: []
|
||||||
|
}
|
||||||
|
|
||||||
|
const discountSlice = createSlice({
|
||||||
|
name: 'discount',
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
// Set entire discount object
|
||||||
|
setDiscount: (state, action: PayloadAction<CreateDiscountPayload>) => {
|
||||||
|
state.discountRequest = action.payload
|
||||||
|
},
|
||||||
|
|
||||||
|
// Set individual field
|
||||||
|
setDiscountField: (state, action: PayloadAction<{ field: keyof CreateDiscountPayload; value: any }>) => {
|
||||||
|
const { field, value } = action.payload
|
||||||
|
state.discountRequest[field] = value as never
|
||||||
|
},
|
||||||
|
|
||||||
|
// Reset discount to initial state
|
||||||
|
resetDiscount: state => {
|
||||||
|
state.discountRequest = initialState.discountRequest
|
||||||
|
state.selectedOutlets = []
|
||||||
|
state.productRules = []
|
||||||
|
state.categoryRules = []
|
||||||
|
},
|
||||||
|
|
||||||
|
// Outlet management
|
||||||
|
setDiscountOutlets: (state, action: PayloadAction<string[]>) => {
|
||||||
|
state.selectedOutlets = action.payload
|
||||||
|
},
|
||||||
|
|
||||||
|
addDiscountOutlet: (state, action: PayloadAction<string>) => {
|
||||||
|
if (!state.selectedOutlets.includes(action.payload)) {
|
||||||
|
state.selectedOutlets.push(action.payload)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeDiscountOutlet: (state, action: PayloadAction<string>) => {
|
||||||
|
state.selectedOutlets = state.selectedOutlets.filter(id => id !== action.payload)
|
||||||
|
},
|
||||||
|
|
||||||
|
// Product rules management
|
||||||
|
setProductRules: (state, action: PayloadAction<TempProductRule[]>) => {
|
||||||
|
state.productRules = action.payload
|
||||||
|
},
|
||||||
|
|
||||||
|
addProductRule: (state, action: PayloadAction<TempProductRule>) => {
|
||||||
|
state.productRules.push(action.payload)
|
||||||
|
},
|
||||||
|
|
||||||
|
updateProductRule: (state, action: PayloadAction<{ index: number; rule: TempProductRule }>) => {
|
||||||
|
const { index, rule } = action.payload
|
||||||
|
if (index >= 0 && index < state.productRules.length) {
|
||||||
|
state.productRules[index] = rule
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeProductRule: (state, action: PayloadAction<number>) => {
|
||||||
|
state.productRules = state.productRules.filter((_, index) => index !== action.payload)
|
||||||
|
},
|
||||||
|
|
||||||
|
clearProductRules: state => {
|
||||||
|
state.productRules = []
|
||||||
|
},
|
||||||
|
|
||||||
|
// Category rules management
|
||||||
|
setCategoryRules: (state, action: PayloadAction<TempCategoryRule[]>) => {
|
||||||
|
state.categoryRules = action.payload
|
||||||
|
},
|
||||||
|
|
||||||
|
addCategoryRule: (state, action: PayloadAction<TempCategoryRule>) => {
|
||||||
|
state.categoryRules.push(action.payload)
|
||||||
|
},
|
||||||
|
|
||||||
|
updateCategoryRule: (state, action: PayloadAction<{ index: number; rule: TempCategoryRule }>) => {
|
||||||
|
const { index, rule } = action.payload
|
||||||
|
if (index >= 0 && index < state.categoryRules.length) {
|
||||||
|
state.categoryRules[index] = rule
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeCategoryRule: (state, action: PayloadAction<number>) => {
|
||||||
|
state.categoryRules = state.categoryRules.filter((_, index) => index !== action.payload)
|
||||||
|
},
|
||||||
|
|
||||||
|
clearCategoryRules: state => {
|
||||||
|
state.categoryRules = []
|
||||||
|
},
|
||||||
|
|
||||||
|
// Bulk operations
|
||||||
|
clearAllRules: state => {
|
||||||
|
state.productRules = []
|
||||||
|
state.categoryRules = []
|
||||||
|
},
|
||||||
|
|
||||||
|
// Set multiple fields at once
|
||||||
|
setDiscountFields: (state, action: PayloadAction<Partial<CreateDiscountPayload>>) => {
|
||||||
|
state.discountRequest = { ...state.discountRequest, ...action.payload }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export const {
|
||||||
|
setDiscount,
|
||||||
|
setDiscountField,
|
||||||
|
resetDiscount,
|
||||||
|
setDiscountOutlets,
|
||||||
|
addDiscountOutlet,
|
||||||
|
removeDiscountOutlet,
|
||||||
|
setProductRules,
|
||||||
|
addProductRule,
|
||||||
|
updateProductRule,
|
||||||
|
removeProductRule,
|
||||||
|
clearProductRules,
|
||||||
|
setCategoryRules,
|
||||||
|
addCategoryRule,
|
||||||
|
updateCategoryRule,
|
||||||
|
removeCategoryRule,
|
||||||
|
clearCategoryRules,
|
||||||
|
clearAllRules,
|
||||||
|
setDiscountFields
|
||||||
|
} = discountSlice.actions
|
||||||
|
|
||||||
|
export default discountSlice.reducer
|
||||||
|
|
||||||
|
// Selectors (optional but recommended)
|
||||||
|
export const selectDiscountRequest = (state: { discountReducer: DiscountState }) =>
|
||||||
|
state.discountReducer.discountRequest
|
||||||
|
|
||||||
|
export const selectSelectedOutlets = (state: { discountReducer: DiscountState }) =>
|
||||||
|
state.discountReducer.selectedOutlets
|
||||||
|
|
||||||
|
export const selectProductRules = (state: { discountReducer: DiscountState }) => state.discountReducer.productRules
|
||||||
|
|
||||||
|
export const selectCategoryRules = (state: { discountReducer: DiscountState }) => state.discountReducer.categoryRules
|
||||||
|
|
||||||
|
export const selectIsDiscountValid = (state: { discountReducer: DiscountState }) => {
|
||||||
|
const { discountRequest } = state.discountReducer
|
||||||
|
return (
|
||||||
|
discountRequest.campaign_id !== '' &&
|
||||||
|
discountRequest.code !== '' &&
|
||||||
|
discountRequest.name !== '' &&
|
||||||
|
discountRequest.start_date !== '' &&
|
||||||
|
discountRequest.end_date !== '' &&
|
||||||
|
(discountRequest.type === 'free_product' || discountRequest.value > 0)
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// Third-party Imports
|
||||||
|
import type { PayloadAction } from '@reduxjs/toolkit'
|
||||||
|
import { createSlice } from '@reduxjs/toolkit'
|
||||||
|
|
||||||
|
// Type Imports
|
||||||
|
|
||||||
|
// Data Imports
|
||||||
|
import { Vendor } from '../../types/services/vendor'
|
||||||
|
|
||||||
|
const initialState: { currentVendor: Vendor } = {
|
||||||
|
currentVendor: {
|
||||||
|
id: '',
|
||||||
|
organization_id: '',
|
||||||
|
name: '',
|
||||||
|
email: '',
|
||||||
|
phone_number: '',
|
||||||
|
address: '',
|
||||||
|
contact_person: '',
|
||||||
|
tax_number: '',
|
||||||
|
payment_terms: '',
|
||||||
|
notes: '',
|
||||||
|
is_active: true,
|
||||||
|
created_at: '',
|
||||||
|
updated_at: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const VendorSlice = createSlice({
|
||||||
|
name: 'vendor',
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
setVendor: (state, action: PayloadAction<Vendor>) => {
|
||||||
|
state.currentVendor = action.payload
|
||||||
|
},
|
||||||
|
resetVendor: state => {
|
||||||
|
state.currentVendor = initialState.currentVendor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export const { setVendor, resetVendor } = VendorSlice.actions
|
||||||
|
|
||||||
|
export default VendorSlice.reducer
|
||||||
+4
-3
@@ -7,6 +7,7 @@ const getToken = () => {
|
|||||||
|
|
||||||
export const api = axios.create({
|
export const api = axios.create({
|
||||||
baseURL: 'https://api-pos.apskel.id/api/v1',
|
baseURL: 'https://api-pos.apskel.id/api/v1',
|
||||||
|
// baseURL: 'http://127.0.0.1:4000/api/v1',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
@@ -30,9 +31,10 @@ api.interceptors.response.use(
|
|||||||
response => response,
|
response => response,
|
||||||
error => {
|
error => {
|
||||||
const status = error.response?.status
|
const status = error.response?.status
|
||||||
const currentPath = window.location.pathname
|
|
||||||
|
|
||||||
if (status === 401 && !currentPath.endsWith('/login')) {
|
if (status === 401) {
|
||||||
|
localStorage.removeItem('user')
|
||||||
|
localStorage.removeItem('authToken')
|
||||||
window.location.href = '/login'
|
window.location.href = '/login'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,4 +49,3 @@ api.interceptors.response.use(
|
|||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { AccountRequest } from '../queries/chartOfAccountType'
|
||||||
|
|
||||||
|
export const useAccountsMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createAccount = useMutation({
|
||||||
|
mutationFn: async (newAccount: AccountRequest) => {
|
||||||
|
const response = await api.post('/accounts', newAccount)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Account created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['accounts'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateAccount = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: AccountRequest }) => {
|
||||||
|
const response = await api.put(`/accounts/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Account updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['accounts'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteAccount = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/accounts/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Account deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['accounts'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createAccount, updateAccount, deleteAccount }
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import { CampaignRequest, CampaignRuleRequest } from '@/types/services/campaign'
|
||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
export const useCampaignsMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createCampaign = useMutation({
|
||||||
|
mutationFn: async (newCampaign: CampaignRequest) => {
|
||||||
|
const response = await api.post('/marketing/campaigns', newCampaign)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Campaign created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['campaigns'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateCampaign = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: CampaignRequest }) => {
|
||||||
|
const response = await api.put(`/marketing/campaigns/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Campaign updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['campaigns'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteCampaign = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/marketing/campaigns/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Campaign deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['campaigns'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createCampaign, updateCampaign, deleteCampaign }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useCampaignRulesMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createCampaignRule = useMutation({
|
||||||
|
mutationFn: async (newCampaignRule: CampaignRuleRequest) => {
|
||||||
|
const response = await api.post('/marketing/campaign-rules', newCampaignRule)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('CampaignRule created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['campaign-rules/campaign'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateCampaignRule = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: CampaignRuleRequest }) => {
|
||||||
|
const response = await api.put(`/marketing/campaign-rules/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('CampaignRule updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['campaign-rules/campaign'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteCampaignRule = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/marketing/campaign-rules/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('CampaignRule deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['campaign-rules/campaign'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createCampaignRule, updateCampaignRule, deleteCampaignRule }
|
||||||
|
}
|
||||||
@@ -0,0 +1,287 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import {
|
||||||
|
CreateDiscountPayload,
|
||||||
|
UpdateDiscountPayload,
|
||||||
|
AddOutletsPayload,
|
||||||
|
ReplaceOutletsPayload,
|
||||||
|
AddProductRulePayload,
|
||||||
|
UpdateProductRulePayload,
|
||||||
|
AddCategoryRulePayload,
|
||||||
|
UpdateCategoryRulePayload,
|
||||||
|
Discount,
|
||||||
|
DiscountOutlet,
|
||||||
|
ProductRule,
|
||||||
|
CategoryRule
|
||||||
|
} from '@/types/services/discount'
|
||||||
|
|
||||||
|
export const useDiscountsMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createDiscount = useMutation({
|
||||||
|
mutationFn: async (payload: CreateDiscountPayload) => {
|
||||||
|
const response = await api.post('/discounts', payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Discount created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['discounts'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateDiscount = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: UpdateDiscountPayload }) => {
|
||||||
|
const response = await api.put(`/discounts/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Discount updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['discounts'] })
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['discount'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const toggleDiscountStatus = useMutation({
|
||||||
|
mutationFn: async ({ id, isActive }: { id: string; isActive: boolean }) => {
|
||||||
|
const response = await api.patch(`/discounts/${id}/toggle-status`, { is_active: isActive })
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Discount status updated!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['discounts'] })
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['discount'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Status update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteDiscount = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/discounts/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Discount deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['discounts'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const validateDiscount = useMutation({
|
||||||
|
mutationFn: async ({
|
||||||
|
code,
|
||||||
|
purchaseAmount,
|
||||||
|
customerId
|
||||||
|
}: {
|
||||||
|
code: string
|
||||||
|
purchaseAmount: number
|
||||||
|
customerId?: string
|
||||||
|
}) => {
|
||||||
|
const response = await api.post('/discounts/validate', {
|
||||||
|
code,
|
||||||
|
purchase_amount: purchaseAmount,
|
||||||
|
customer_id: customerId
|
||||||
|
})
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.message || 'Validation failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
createDiscount,
|
||||||
|
updateDiscount,
|
||||||
|
toggleDiscountStatus,
|
||||||
|
deleteDiscount,
|
||||||
|
validateDiscount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useDiscountOutletsMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const addOutlets = useMutation({
|
||||||
|
mutationFn: async ({ discountId, payload }: { discountId: string; payload: AddOutletsPayload }) => {
|
||||||
|
const response = await api.post(`/discounts/${discountId}/outlets`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
toast.success('Outlets added successfully!')
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['discount', variables.discountId, 'outlets']
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Add outlets failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const replaceOutlets = useMutation({
|
||||||
|
mutationFn: async ({ discountId, payload }: { discountId: string; payload: ReplaceOutletsPayload }) => {
|
||||||
|
const response = await api.put(`/discounts/${discountId}/outlets`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
toast.success('Outlets replaced successfully!')
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['discount', variables.discountId, 'outlets']
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Replace outlets failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const removeOutlet = useMutation({
|
||||||
|
mutationFn: async ({ discountId, outletId }: { discountId: string; outletId: string }) => {
|
||||||
|
const response = await api.delete(`/discounts/${discountId}/outlets/${outletId}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
toast.success('Outlet removed successfully!')
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['discount', variables.discountId, 'outlets']
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Remove outlet failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { addOutlets, replaceOutlets, removeOutlet }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useProductRulesMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const addProductRule = useMutation({
|
||||||
|
mutationFn: async ({ discountId, payload }: { discountId: string; payload: AddProductRulePayload }) => {
|
||||||
|
const response = await api.post(`/discounts/${discountId}/products`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
toast.success('Product rule added successfully!')
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['discount', variables.discountId, 'product-rules']
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Add product rule failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateProductRule = useMutation({
|
||||||
|
mutationFn: async ({
|
||||||
|
discountId,
|
||||||
|
productRuleId,
|
||||||
|
payload
|
||||||
|
}: {
|
||||||
|
discountId: string
|
||||||
|
productRuleId: string
|
||||||
|
payload: UpdateProductRulePayload
|
||||||
|
}) => {
|
||||||
|
const response = await api.put(`/discounts/${discountId}/products/${productRuleId}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
toast.success('Product rule updated successfully!')
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['discount', variables.discountId, 'product-rules']
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update product rule failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteProductRule = useMutation({
|
||||||
|
mutationFn: async ({ discountId, productRuleId }: { discountId: string; productRuleId: string }) => {
|
||||||
|
const response = await api.delete(`/discounts/${discountId}/products/${productRuleId}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
toast.success('Product rule deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['discount', variables.discountId, 'product-rules']
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete product rule failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { addProductRule, updateProductRule, deleteProductRule }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useCategoryRulesMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const addCategoryRule = useMutation({
|
||||||
|
mutationFn: async ({ discountId, payload }: { discountId: string; payload: AddCategoryRulePayload }) => {
|
||||||
|
const response = await api.post(`/discounts/${discountId}/categories`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
toast.success('Category rule added successfully!')
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['discount', variables.discountId, 'category-rules']
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Add category rule failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateCategoryRule = useMutation({
|
||||||
|
mutationFn: async ({
|
||||||
|
discountId,
|
||||||
|
categoryRuleId,
|
||||||
|
payload
|
||||||
|
}: {
|
||||||
|
discountId: string
|
||||||
|
categoryRuleId: string
|
||||||
|
payload: UpdateCategoryRulePayload
|
||||||
|
}) => {
|
||||||
|
const response = await api.put(`/discounts/${discountId}/categories/${categoryRuleId}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
toast.success('Category rule updated successfully!')
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['discount', variables.discountId, 'category-rules']
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update category rule failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteCategoryRule = useMutation({
|
||||||
|
mutationFn: async ({ discountId, categoryRuleId }: { discountId: string; categoryRuleId: string }) => {
|
||||||
|
const response = await api.delete(`/discounts/${discountId}/categories/${categoryRuleId}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
toast.success('Category rule deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['discount', variables.discountId, 'category-rules']
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete category rule failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { addCategoryRule, updateCategoryRule, deleteCategoryRule }
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { GameRequest } from '@/types/services/game'
|
||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
export const useGamesMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createGame = useMutation({
|
||||||
|
mutationFn: async (newGame: GameRequest) => {
|
||||||
|
const response = await api.post('/marketing/games', newGame)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Game created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['games'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateGame = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: GameRequest }) => {
|
||||||
|
const response = await api.put(`/marketing/games/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Game updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['games'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteGame = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/marketing/games/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Game deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['games'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createGame, updateGame, deleteGame }
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { GamePrizeRequest } from '@/types/services/gamePrize'
|
||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
export const useGamePrizesMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createGamePrize = useMutation({
|
||||||
|
mutationFn: async (newGamePrize: GamePrizeRequest) => {
|
||||||
|
const response = await api.post('/marketing/game-prizes', newGamePrize)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('GamePrize created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['gamePrizes'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateGamePrize = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: GamePrizeRequest }) => {
|
||||||
|
const response = await api.put(`/marketing/game-prizes/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('GamePrize updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['gamePrizes'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteGamePrize = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/marketing/game-prizes/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('GamePrize deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['gamePrizes'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createGamePrize, updateGamePrize, deleteGamePrize }
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { PurchaseOrderRequest, SendPaymentPurchaseOrderRequest } from '@/types/services/purchaseOrder'
|
||||||
|
|
||||||
|
export const usePurchaseOrdersMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createPurchaseOrder = useMutation({
|
||||||
|
mutationFn: async (newPurchaseOrder: PurchaseOrderRequest) => {
|
||||||
|
const response = await api.post('/purchase-orders', newPurchaseOrder)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Purchase Order created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['purchase-orders', 'ingredients'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const sendPaymentPurchaseOrder = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: SendPaymentPurchaseOrderRequest }) => {
|
||||||
|
const response = await api.put(`/purchase-orders/${id}/status/received`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Send Payment Order successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['purchase-orders'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Send Payment Order failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createPurchaseOrder, sendPaymentPurchaseOrder }
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { RewardRequest } from '@/types/services/reward'
|
||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
export const useRewardsMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createReward = useMutation({
|
||||||
|
mutationFn: async (newReward: RewardRequest) => {
|
||||||
|
const response = await api.post('/marketing/rewards', newReward)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Reward created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['rewards'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateReward = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: RewardRequest }) => {
|
||||||
|
const response = await api.put(`/marketing/rewards/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Reward updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['rewards'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteReward = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/marketing/rewards/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Reward deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['rewards'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createReward, updateReward, deleteReward }
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { TierRequest } from '@/types/services/tier'
|
||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
export const useTiersMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createTier = useMutation({
|
||||||
|
mutationFn: async (newTier: TierRequest) => {
|
||||||
|
const response = await api.post('/marketing/tiers', newTier)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Tier created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['tiers'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateTier = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: TierRequest }) => {
|
||||||
|
const response = await api.put(`/marketing/tiers/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Tier updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['tiers'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteTier = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/marketing/tiers/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Tier deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['tiers'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createTier, updateTier, deleteTier }
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { IngredientUnitConverterRequest } from '@/types/services/productRecipe'
|
||||||
|
|
||||||
|
export const useUnitConventorMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createUnitConventer = useMutation({
|
||||||
|
mutationFn: async (newUnitConventer: IngredientUnitConverterRequest) => {
|
||||||
|
const response = await api.post('/unit-converters', newUnitConventer)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('UnitConventer created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['unitConventers'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateUnitConventer = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: IngredientUnitConverterRequest }) => {
|
||||||
|
const response = await api.put(`/unit-converters/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('UnitConventer updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['unit-converters'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteUnitConventer = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/unit-converters/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('UnitConventer deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['unitConventers'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createUnitConventer, updateUnitConventer, deleteUnitConventer }
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { VendorRequest } from '@/types/services/vendor'
|
||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
export const useVendorsMutation = () => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const createVendor = useMutation({
|
||||||
|
mutationFn: async (newVendor: VendorRequest) => {
|
||||||
|
const response = await api.post('/vendors', newVendor)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Vendor created successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['vendors'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateVendor = useMutation({
|
||||||
|
mutationFn: async ({ id, payload }: { id: string; payload: VendorRequest }) => {
|
||||||
|
const response = await api.put(`/vendors/${id}`, payload)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Vendor updated successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['vendors'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Update failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deleteVendor = useMutation({
|
||||||
|
mutationFn: async (id: string) => {
|
||||||
|
const response = await api.delete(`/vendors/${id}`)
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success('Vendor deleted successfully!')
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['vendors'] })
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.response?.data?.errors?.[0]?.cause || 'Delete failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return { createVendor, updateVendor, deleteVendor }
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { Accounts } from '@/types/services/chartOfAccount'
|
||||||
|
|
||||||
|
interface AccountQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAccounts(params: AccountQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<Accounts>({
|
||||||
|
queryKey: ['accounts', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/accounts?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { Campaign, CampaignRule, Campaigns } from '@/types/services/campaign'
|
||||||
|
|
||||||
|
interface CampaignQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCampaigns(params: CampaignQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<Campaigns>({
|
||||||
|
queryKey: ['campaigns', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/marketing/campaigns?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCampaignById(id: string) {
|
||||||
|
return useQuery<Campaign>({
|
||||||
|
queryKey: ['campaigns', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/marketing/campaigns/${id}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCampaignRulesByCampaignId(id: string) {
|
||||||
|
return useQuery<CampaignRule[]>({
|
||||||
|
queryKey: ['campaign-rules/campaign', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/marketing/campaign-rules/campaign/${id}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ interface CategoriesQueryParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useCategories(params: CategoriesQueryParams = {}) {
|
export function useCategories(params: CategoriesQueryParams = {}) {
|
||||||
const { page = 1, limit = 10, search = '', ...filters } = params
|
const { page = 1, limit = 50, search = '', ...filters } = params
|
||||||
|
|
||||||
return useQuery<Categories>({
|
return useQuery<Categories>({
|
||||||
queryKey: ['categories', { page, limit, search, ...filters }],
|
queryKey: ['categories', { page, limit, search, ...filters }],
|
||||||
@@ -30,7 +30,9 @@ export function useCategories(params: CategoriesQueryParams = {}) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const res = await api.get(`/categories?${queryParams.toString()}`)
|
const res = await api.get(`/categories?${queryParams.toString()}`)
|
||||||
return res.data.data
|
const data = res.data.data
|
||||||
|
|
||||||
|
return data
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { ChartOfAccounts } from '@/types/services/chartOfAccount'
|
||||||
|
|
||||||
|
interface ChartOfAccountQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useChartOfAccount(params: ChartOfAccountQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<ChartOfAccounts>({
|
||||||
|
queryKey: ['chart-of-accounts', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/chart-of-accounts?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { ChartOfAccountTypes } from '@/types/services/chartOfAccount'
|
||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
interface ChartOfAccountQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useChartOfAccountTypes(params: ChartOfAccountQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<ChartOfAccountTypes>({
|
||||||
|
queryKey: ['chart-of-account-types', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/chart-of-account-types?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AccountRequest {
|
||||||
|
chart_of_account_id: string
|
||||||
|
name: string
|
||||||
|
number: string
|
||||||
|
account_type: string
|
||||||
|
opening_balance: number
|
||||||
|
description: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import {
|
||||||
|
CategoryRule,
|
||||||
|
Discount,
|
||||||
|
DiscountOutlet,
|
||||||
|
DiscountsResponse,
|
||||||
|
FetchDiscountsParams,
|
||||||
|
ProductRule
|
||||||
|
} from '@/types/services/discount'
|
||||||
|
|
||||||
|
export function useDiscounts(params: FetchDiscountsParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<DiscountsResponse>({
|
||||||
|
queryKey: ['discounts', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/discounts?${queryParams.toString()}`)
|
||||||
|
console.log(res.data.data)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAllDiscounts() {
|
||||||
|
return useQuery<Discount[]>({
|
||||||
|
queryKey: ['discounts', 'all'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get('/discounts?page=1&limit=100')
|
||||||
|
return res.data.discounts
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDiscountsByCampaign(campaignId: string) {
|
||||||
|
return useQuery<Discount[]>({
|
||||||
|
queryKey: ['discounts', 'campaign', campaignId],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/discounts?campaign_id=${campaignId}&limit=100`)
|
||||||
|
return res.data.discounts
|
||||||
|
},
|
||||||
|
enabled: !!campaignId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDiscountById(id: string) {
|
||||||
|
return useQuery<Discount>({
|
||||||
|
queryKey: ['discount', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/discounts/${id}`)
|
||||||
|
return res.data
|
||||||
|
},
|
||||||
|
enabled: !!id,
|
||||||
|
staleTime: 5 * 60 * 1000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDiscountByCode(code: string) {
|
||||||
|
return useQuery<Discount>({
|
||||||
|
queryKey: ['discount', 'code', code],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/discounts/code/${code}`)
|
||||||
|
return res.data
|
||||||
|
},
|
||||||
|
enabled: !!code,
|
||||||
|
staleTime: 5 * 60 * 1000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDiscountOutlets(discountId: string) {
|
||||||
|
return useQuery<DiscountOutlet[]>({
|
||||||
|
queryKey: ['discount', discountId, 'outlets'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/discounts/${discountId}/outlets`)
|
||||||
|
return res.data
|
||||||
|
},
|
||||||
|
enabled: !!discountId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useProductRules(discountId: string) {
|
||||||
|
return useQuery<ProductRule[]>({
|
||||||
|
queryKey: ['discount', discountId, 'product-rules'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/discounts/${discountId}/products`)
|
||||||
|
return res.data
|
||||||
|
},
|
||||||
|
enabled: !!discountId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCategoryRules(discountId: string) {
|
||||||
|
return useQuery<CategoryRule[]>({
|
||||||
|
queryKey: ['discount', discountId, 'category-rules'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/discounts/${discountId}/categories`)
|
||||||
|
return res.data
|
||||||
|
},
|
||||||
|
enabled: !!discountId
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { Game, Games } from '@/types/services/game'
|
||||||
|
|
||||||
|
interface GameQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGames(params: GameQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<Games>({
|
||||||
|
queryKey: ['games', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/marketing/games?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGameById(id: string) {
|
||||||
|
return useQuery<Game>({
|
||||||
|
queryKey: ['games', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/marketing/games/${id}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { GamePrize, GamePrizes } from '@/types/services/gamePrize'
|
||||||
|
|
||||||
|
interface GamePrizeQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGamePrizes(params: GamePrizeQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<GamePrizes>({
|
||||||
|
queryKey: ['gamePrizes', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/marketing/game-prizes?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGamePrizeById(id: string) {
|
||||||
|
return useQuery<GamePrize>({
|
||||||
|
queryKey: ['gamePrizes', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/marketing/game-prizes/${id}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { Ingredients } from '../../types/services/ingredient'
|
import { Ingredients } from '../../types/services/ingredient'
|
||||||
import { api } from '../api'
|
import { api } from '../api'
|
||||||
|
import { Ingredient } from '@/types/services/productRecipe'
|
||||||
|
|
||||||
interface IngredientsQueryParams {
|
interface IngredientsQueryParams {
|
||||||
page?: number
|
page?: number
|
||||||
@@ -34,3 +35,13 @@ export function useIngredients(params: IngredientsQueryParams = {}) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useIngredientById(id: string) {
|
||||||
|
return useQuery<Ingredient>({
|
||||||
|
queryKey: ['ingredients', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/ingredients/${id}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ interface OrdersQueryParams {
|
|||||||
page?: number
|
page?: number
|
||||||
limit?: number
|
limit?: number
|
||||||
search?: string
|
search?: string
|
||||||
|
date_from?: string
|
||||||
|
date_to?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useOrders(params: OrdersQueryParams = {}) {
|
export function useOrders(params: OrdersQueryParams = {}) {
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { PurchaseOrder, PurchaseOrders } from '@/types/services/purchaseOrder'
|
||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
interface PurchaseOrderQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
status?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function usePurchaseOrders(params: PurchaseOrderQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', status = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<PurchaseOrders>({
|
||||||
|
queryKey: ['purchase-orders', { page, limit, search, status, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
queryParams.append('status', status)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/purchase-orders?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function usePurchaseOrderById(id: string) {
|
||||||
|
return useQuery<PurchaseOrder>({
|
||||||
|
queryKey: ['purchase-orders', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/purchase-orders/${id}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { Reward, Rewards } from '@/types/services/reward'
|
||||||
|
|
||||||
|
interface RewardQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRewards(params: RewardQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<Rewards>({
|
||||||
|
queryKey: ['rewards', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/marketing/rewards?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRewardById(id: string) {
|
||||||
|
return useQuery<Reward>({
|
||||||
|
queryKey: ['rewards', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/marketing/rewards/${id}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { Tier, Tiers } from '@/types/services/tier'
|
||||||
|
|
||||||
|
interface TierQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useTiers(params: TierQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<Tiers>({
|
||||||
|
queryKey: ['tiers', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/marketing/tiers?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useTierById(id: string) {
|
||||||
|
return useQuery<Tier>({
|
||||||
|
queryKey: ['tiers', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/marketing/tiers/${id}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { UnitConversion } from '@/types/services/productRecipe'
|
||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
export function useUnitConverterByIngredient(IngredientId: string) {
|
||||||
|
return useQuery<UnitConversion[]>({
|
||||||
|
queryKey: ['unit-converters/ingredient', IngredientId],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/unit-converters/ingredient/${IngredientId}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { api } from '../api'
|
||||||
|
import { Vendor, Vendors } from '@/types/services/vendor'
|
||||||
|
|
||||||
|
interface VendorQueryParams {
|
||||||
|
page?: number
|
||||||
|
limit?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useVendors(params: VendorQueryParams = {}) {
|
||||||
|
const { page = 1, limit = 10, search = '', ...filters } = params
|
||||||
|
|
||||||
|
return useQuery<Vendors>({
|
||||||
|
queryKey: ['vendors', { page, limit, search, ...filters }],
|
||||||
|
queryFn: async () => {
|
||||||
|
const queryParams = new URLSearchParams()
|
||||||
|
|
||||||
|
queryParams.append('page', page.toString())
|
||||||
|
queryParams.append('limit', limit.toString())
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
queryParams.append('search', search)
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(filters).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
queryParams.append(key, value.toString())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await api.get(`/vendors?${queryParams.toString()}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useVendorActive() {
|
||||||
|
return useQuery<Vendor[]>({
|
||||||
|
queryKey: ['vendors/active'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/vendors/active`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useVendorById(id: string) {
|
||||||
|
return useQuery<Vendor>({
|
||||||
|
queryKey: ['vendors', id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get(`/vendors/${id}`)
|
||||||
|
return res.data.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user