fix(dm): correction to passing the username over for the importing of the file

This commit is contained in:
2025-10-31 09:41:08 -05:00
parent 1283a63b5f
commit a7a9aa2874
7 changed files with 50 additions and 12 deletions

View File

@@ -2,11 +2,13 @@ import axios from "axios";
import { useRef, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { useAuth } from "@/lib/authClient";
export default function ForecastImport(props: any) {
const fileInputRef: any = useRef(null);
const [posting, setPosting] = useState(false);
const token = localStorage.getItem("auth_token");
//const token = localStorage.getItem("auth_token");
const { session } = useAuth();
//const [fileType, setFileType] = useState("");
const importOrders = async (e: any) => {
const file = e.target.files[0];
@@ -20,6 +22,8 @@ export default function ForecastImport(props: any) {
const formData = new FormData();
formData.append("postForecast", e.target.files[0]);
formData.append("fileType", props.fileType); // extra field
formData.append("username", `${session?.user.username}`);
// console.log(formData);
toast.success("Import started.");
try {
@@ -29,7 +33,6 @@ export default function ForecastImport(props: any) {
{
headers: {
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${token}`,
},
},
);

View File

@@ -2,11 +2,12 @@ import axios from "axios";
import { useRef, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { useAuth } from "@/lib/authClient";
export default function OrderImport(props: any) {
const fileInputRef: any = useRef(null);
const [posting, setPosting] = useState(false);
const token = localStorage.getItem("auth_token");
const { session } = useAuth();
//const [fileType, setFileType] = useState("");
const importOrders = async (e: any) => {
const file = e.target.files[0];
@@ -20,6 +21,7 @@ export default function OrderImport(props: any) {
const formData = new FormData();
formData.append("postOrders", e.target.files[0]);
formData.append("fileType", props.fileType); // extra field
formData.append("username", `${session?.user.username}`);
try {
const response = await axios.post(
@@ -28,7 +30,6 @@ export default function OrderImport(props: any) {
{
headers: {
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${token}`,
},
},
);