First Commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import React from "react";
|
||||
import { api } from "../api";
|
||||
|
||||
export default function Attachments({ jobId }: { jobId: number }) {
|
||||
const upload = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (!e.target.files) return;
|
||||
|
||||
const data = new FormData();
|
||||
|
||||
const files = Array.from(e.target.files) as File[];
|
||||
files.forEach((f) => data.append("files", f));
|
||||
|
||||
data.append("jobId", jobId.toString());
|
||||
|
||||
await api.post("/attachments", data, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<input type="file" multiple onChange={upload} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user