feat:filter date feedback
This commit is contained in:
parent
048e593670
commit
854994e2c8
|
|
@ -233,13 +233,11 @@ export default function BannerHumasNew() {
|
||||||
className="w-full shrink-0"
|
className="w-full shrink-0"
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
// src={images[index % 4]}
|
|
||||||
src={
|
src={
|
||||||
img?.contentFileUrl == ""
|
img?.contentFileUrl == ""
|
||||||
? "/no-image.jpg"
|
? "/no-image.jpg"
|
||||||
: img?.contentFileUrl
|
: img?.contentFileUrl
|
||||||
}
|
}
|
||||||
unoptimized
|
|
||||||
alt={`humasbanner-${index}`}
|
alt={`humasbanner-${index}`}
|
||||||
width={1960}
|
width={1960}
|
||||||
height={1080}
|
height={1080}
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ import { useDropzone } from "react-dropzone";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import {
|
import {
|
||||||
createAdvertiseById,
|
createAdvertiseById,
|
||||||
|
createMediaFileAdvertise,
|
||||||
deleteAdvertise,
|
deleteAdvertise,
|
||||||
editAdvertise,
|
editAdvertise,
|
||||||
editAdvertiseIsActive,
|
editAdvertiseIsActive,
|
||||||
|
|
@ -210,6 +211,16 @@ export default function AdvertiseTable(props: { triggerRefresh: boolean }) {
|
||||||
error(res?.message);
|
error(res?.message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (files.length > 0) {
|
||||||
|
const formFiles = new FormData();
|
||||||
|
formFiles.append("file", files[0]);
|
||||||
|
const resFile = await createMediaFileAdvertise(
|
||||||
|
Number(values.id),
|
||||||
|
formFiles
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
close();
|
close();
|
||||||
MySwal.fire({
|
MySwal.fire({
|
||||||
title: "Sukses",
|
title: "Sukses",
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,11 @@ import {
|
||||||
getListArticle,
|
getListArticle,
|
||||||
} from "@/service/article";
|
} from "@/service/article";
|
||||||
import { Article } from "@/types/globals";
|
import { Article } from "@/types/globals";
|
||||||
import { convertDateFormat, convertDateFormatNoTimeV2 } from "@/utils/global";
|
import {
|
||||||
|
convertDateFormat,
|
||||||
|
convertDateFormatNoTime,
|
||||||
|
convertDateFormatNoTimeV2,
|
||||||
|
} from "@/utils/global";
|
||||||
import { Button } from "@heroui/button";
|
import { Button } from "@heroui/button";
|
||||||
import {
|
import {
|
||||||
Calendar,
|
Calendar,
|
||||||
|
|
@ -120,6 +124,14 @@ export default function SuggestionsTable() {
|
||||||
const [isReply, setIsReply] = useState(false);
|
const [isReply, setIsReply] = useState(false);
|
||||||
const [replyValue, setReplyValue] = useState("");
|
const [replyValue, setReplyValue] = useState("");
|
||||||
const [totalData, setTotalData] = useState(0);
|
const [totalData, setTotalData] = useState(0);
|
||||||
|
const [feedbackDate, setFeedbackDate] = useState({
|
||||||
|
startDate: parseDate(
|
||||||
|
convertDateFormatNoTimeV2(
|
||||||
|
new Date(new Date().setDate(new Date().getDate() - 7))
|
||||||
|
)
|
||||||
|
),
|
||||||
|
endDate: parseDate(convertDateFormatNoTimeV2(new Date())),
|
||||||
|
});
|
||||||
|
|
||||||
const formOptions = {
|
const formOptions = {
|
||||||
resolver: zodResolver(createArticleSchema),
|
resolver: zodResolver(createArticleSchema),
|
||||||
|
|
@ -141,10 +153,20 @@ export default function SuggestionsTable() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initState();
|
initState();
|
||||||
}, [page, showData]);
|
}, [page, showData, feedbackDate]);
|
||||||
|
|
||||||
async function initState() {
|
async function initState() {
|
||||||
const res = await getFeedbacks({ limit: showData, search: search });
|
const getDate = (data: any) => {
|
||||||
|
return `${data.year}-${data.month < 10 ? `0${data.month}` : data.month}-${
|
||||||
|
data.day < 10 ? `0${data.day}` : data.day
|
||||||
|
}`;
|
||||||
|
};
|
||||||
|
const res = await getFeedbacks({
|
||||||
|
limit: showData,
|
||||||
|
search: search,
|
||||||
|
startDate: getDate(feedbackDate.startDate),
|
||||||
|
endDate: getDate(feedbackDate.endDate),
|
||||||
|
});
|
||||||
getTableNumber(parseInt(showData), res.data?.data);
|
getTableNumber(parseInt(showData), res.data?.data);
|
||||||
setTotalPage(res?.data?.meta?.totalPage);
|
setTotalPage(res?.data?.meta?.totalPage);
|
||||||
}
|
}
|
||||||
|
|
@ -541,6 +563,53 @@ export default function SuggestionsTable() {
|
||||||
<Button color="primary" className="text-white" onPress={doExport}>
|
<Button color="primary" className="text-white" onPress={doExport}>
|
||||||
Export
|
Export
|
||||||
</Button>
|
</Button>
|
||||||
|
<div className=" w-[220px] h-[40px] flex flex-row gap-2 justify-between items-center">
|
||||||
|
<Popover
|
||||||
|
placement="bottom"
|
||||||
|
classNames={{ content: ["!bg-transparent", "p-0"] }}
|
||||||
|
>
|
||||||
|
<PopoverTrigger>
|
||||||
|
<a className="cursor-pointer border-1 px-2 py-2 rounded-xl">
|
||||||
|
{convertDateFormatNoTime(feedbackDate.startDate)}
|
||||||
|
</a>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className="bg-transparent">
|
||||||
|
<Calendar
|
||||||
|
value={feedbackDate.startDate}
|
||||||
|
onChange={(e) =>
|
||||||
|
setFeedbackDate({
|
||||||
|
startDate: e,
|
||||||
|
endDate: feedbackDate.endDate,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
maxValue={feedbackDate.endDate}
|
||||||
|
/>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
|
||||||
|
<Popover
|
||||||
|
placement="bottom"
|
||||||
|
classNames={{ content: ["!bg-transparent", "p-0"] }}
|
||||||
|
>
|
||||||
|
<PopoverTrigger>
|
||||||
|
<a className="cursor-pointer border-1 px-2 py-2 rounded-xl">
|
||||||
|
{convertDateFormatNoTime(feedbackDate.endDate)}
|
||||||
|
</a>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className="bg-transparent">
|
||||||
|
<Calendar
|
||||||
|
value={feedbackDate.endDate}
|
||||||
|
onChange={(e) =>
|
||||||
|
setFeedbackDate({
|
||||||
|
startDate: feedbackDate.startDate,
|
||||||
|
endDate: e,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
minValue={feedbackDate.startDate}
|
||||||
|
/>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Table
|
<Table
|
||||||
aria-label="micro issue table"
|
aria-label="micro issue table"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ export async function getFeedbacks(data: any) {
|
||||||
};
|
};
|
||||||
const pathUrl = `/feedbacks?page=${data?.page || 1}limit=${
|
const pathUrl = `/feedbacks?page=${data?.page || 1}limit=${
|
||||||
data?.limit || ""
|
data?.limit || ""
|
||||||
}&message=${data?.search || ""}`;
|
}&message=${data?.search || ""}&startDate=${data.startDate || ""}&endDate=${
|
||||||
|
data.endDate || ""
|
||||||
|
}`;
|
||||||
return await httpGet(pathUrl, headers);
|
return await httpGet(pathUrl, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue