Bugs after test fixed

Kahdooie
Hossein Rahmani 2024-01-07 20:45:40 +03:30
parent b5dde6be4d
commit ead91d08ea
11 changed files with 107 additions and 75 deletions

View File

@ -5,7 +5,7 @@ export default function page({ params }: { params: any }) {
const id = params.id; const id = params.id;
return ( return (
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] mt-16 sm:mt-8 pt-9 mx-auto mb-10"> <div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] mt-10 sm:mt-8 pt-9 mx-auto mb-10">
<ComplainsDetails role="Inspector" id={id} /> <ComplainsDetails role="Inspector" id={id} />
</div> </div>
); );

View File

@ -16,15 +16,16 @@ import secureLocalStorage from "react-secure-storage";
import { Checkbox } from "./ui/checkbox"; import { Checkbox } from "./ui/checkbox";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { import {
Dialog, AlertDialog,
DialogClose, AlertDialogAction,
DialogContent, AlertDialogCancel,
DialogDescription, AlertDialogContent,
DialogFooter, AlertDialogDescription,
DialogHeader, AlertDialogFooter,
DialogTitle, AlertDialogHeader,
DialogTrigger, AlertDialogTitle,
} from "@/components/ui/dialog"; AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Input } from "./ui/input"; import { Input } from "./ui/input";
import { toast } from "sonner"; import { toast } from "sonner";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
@ -175,24 +176,25 @@ export default function ComplainsDetails({
data = getComplaintMutation?.data; data = getComplaintMutation?.data;
return ( return (
<> <>
<Dialog open={open} onOpenChange={setOpen}> <AlertDialog open={open} onOpenChange={setOpen}>
<DialogContent dir="rtl" className=""> <AlertDialogContent dir="rtl" className="">
<DialogHeader dir="rtl"> <AlertDialogHeader dir="rtl">
<DialogTitle dir="rtl">بارگذاری کلید خصوصی</DialogTitle> <AlertDialogTitle dir="rtl">بارگذاری کلید خصوصی</AlertDialogTitle>
<DialogDescription> <AlertDialogDescription>
برای مشاهده شکایت لطفا کلید خود را آپلود نمایید. برای مشاهده شکایت لطفا کلید خود را آپلود نمایید.
</DialogDescription> </AlertDialogDescription>
</DialogHeader> </AlertDialogHeader>
<div className="grid w-full max-w-sm items-center gap-1.5"> <div className="grid w-full max-w-sm items-center gap-1.5 px-8">
<Input <Input
dir="rtl" dir="rtl"
id="picture" id="picture"
onChange={handleFileChange} onChange={handleFileChange}
type="file" type="file"
accept=".txt" accept=".txt"
className=" bg-white hover:bg-white focus:bg-white"
/> />
</div> </div>
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2 px-8">
<Checkbox <Checkbox
checked={check} checked={check}
onCheckedChange={setCheck} onCheckedChange={setCheck}
@ -206,14 +208,15 @@ export default function ComplainsDetails({
ذخیره کلید برای دفعات بعد ذخیره کلید برای دفعات بعد
</label> </label>
</div> </div>
<DialogFooter className=" flex !justify-between"> <AlertDialogFooter className=" gap-y-2 max-md:w-full max-md:flex max-md:flex-col">
{/* <DialogClose asChild></DialogClose> */} {/* <DialogClose asChild></DialogClose> */}
<Button <Button
variant="outline" variant="outline"
onClick={() => { onClick={() => {
router.push("/UserPanel/Complaints"); router.push("/UserPanel/ControllerDashboard/Complaints");
}} }}
type="submit" type="submit"
className=" md:ml-2"
> >
بازگشت بازگشت
</Button> </Button>
@ -226,13 +229,15 @@ export default function ComplainsDetails({
> >
ذخیره ذخیره
</Button> </Button>
</DialogFooter> </AlertDialogFooter>
</DialogContent> </AlertDialogContent>
</Dialog> </AlertDialog>
{getComplaintMutation.data && !getComplaintMutation.isPending ? ( {getComplaintMutation.data && !getComplaintMutation.isPending ? (
<> <>
<button <button
onClick={() => router.push("/UserPanel/Complaints")} onClick={() =>
router.push("/UserPanel/ControllerDashboard/Complaints")
}
className=" my-2 flex gap-1 cursor-pointer text-blue " className=" my-2 flex gap-1 cursor-pointer text-blue "
> >
<span> <span>

View File

@ -76,7 +76,6 @@ export default function InspectorOperations({
possibleOperations.length == 1 possibleOperations.length == 1
? String(possibleOperations[0].value) ? String(possibleOperations[0].value)
: undefined, : undefined,
text: "",
}, },
}); });
@ -88,7 +87,10 @@ export default function InspectorOperations({
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
const tk = localStorage.getItem("trackingNumber"); const tk = localStorage.getItem("trackingNumber");
updateData({ trackingNumber: tk, password: key2 }); updateData({
trackingNumber: tk,
password: key2 ? key2 : (localStorage.getItem("privateKey") as string),
});
}, },
onError: (err) => {}, onError: (err) => {},
}); });
@ -107,7 +109,10 @@ export default function InspectorOperations({
if (data.type) { if (data.type) {
formData.append("IsPublic", data.type == "public" ? "true" : "false"); formData.append("IsPublic", data.type == "public" ? "true" : "false");
} }
formData.append("EncodedKey", key2); formData.append(
"EncodedKey",
key2 ? key2 : (localStorage.getItem("privateKey") as string)
);
if (data?.media && data?.media?.length > 0) { if (data?.media && data?.media?.length > 0) {
for (let i = 0; i < data.media.length; i++) { for (let i = 0; i < data.media.length; i++) {
formData.append("Medias", data.media[i]); formData.append("Medias", data.media[i]);

View File

@ -27,6 +27,7 @@ import { Oval, ThreeDots } from "react-loader-spinner";
import useData from "@/store/useData"; import useData from "@/store/useData";
import { toast } from "sonner"; import { toast } from "sonner";
import { errorMessages } from "@/constants"; import { errorMessages } from "@/constants";
import { RefreshCcw } from "lucide-react";
const FormSchema = z.object({ const FormSchema = z.object({
username: z.string().min(1, { username: z.string().min(1, {
message: "لطفا نام کاربری را وارد نمایید.", message: "لطفا نام کاربری را وارد نمایید.",
@ -101,7 +102,7 @@ export default function Login() {
className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040] className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
h-fit" h-fit"
> >
<div className="space-y-3 md:space-y-4 flex flex-col md:py-10 md:px-12 lg:px-16 h-full justify-center"> <div className="space-y-3 md:space-y-4 flex flex-col md:py-10 p-10 md:px-12 lg:px-16 h-full justify-center">
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " /> <Image alt="icon" src={LoginIcon} className="self-center w-1/3 " />
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white"> <p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
@ -157,7 +158,7 @@ export default function Login() {
</FormItem> </FormItem>
)} )}
/> />
<div className="flex gap-4 mt-4 items-center"> <div className="flex gap-3 mt-4 items-center">
<FormField <FormField
control={form.control} control={form.control}
name="captcha" name="captcha"
@ -188,7 +189,7 @@ export default function Login() {
/> />
</div> </div>
) : ( ) : (
<div className=" flex justify-center text-center"> <div className=" flex items-center justify-center text-center gap-2">
<Image <Image
alt="icon" alt="icon"
src={srcForImage as string} src={srcForImage as string}
@ -197,6 +198,11 @@ export default function Login() {
height={20} height={20}
quality={100} quality={100}
/> />
<RefreshCcw
className=" cursor-pointer"
onClick={() => refetch()}
color="#003778"
/>
</div> </div>
)} )}
</div> </div>

View File

@ -132,6 +132,7 @@ export default function NavbarPanel() {
<LogOut <LogOut
onClick={() => { onClick={() => {
deleteCookie("Sootzani_Token"); deleteCookie("Sootzani_Token");
localStorage.removeItem("privateKey");
router.push("/"); router.push("/");
}} }}
className=" text-white cursor-pointer" className=" text-white cursor-pointer"

View File

@ -101,6 +101,7 @@ export default function TableController({
<TableRow> <TableRow>
<TableHead>ردیف</TableHead> <TableHead>ردیف</TableHead>
<TableHead>تاریخ</TableHead> <TableHead>تاریخ</TableHead>
<TableHead>کد پیگیری</TableHead>
<TableHead>موضوع</TableHead> <TableHead>موضوع</TableHead>
<TableHead>دستگاه مربوطه</TableHead> <TableHead>دستگاه مربوطه</TableHead>
</TableRow> </TableRow>
@ -128,10 +129,11 @@ export default function TableController({
<TableCell className="w-2/12"> <TableCell className="w-2/12">
{convertDate(item.registeredAt)} {convertDate(item.registeredAt)}
</TableCell> </TableCell>
<TableCell className="w-2/12">{item.trackingNumber}</TableCell>
<TableCell className="w-2/12"> <TableCell className="w-2/12">
{item?.title ? item.title : "-"} {item?.title ? item.title : "-"}
</TableCell> </TableCell>
<TableCell className="w-7/12"> <TableCell className="w-5/12">
{item?.complaintOrganization {item?.complaintOrganization
? item?.complaintOrganization.title ? item?.complaintOrganization.title
: "-"} : "-"}

View File

@ -11,6 +11,7 @@ import useData from "@/store/useData";
import { JwtPayload, jwtDecode } from "jwt-decode"; import { JwtPayload, jwtDecode } from "jwt-decode";
import { setCookie } from "cookies-next"; import { setCookie } from "cookies-next";
import { Oval } from "react-loader-spinner"; import { Oval } from "react-loader-spinner";
import { toast } from "sonner";
export default function Verify() { export default function Verify() {
const [otp, setOtp] = useState(""); const [otp, setOtp] = useState("");
@ -36,7 +37,11 @@ export default function Verify() {
router.push("/UserPanel/CitizenDashboard"); router.push("/UserPanel/CitizenDashboard");
} }
}, },
onError: (err: any) => {}, onError: (err: any) => {
toast("کد تایید شما صحیح نمیباشد.", {
className: "!bg-red-500 !text-white",
});
},
}); });
const CitizenVerifyMutation = useMutation({ const CitizenVerifyMutation = useMutation({
mutationFn: verifyCitizen, mutationFn: verifyCitizen,
@ -68,6 +73,14 @@ export default function Verify() {
useData.persist.rehydrate(); useData.persist.rehydrate();
}, []); }, []);
useEffect(() => {
if (otp.length == 6) {
const payload = { ...userData, verificationCode: otp };
console.log(userData);
verifyMutation.mutate(payload);
}
}, [otp]);
return ( return (
<div className=" w-screen h-screen grid place-content-center bg-gray-200"> <div className=" w-screen h-screen grid place-content-center bg-gray-200">
<div <div
@ -86,11 +99,7 @@ export default function Verify() {
numInputs={6} numInputs={6}
renderSeparator={<span>{space}</span>} renderSeparator={<span>{space}</span>}
renderInput={(props, idx) => ( renderInput={(props, idx) => (
<input <input autoFocus={idx == 0} pattern="[0-9]*" {...props} />
autoFocus={idx == 0}
pattern="[0-9]*"
{...props}
/>
)} )}
containerStyle=" flex justify-center" containerStyle=" flex justify-center"
inputStyle=" !w-10 rounded-md h-10 bg-[#F5F5F5] border border-blue/30 text-black" inputStyle=" !w-10 rounded-md h-10 bg-[#F5F5F5] border border-blue/30 text-black"
@ -101,7 +110,7 @@ export default function Verify() {
کد دریافت شده توسط پیامک را وارد نمایید. کد دریافت شده توسط پیامک را وارد نمایید.
</span> </span>
</label> </label>
<div className="flex justify-end gap-2 w-full mt-14"> {/* <div className="flex justify-end gap-2 w-full mt-14">
<Button <Button
disabled={verifyMutation.isPending} disabled={verifyMutation.isPending}
onClick={handelVerify} onClick={handelVerify}
@ -119,13 +128,12 @@ export default function Verify() {
wrapperStyle={{}} wrapperStyle={{}}
wrapperClass="" wrapperClass=""
/> />
{/* <p>در حال انجام ...</p> */}
</div> </div>
) : ( ) : (
"تایید" "تایید"
)} )}
</Button> </Button>
</div> </div> */}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,16 +1,16 @@
"use client" "use client";
import * as React from "react" import * as React from "react";
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/button" import { buttonVariants } from "@/components/ui/button";
const AlertDialog = AlertDialogPrimitive.Root const AlertDialog = AlertDialogPrimitive.Root;
const AlertDialogTrigger = AlertDialogPrimitive.Trigger const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
const AlertDialogPortal = AlertDialogPrimitive.Portal const AlertDialogPortal = AlertDialogPrimitive.Portal;
const AlertDialogOverlay = React.forwardRef< const AlertDialogOverlay = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Overlay>, React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
@ -24,8 +24,8 @@ const AlertDialogOverlay = React.forwardRef<
{...props} {...props}
ref={ref} ref={ref}
/> />
)) ));
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
const AlertDialogContent = React.forwardRef< const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>, React.ElementRef<typeof AlertDialogPrimitive.Content>,
@ -36,11 +36,10 @@ const AlertDialogContent = React.forwardRef<
<AlertDialogPrimitive.Content <AlertDialogPrimitive.Content
ref={ref} ref={ref}
className={cn( className={cn(
`fixed left-[50%] top-[50%] z-50 grid w-full max-w-4xl translate-x-[-50%] translate-y-[-50%] gap-4 border duration-200 `fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border duration-200
data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95
data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2
data-[state=open]:slide-in-from-top-[48%] rounded-lg data-[state=open]:slide-in-from-top-[48%] rounded-lg content-between p-0 bg-opacity-30 bg-[#FFFFF999] filter
h-full max-h-[32em] content-between p-0 bg-opacity-30 bg-[#FFFFF999] filter
shadow-[0px_0px_30px_0px_rgba(0,0,0,0.3)] shadow-[0px_0px_30px_0px_rgba(0,0,0,0.3)]
`, `,
className className
@ -48,8 +47,8 @@ const AlertDialogContent = React.forwardRef<
{...props} {...props}
/> />
</AlertDialogPortal> </AlertDialogPortal>
)) ));
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
const AlertDialogHeader = ({ const AlertDialogHeader = ({
className, className,
@ -62,8 +61,8 @@ const AlertDialogHeader = ({
)} )}
{...props} {...props}
/> />
) );
AlertDialogHeader.displayName = "AlertDialogHeader" AlertDialogHeader.displayName = "AlertDialogHeader";
const AlertDialogFooter = ({ const AlertDialogFooter = ({
className, className,
@ -76,8 +75,8 @@ const AlertDialogFooter = ({
)} )}
{...props} {...props}
/> />
) );
AlertDialogFooter.displayName = "AlertDialogFooter" AlertDialogFooter.displayName = "AlertDialogFooter";
const AlertDialogTitle = React.forwardRef< const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>, React.ElementRef<typeof AlertDialogPrimitive.Title>,
@ -85,11 +84,14 @@ const AlertDialogTitle = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Title <AlertDialogPrimitive.Title
ref={ref} ref={ref}
className={cn("text-lg font-semibold bg-white flex justify-between items-center px-6 py-3 rounded-t-lg border-b-[0.5px] border-[#8F8F8F] border-solid", className)} className={cn(
"text-lg font-semibold bg-white flex justify-between items-center px-6 py-3 rounded-t-lg border-b-[0.5px] border-[#8F8F8F] border-solid",
className
)}
{...props} {...props}
/> />
)) ));
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
const AlertDialogDescription = React.forwardRef< const AlertDialogDescription = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Description>, React.ElementRef<typeof AlertDialogPrimitive.Description>,
@ -97,12 +99,15 @@ const AlertDialogDescription = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Description <AlertDialogPrimitive.Description
ref={ref} ref={ref}
className={cn("text-sm text-muted-foreground flex flex-col items-start text-justify px-10 py-4 sm:px-28 sm:pt-9 ", className)} className={cn(
"text-sm text-muted-foreground flex flex-col items-start text-justify px-10 py-4 ",
className
)}
{...props} {...props}
/> />
)) ));
AlertDialogDescription.displayName = AlertDialogDescription.displayName =
AlertDialogPrimitive.Description.displayName AlertDialogPrimitive.Description.displayName;
const AlertDialogAction = React.forwardRef< const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>, React.ElementRef<typeof AlertDialogPrimitive.Action>,
@ -113,8 +118,8 @@ const AlertDialogAction = React.forwardRef<
className={cn(buttonVariants(), className)} className={cn(buttonVariants(), className)}
{...props} {...props}
/> />
)) ));
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
const AlertDialogCancel = React.forwardRef< const AlertDialogCancel = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Cancel>, React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
@ -129,8 +134,8 @@ const AlertDialogCancel = React.forwardRef<
)} )}
{...props} {...props}
/> />
)) ));
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
export { export {
AlertDialog, AlertDialog,
@ -144,4 +149,4 @@ export {
AlertDialogDescription, AlertDialogDescription,
AlertDialogAction, AlertDialogAction,
AlertDialogCancel, AlertDialogCancel,
} };

View File

@ -13,7 +13,7 @@ const Checkbox = React.forwardRef<
<CheckboxPrimitive.Root <CheckboxPrimitive.Root
ref={ref} ref={ref}
className={cn( className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-blue data-[state=checked]:text-primary-foreground",
className className
)} )}
{...props} {...props}

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "sootzani", "name": "sootzani",
"version": "0.2.0", "version": "0.2.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "sootzani", "name": "sootzani",
"version": "0.2.0", "version": "0.2.1",
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.3.2", "@hookform/resolvers": "^3.3.2",
"@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-alert-dialog": "^1.0.5",

View File

@ -1,6 +1,6 @@
{ {
"name": "sootzani", "name": "sootzani",
"version": "0.2.0", "version": "0.2.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",