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"
|
||||
>
|
||||
<Image
|
||||
// src={images[index % 4]}
|
||||
src={
|
||||
img?.contentFileUrl == ""
|
||||
? "/no-image.jpg"
|
||||
: img?.contentFileUrl
|
||||
}
|
||||
unoptimized
|
||||
alt={`humasbanner-${index}`}
|
||||
width={1960}
|
||||
height={1080}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import { useDropzone } from "react-dropzone";
|
|||
import Image from "next/image";
|
||||
import {
|
||||
createAdvertiseById,
|
||||
createMediaFileAdvertise,
|
||||
deleteAdvertise,
|
||||
editAdvertise,
|
||||
editAdvertiseIsActive,
|
||||
|
|
@ -210,6 +211,16 @@ export default function AdvertiseTable(props: { triggerRefresh: boolean }) {
|
|||
error(res?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (files.length > 0) {
|
||||
const formFiles = new FormData();
|
||||
formFiles.append("file", files[0]);
|
||||
const resFile = await createMediaFileAdvertise(
|
||||
Number(values.id),
|
||||
formFiles
|
||||
);
|
||||
}
|
||||
|
||||
close();
|
||||
MySwal.fire({
|
||||
title: "Sukses",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,11 @@ import {
|
|||
getListArticle,
|
||||
} from "@/service/article";
|
||||
import { Article } from "@/types/globals";
|
||||
import { convertDateFormat, convertDateFormatNoTimeV2 } from "@/utils/global";
|
||||
import {
|
||||
convertDateFormat,
|
||||
convertDateFormatNoTime,
|
||||
convertDateFormatNoTimeV2,
|
||||
} from "@/utils/global";
|
||||
import { Button } from "@heroui/button";
|
||||
import {
|
||||
Calendar,
|
||||
|
|
@ -120,6 +124,14 @@ export default function SuggestionsTable() {
|
|||
const [isReply, setIsReply] = useState(false);
|
||||
const [replyValue, setReplyValue] = useState("");
|
||||
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 = {
|
||||
resolver: zodResolver(createArticleSchema),
|
||||
|
|
@ -141,10 +153,20 @@ export default function SuggestionsTable() {
|
|||
|
||||
useEffect(() => {
|
||||
initState();
|
||||
}, [page, showData]);
|
||||
}, [page, showData, feedbackDate]);
|
||||
|
||||
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);
|
||||
setTotalPage(res?.data?.meta?.totalPage);
|
||||
}
|
||||
|
|
@ -541,6 +563,53 @@ export default function SuggestionsTable() {
|
|||
<Button color="primary" className="text-white" onPress={doExport}>
|
||||
Export
|
||||
</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>
|
||||
<Table
|
||||
aria-label="micro issue table"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ export async function getFeedbacks(data: any) {
|
|||
};
|
||||
const pathUrl = `/feedbacks?page=${data?.page || 1}limit=${
|
||||
data?.limit || ""
|
||||
}&message=${data?.search || ""}`;
|
||||
}&message=${data?.search || ""}&startDate=${data.startDate || ""}&endDate=${
|
||||
data.endDate || ""
|
||||
}`;
|
||||
return await httpGet(pathUrl, headers);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue