Bugs fixed
parent
8e66dada93
commit
525cd00055
|
|
@ -14,7 +14,7 @@ import Footer from "@/components/Footer";
|
|||
import { Swiper, SwiperSlide } from "swiper/react";
|
||||
// Import Swiper styles
|
||||
import "swiper/css";
|
||||
import 'swiper/css/navigation';
|
||||
import "swiper/css/navigation";
|
||||
// import required modules
|
||||
import { Autoplay, Navigation } from "swiper/modules";
|
||||
import { sliderItems } from "@/constants";
|
||||
|
|
@ -74,7 +74,7 @@ export default function Landing() {
|
|||
pagination={{
|
||||
clickable: true,
|
||||
}}
|
||||
modules={[Autoplay , Navigation]}
|
||||
modules={[Autoplay, Navigation]}
|
||||
className="mySwiper w-full h-full"
|
||||
>
|
||||
{data?.length > 0 ? (
|
||||
|
|
@ -148,6 +148,9 @@ export default function Landing() {
|
|||
if (index == 0) {
|
||||
localStorage.setItem("unknown", "true");
|
||||
}
|
||||
if (item.id == 2) {
|
||||
localStorage.removeItemItem("unknown");
|
||||
}
|
||||
}}
|
||||
>
|
||||
<p className="text-xs text-center font-medium text-gray hidden group-hover:flex group-hover:text-white">
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ export default function CitizenLogin() {
|
|||
localStorage.setItem("verificationToken", res);
|
||||
},
|
||||
onError: (err: any | string) => {
|
||||
refetch();
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
|
|
@ -77,7 +78,6 @@ export default function CitizenLogin() {
|
|||
value: data.captcha,
|
||||
},
|
||||
};
|
||||
refetch();
|
||||
loginMutation.mutateAsync(payload);
|
||||
saveData({
|
||||
phoneNumber: data.phoneNumber,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export default function ComplainsDetails({
|
|||
const [open, setOpen] = useState<boolean>(
|
||||
state == "FollowResult" ? false : true
|
||||
);
|
||||
const [password, setPassword] = useState<any>(true);
|
||||
const [password, setPassword] = useState<any>(null);
|
||||
const router = useRouter();
|
||||
const storeData = useData((state) => state.data);
|
||||
let data;
|
||||
|
|
@ -128,7 +128,7 @@ export default function ComplainsDetails({
|
|||
const payload = { ...storeData, password: password };
|
||||
getComplaintMutation.mutate({ Data: payload });
|
||||
};
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
useData.persist.rehydrate();
|
||||
if (state == "FollowResult") {
|
||||
|
|
@ -136,11 +136,17 @@ export default function ComplainsDetails({
|
|||
}
|
||||
}, []);
|
||||
|
||||
if (getComplaintMutation.isSuccess && !Data) {
|
||||
data = getComplaintMutation.data;
|
||||
} else {
|
||||
data = Data;
|
||||
}
|
||||
useEffect(() => {
|
||||
const tk = localStorage.getItem("trackingNumber2");
|
||||
const pw = localStorage.getItem("password2");
|
||||
if (tk && pw) {
|
||||
getComplaintMutation.mutate({
|
||||
Data: { trackingNumber: tk, password: pw },
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
data = getComplaintMutation?.data;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -178,9 +184,9 @@ export default function ComplainsDetails({
|
|||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
{data ? (
|
||||
{getComplaintMutation.data && !getComplaintMutation.isPending ? (
|
||||
<>
|
||||
{state !== "FollowResult" && (
|
||||
{/* {state !== "FollowResult" && (
|
||||
<button
|
||||
onClick={() => router.push("/Account/Complaints")}
|
||||
className="flex gap-1 my-2 cursor-pointer text-blue"
|
||||
|
|
@ -190,7 +196,7 @@ export default function ComplainsDetails({
|
|||
</span>
|
||||
<p>بازگشت</p>
|
||||
</button>
|
||||
)}
|
||||
)} */}
|
||||
|
||||
{/* Editt */}
|
||||
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col">
|
||||
|
|
@ -202,17 +208,20 @@ export default function ComplainsDetails({
|
|||
انجام عملیات
|
||||
</p>
|
||||
<InspectorOperations
|
||||
updateData={() => getComplaintMutation.mutate(storeData)}
|
||||
updateData={(payload) =>
|
||||
getComplaintMutation.mutate({ Data: payload })
|
||||
}
|
||||
role={role}
|
||||
complaintData={data}
|
||||
password={password}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 2 */}
|
||||
<div className="flex flex-col self-stretch w-full gap-2 rounded-lg lg:w-2/3 ">
|
||||
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center lg:sticky top-28">
|
||||
{data.user == null ? (
|
||||
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center">
|
||||
{data?.user == null ? (
|
||||
<>
|
||||
<div className="relative flex flex-col w-full p-5 mt-2 border border-gray-400 rounded-md gap-y-1">
|
||||
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
|
||||
|
|
|
|||
|
|
@ -61,31 +61,26 @@ export default function FollowResult() {
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
const printableContent = "This is the content to be printed.";
|
||||
return (
|
||||
<>
|
||||
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] pt-6 mx-auto">
|
||||
{complaintPrintMutation?.data ? (
|
||||
<>
|
||||
<button
|
||||
onClick={() => router.push("/FollowUp")}
|
||||
className="flex gap-1 cursor-pointer text-blue"
|
||||
>
|
||||
<span>
|
||||
<ArrowRight />
|
||||
</span>
|
||||
<p>بازگشت</p>
|
||||
</button>
|
||||
<ComplainsDetails
|
||||
role="Citizen"
|
||||
state="FollowResult"
|
||||
Data={complaintPrintMutation?.data}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
<>
|
||||
{/* <button
|
||||
onClick={() => router.push("/FollowUp")}
|
||||
className="flex gap-1 cursor-pointer text-blue"
|
||||
>
|
||||
<span>
|
||||
<ArrowRight />
|
||||
</span>
|
||||
<p>بازگشت</p>
|
||||
</button> */}
|
||||
<ComplainsDetails
|
||||
role="Citizen"
|
||||
state="FollowResult"
|
||||
Data={complaintPrintMutation?.data}
|
||||
/>
|
||||
</>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -38,22 +38,17 @@ export default function InspectorOperations({
|
|||
complaintData,
|
||||
role,
|
||||
updateData,
|
||||
password,
|
||||
}: {
|
||||
complaintData: any;
|
||||
role: string;
|
||||
updateData: () => any;
|
||||
updateData: (data: any) => any;
|
||||
password?: string;
|
||||
}) {
|
||||
const FormSchema = z.object({
|
||||
text: z
|
||||
.string({ required_error: "لطفا متن خود را وارد نمایید." })
|
||||
.min(8, {
|
||||
message: "Bio must be at least 8 characters.",
|
||||
})
|
||||
.max(260, {
|
||||
message: "Bio must not be longer than 30 characters.",
|
||||
}),
|
||||
text: z.string({ required_error: "لطفا متن خود را وارد نمایید." }),
|
||||
operation: z.string({
|
||||
required_error: "Please select an email to display.",
|
||||
required_error: "لطفا نوع عملیات را انتخاب نمایید.",
|
||||
}),
|
||||
media: z
|
||||
.custom<FileList>((val) => val instanceof FileList, "Required")
|
||||
|
|
@ -61,12 +56,7 @@ export default function InspectorOperations({
|
|||
.refine((files) => files.length <= 5, `Maximum of 5 File are allowed.`)
|
||||
.nullish(),
|
||||
});
|
||||
const password = useData((state) => state.data.password);
|
||||
const possibleOperations = complaintData?.possibleOperationsWithDescription;
|
||||
const selectOptions = Operations.filter((item, index) =>
|
||||
possibleOperations.includes(index)
|
||||
);
|
||||
|
||||
const form = useForm<z.infer<typeof FormSchema>>({
|
||||
resolver: zodResolver(FormSchema),
|
||||
defaultValues: {
|
||||
|
|
@ -79,12 +69,19 @@ export default function InspectorOperations({
|
|||
|
||||
const OperationMutation = useMutation({
|
||||
mutationKey: ["Operation"],
|
||||
mutationFn:
|
||||
role == "Inspector" ? OperateByInspector : postComplaintsDetails,
|
||||
mutationFn: postComplaintsDetails,
|
||||
onSuccess: (res) => {
|
||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||
className: "!bg-green-500 !text-white",
|
||||
});
|
||||
console.log(complaintData.trackingNumber);
|
||||
console.log(localStorage.getItem("password2") as string);
|
||||
updateData({
|
||||
trackingNumber: complaintData.trackingNumber,
|
||||
password: password
|
||||
? password
|
||||
: (localStorage.getItem("password2") as string),
|
||||
});
|
||||
},
|
||||
onError: (err: any | string) => {
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
|
|
@ -98,7 +95,10 @@ export default function InspectorOperations({
|
|||
formData.append("text", data.text);
|
||||
formData.append("trackingNumber", complaintData.trackingNumber);
|
||||
formData.append("Operation", data.operation);
|
||||
formData.append("password", localStorage.getItem("password2") as string);
|
||||
formData.append(
|
||||
"password",
|
||||
password ? password : (localStorage.getItem("password2") as string)
|
||||
);
|
||||
if (data?.media && data?.media?.length > 0) {
|
||||
for (let i = 0; i < data.media.length; i++) {
|
||||
formData.append("Medias", data.media[i]);
|
||||
|
|
|
|||
|
|
@ -7,49 +7,38 @@ import { twMerge } from "tailwind-merge";
|
|||
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
|
||||
|
||||
export default function Pagination({
|
||||
itemsPerPage,
|
||||
TotalPages,
|
||||
currentPage,
|
||||
PageSize,
|
||||
Page,
|
||||
countPage,
|
||||
length,
|
||||
}: {
|
||||
itemsPerPage?: any;
|
||||
TotalPages?: any;
|
||||
currentPage?: any;
|
||||
PageSize?: number;
|
||||
Page?: any;
|
||||
countPage?: any;
|
||||
length?: any;
|
||||
}) {
|
||||
// Here we use item offsets; we could also use page offsets
|
||||
// following the API or data you're working with.
|
||||
const [itemOffset, setItemOffset] = useState(0);
|
||||
|
||||
// Simulate fetching items from another resources.
|
||||
// (This could be items from props; or items loaded in a local state
|
||||
// from an API endpoint with useEffect and useState)
|
||||
const endOffset = itemOffset + itemsPerPage;
|
||||
|
||||
const currentItems = items.slice(itemOffset, endOffset);
|
||||
const pageCount = Math.ceil(items.length / itemsPerPage);
|
||||
|
||||
// Invoke when user click to request another page.
|
||||
const handlePageClick = (event: any) => {
|
||||
const newOffset = (event.selected * itemsPerPage) % items.length;
|
||||
setItemOffset(newOffset);
|
||||
Page(event.selected);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <Items currentItems={currentItems} /> */}
|
||||
<ReactPaginate
|
||||
breakLabel="..."
|
||||
onPageActive={(e) => console.log(e)}
|
||||
nextLabel={<MdKeyboardArrowLeft className="w-5 h-5 " />}
|
||||
onPageChange={handlePageClick}
|
||||
pageRangeDisplayed={3}
|
||||
pageCount={Math.ceil(countPage / 5)}
|
||||
forcePage={currentPage}
|
||||
pageCount={TotalPages}
|
||||
previousLabel={<MdKeyboardArrowRight className="w-5 h-5 " />}
|
||||
pageClassName=" w-10 h-10 grid place-content-center rounded-lg !text-blue shadow-md"
|
||||
className={twMerge(
|
||||
" flex flex-wrap gap-3 text-sm md:text-base w-full rounded-md p-1 bg-white/30 backdrop-blur-lg justify-center text-blue mt-5 absolute left-0 right-0 bottom-6"
|
||||
" flex flex-wrap gap-3 text-sm md:text-base w-full rounded-md p-2 pb-3 bg-white/30 backdrop-blur-lg justify-center text-blue mt-5 fixed left-0 right-0 bottom-0"
|
||||
)}
|
||||
activeClassName=" bg-blue text-blue shadow-md shadow-main"
|
||||
activeLinkClassName=" text-white w-full p-1 h-full"
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ export default function ProfileDropDown() {
|
|||
saveToken(false);
|
||||
deleteCookie("Sootzani_Refresh_Token");
|
||||
deleteCookie("Sootzani_Token");
|
||||
localStorage.removeItem("password2");
|
||||
localStorage.removeItem("trackingNumber2");
|
||||
router.push("/");
|
||||
};
|
||||
const saveToken = useToken((state) => state.saveToken);
|
||||
|
|
@ -71,7 +73,9 @@ export default function ProfileDropDown() {
|
|||
<DropdownMenuTrigger className=" max-sm:-mr-8 max-sm:text-xs" asChild>
|
||||
<Button variant="outline">
|
||||
{/* {profileData?.title ? profileData?.title : profileData?.userName} */}
|
||||
{profileData?.firstName || profileData?.lastName ? profileData?.firstName +" "+ profileData?.lastName : profileData?.userName}
|
||||
{profileData?.firstName || profileData?.lastName
|
||||
? profileData?.firstName + " " + profileData?.lastName
|
||||
: profileData?.userName}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56 sm:ml-10">
|
||||
|
|
|
|||
|
|
@ -116,9 +116,11 @@ export default function RequestStep2() {
|
|||
onSuccess: (res) => {
|
||||
localStorage.setItem("trackingNumber", res.trackingNumber);
|
||||
localStorage.setItem("password", res.password);
|
||||
localStorage.removeItem("unknown");
|
||||
router.push("/RequestResult");
|
||||
},
|
||||
onError: (err: any | string) => {
|
||||
refetch();
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
|
|
@ -133,9 +135,11 @@ export default function RequestStep2() {
|
|||
localStorage.setItem("password", res.password);
|
||||
localStorage.setItem("registeredAt", res.registeredAt);
|
||||
localStorage.removeItem("authorized");
|
||||
localStorage.removeItem("unknown");
|
||||
router.push("/RequestResult");
|
||||
},
|
||||
onError: (err: any | string) => {
|
||||
refetch();
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
|
|
@ -204,7 +208,6 @@ export default function RequestStep2() {
|
|||
});
|
||||
}
|
||||
|
||||
refetch();
|
||||
resetField("Title");
|
||||
resetField("Text");
|
||||
resetField("Medias");
|
||||
|
|
@ -373,7 +376,6 @@ export default function RequestStep2() {
|
|||
const files: File[] = Array.from(uploadFile);
|
||||
// 2. now you can use array methods on files;
|
||||
filenames = files.map((file) => file?.name);
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ export default function TabController() {
|
|||
const [selectedFile, setSelectedFile] = useState<any>(null);
|
||||
const [page, setPage] = useState<any>(1);
|
||||
const [totalCount, setTotalCount] = useState<any>(0);
|
||||
const [currentPage, setCurrentPage] = useState<any>(0);
|
||||
const [pageSize, setPageSize] = useState<any>(0);
|
||||
const [totalPages, setTotalPages] = useState<any>(0);
|
||||
const router = useRouter();
|
||||
const [search, setSearch] = useState<any>(null);
|
||||
|
||||
|
|
@ -46,6 +49,9 @@ export default function TabController() {
|
|||
if (data) {
|
||||
const headersData = JSON.parse(data.headers["x-pagination"]);
|
||||
setTotalCount(headersData.TotalCount);
|
||||
setTotalPages(headersData.TotalPages);
|
||||
setCurrentPage(headersData.CurrentPage);
|
||||
setPageSize(headersData.PageSize);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
|
|
@ -55,11 +61,15 @@ export default function TabController() {
|
|||
|
||||
return (
|
||||
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9">
|
||||
<Link href="/RequestStep2">
|
||||
<Button className=" bg-blue hover:bg-blue/90 rounded-lg max-sm:text-xs">
|
||||
ثبت درخواست
|
||||
</Button>
|
||||
</Link>
|
||||
<Button
|
||||
onClick={() => {
|
||||
router.push("/RequestStep2");
|
||||
localStorage.removeItemItem("unknown");
|
||||
}}
|
||||
className=" bg-blue hover:bg-blue/90 rounded-lg max-sm:text-xs"
|
||||
>
|
||||
ثبت درخواست
|
||||
</Button>
|
||||
|
||||
<Search
|
||||
value={search}
|
||||
|
|
@ -69,6 +79,8 @@ export default function TabController() {
|
|||
/>
|
||||
<TableController data={data?.data} />
|
||||
<Pagination
|
||||
TotalPages={totalPages}
|
||||
currentPage={currentPage - 1}
|
||||
countPage={totalCount}
|
||||
Page={(num: number) => setPage(num + 1)}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ export default function TableController({ data }: { data: Complaint[] }) {
|
|||
|
||||
return (
|
||||
<div>
|
||||
<Table className="border-[1px] border-solid border-muted rounded-md ">
|
||||
<Table className="border-[1px] border-solid border-muted rounded-md mb-20">
|
||||
{/* <TableCaption>A list of your recent invoices.</TableCaption> */}
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
|
|
@ -122,7 +122,6 @@ export default function TableController({ data }: { data: Complaint[] }) {
|
|||
: "-"}
|
||||
</TableCell>
|
||||
{/* </Link> */}
|
||||
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "sootzani",
|
||||
"version": "0.1.9",
|
||||
"version": "0.1.10",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sootzani",
|
||||
"version": "0.1.9",
|
||||
"version": "0.1.10",
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^3.3.2",
|
||||
"@radix-ui/react-alert-dialog": "^1.0.5",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "sootzani",
|
||||
"version": "0.1.9",
|
||||
"version": "0.1.10",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export async function getComplaints({
|
|||
states = 0,
|
||||
TrackingNumber,
|
||||
PageNumber = 1,
|
||||
PageSize = 5,
|
||||
PageSize = 10,
|
||||
}: {
|
||||
states?: number;
|
||||
TrackingNumber?: string;
|
||||
|
|
|
|||
Loading…
Reference in New Issue