fix(dm): correction to passing the username over for the importing of the file
This commit is contained in:
@@ -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}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user