feat: custom style list virtual on parent text field not on dialog

This commit is contained in:
Firman Syah 2026-06-25 14:39:56 +07:00
parent a6371b64fa
commit 4e0c6e12f4
2 changed files with 3 additions and 15 deletions

View File

@ -35,7 +35,8 @@ export default function ListVirtual({
helperText, helperText,
filter, filter,
isApiGo = false, isApiGo = false,
multiple multiple,
customSxTextField = {}
}) { }) {
const headersRequest = useApiHeaders(); const headersRequest = useApiHeaders();
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@ -82,8 +83,6 @@ export default function ListVirtual({
); );
const incomingData = res.data || []; const incomingData = res.data || [];
console.log("res", res)
setRows(prev => isAppend ? [...prev, ...incomingData] : incomingData); setRows(prev => isAppend ? [...prev, ...incomingData] : incomingData);
setTotalRecord(res.totalRecord || 0); setTotalRecord(res.totalRecord || 0);
setOffset(currentOffset); setOffset(currentOffset);
@ -97,22 +96,11 @@ export default function ListVirtual({
const handleScroll = (e) => { const handleScroll = (e) => {
const { scrollTop, scrollHeight, clientHeight } = e.currentTarget; const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;
console.log({
scrollTop,
scrollHeight,
clientHeight,
rows: rows.length,
totalRecord,
loading,
});
const isAtBottom = scrollHeight - scrollTop <= clientHeight + 20; const isAtBottom = scrollHeight - scrollTop <= clientHeight + 20;
if (isAtBottom && !loading && rows.length < totalRecord) { if (isAtBottom && !loading && rows.length < totalRecord) {
const nextOffset = offset + lengthData; const nextOffset = offset + lengthData;
console.log("LOAD MORE", nextOffset);
fetchData(search, nextOffset, true); fetchData(search, nextOffset, true);
} }
}; };
@ -241,6 +229,7 @@ export default function ListVirtual({
error={!!error} error={!!error}
onClick={() => !disabled && setOpen(true)} onClick={() => !disabled && setOpen(true)}
sx={{ sx={{
...customSxTextField,
'& .MuiOutlinedInput-root.Mui-error .MuiOutlinedInput-notchedOutline': { '& .MuiOutlinedInput-root.Mui-error .MuiOutlinedInput-notchedOutline': {
borderColor: 'error.main', borderColor: 'error.main',
} }

View File

@ -1,7 +1,6 @@
export const formatApiResponse = (responseOrError) => { export const formatApiResponse = (responseOrError) => {
if (responseOrError?.status) { if (responseOrError?.status) {
const { status, data, message } = responseOrError; const { status, data, message } = responseOrError;
console.log("status", responseOrError.status)
if (status >= 200 && status < 300) { if (status >= 200 && status < 300) {
return { return {