Bug fixed

Kahdooie
Hossein Rahmani 2024-01-28 15:49:16 +03:30
parent 7caef19713
commit d97c13b565
3 changed files with 18 additions and 11 deletions

View File

@ -166,10 +166,9 @@ export default function ComplainsDetails({
const checkKey2 = (item: any) => {
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
console.log(dcKey);
if (dcKey != false && dcKey != null) {
if (check) {
localStorage.setItem("privatePassword", dcKey);
localStorage.setItem("privateKey", selectedFile);
}
localStorage.setItem("trackingNumber", item.trackingNumber);

View File

@ -67,7 +67,7 @@ export default function InspectorOperations({
const password = useData((state) => state.data.password);
const possibleOperations = complaintData?.possibleOperationsWithDescription;
const queryClient = useQueryClient();
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
@ -85,10 +85,17 @@ export default function InspectorOperations({
toast("عملیات شما با موفقیت انجام شد. ", {
className: "!bg-green-500 !text-white",
});
const tk = localStorage.getItem("trackingNumber");
// const tk = localStorage.getItem("trackingNumber");
const storedData = JSON.parse(
localStorage.getItem("CompliantData") as string
);
const dcKey = Decrypt(
storedData.cipherKeyInspector,
localStorage.getItem("privateKey") as string
);
updateData({
trackingNumber: complaintData.trackingNumber,
password: key2 ? key2 : (localStorage.getItem("privateKey") as string),
password: key2 ? key2 : dcKey,
});
},
onError: (err: any | string) => {
@ -101,8 +108,11 @@ export default function InspectorOperations({
function onSubmit(data: z.infer<typeof FormSchema>) {
const storedData = JSON.parse(
localStorage.getItem("CompliantData") as string
);
const dcKey = Decrypt(storedData.cipherKeyInspector, key2);
);
const dcKey = Decrypt(
storedData.cipherKeyInspector,
localStorage.getItem("privateKey") as string
);
const formData = new FormData();
formData.append("text", data.text);
formData.append("trackingNumber", complaintData.trackingNumber);
@ -110,10 +120,7 @@ export default function InspectorOperations({
if (data.type) {
formData.append("IsPublic", data.type == "public" ? "true" : "false");
}
formData.append(
"EncodedKey",
key2 ? key2 : (localStorage.getItem("privateKey") as string)
);
formData.append("EncodedKey", key2 ? key2 : dcKey);
if (data?.media && data?.media?.length > 0) {
for (let i = 0; i < data.media.length; i++) {
formData.append("Medias", data.media[i]);

View File

@ -134,6 +134,7 @@ export async function RefreshToken(payload: { token: any; refreshToken: any }) {
} catch (error) {
deleteCookie("Sootzani_Token");
deleteCookie("Sootzani_Refresh_Token");
localStorage.removeItem("privateKey");
window.location.href = "/";
}
}