fix: button create task TA in koorkurator, and fixing any bugs
This commit is contained in:
parent
e7baf52526
commit
1230c219f7
|
|
@ -35,10 +35,19 @@ const TaskTaPage = () => {
|
|||
<CardTitle>
|
||||
<div className="flex flex-col sm:flex-row lg:flex-row lg:items-center">
|
||||
<div className="flex-1 text-xl font-medium text-default-900">
|
||||
{t("tabel", { defaultValue: "Tabel" })} {t("task-ta", { defaultValue: "Task Ta" })}
|
||||
{t("tabel", { defaultValue: "Tabel" })}{" "}
|
||||
{t("task-ta", { defaultValue: "Task Ta" })}
|
||||
</div>
|
||||
<div className="flex-none">
|
||||
{roleId !== 12 && (
|
||||
{/* {roleId !== 12 && (
|
||||
<Link href={"/contributor/task-ta/create"}>
|
||||
<Button color="primary" className="text-white">
|
||||
<UploadIcon size={18} className="mr-2" />
|
||||
{t("create-task", { defaultValue: "Create Task" })}
|
||||
</Button>
|
||||
</Link>
|
||||
)} */}
|
||||
{roleId !== 12 && roleId !== 11 && (
|
||||
<Link href={"/contributor/task-ta/create"}>
|
||||
<Button color="primary" className="text-white">
|
||||
<UploadIcon size={18} className="mr-2" />
|
||||
|
|
|
|||
|
|
@ -479,75 +479,117 @@ export default function FormTaskTaNew() {
|
|||
});
|
||||
};
|
||||
|
||||
async function uploadResumableFile(
|
||||
// async function uploadResumableFile(
|
||||
// idx: number,
|
||||
// id: string,
|
||||
// file: any,
|
||||
// fileTypeId: string,
|
||||
// duration: string
|
||||
// ) {
|
||||
// console.log(idx, id, file, fileTypeId, duration);
|
||||
|
||||
// const resCsrf = await getCsrfToken();
|
||||
// const csrfToken = resCsrf?.data?.token;
|
||||
// const headers = {
|
||||
// "X-XSRF-TOKEN": csrfToken,
|
||||
// };
|
||||
|
||||
// const upload = new Upload(file, {
|
||||
// endpoint: `${process.env.NEXT_PUBLIC_API}/media/file/upload`,
|
||||
// headers: headers,
|
||||
// retryDelays: [0, 3000, 6000, 12_000, 24_000],
|
||||
// chunkSize: 20_000,
|
||||
// metadata: {
|
||||
// mediaid: id,
|
||||
// filename: file.name,
|
||||
// contentType: file.type,
|
||||
// fileTypeId: fileTypeId,
|
||||
// duration,
|
||||
// isWatermark: "true",
|
||||
// },
|
||||
// onBeforeRequest: function (req) {
|
||||
// var xhr = req.getUnderlyingObject();
|
||||
// xhr.withCredentials = true;
|
||||
// },
|
||||
// onError: async (e: any) => {
|
||||
// console.log("Error upload :", e);
|
||||
// error(e);
|
||||
// },
|
||||
// onChunkComplete: (
|
||||
// chunkSize: any,
|
||||
// bytesAccepted: any,
|
||||
// bytesTotal: any
|
||||
// ) => {
|
||||
// // const uploadPersen = Math.floor((bytesAccepted / bytesTotal) * 100);
|
||||
// // progressInfo[idx].percentage = uploadPersen;
|
||||
// // counterUpdateProgress++;
|
||||
// // console.log(counterUpdateProgress);
|
||||
// // setProgressList(progressInfo);
|
||||
// // setCounterProgress(counterUpdateProgress);
|
||||
// },
|
||||
// onSuccess: async () => {
|
||||
// // uploadPersen = 100;
|
||||
// // progressInfo[idx].percentage = 100;
|
||||
// // counterUpdateProgress++;
|
||||
// // setCounterProgress(counterUpdateProgress);
|
||||
// successTodo();
|
||||
// if (fileTypeId == "1") {
|
||||
// setIsImageUploadFinish(true);
|
||||
// } else if (fileTypeId == "2") {
|
||||
// setIsVideoUploadFinish(true);
|
||||
// }
|
||||
// if (fileTypeId == "3") {
|
||||
// setIsTextUploadFinish(true);
|
||||
// }
|
||||
// if (fileTypeId == "4") {
|
||||
// setIsAudioUploadFinish(true);
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
|
||||
// upload.start();
|
||||
// }
|
||||
|
||||
function uploadResumableFile(
|
||||
idx: number,
|
||||
id: string,
|
||||
file: any,
|
||||
fileTypeId: string,
|
||||
duration: string
|
||||
) {
|
||||
console.log(idx, id, file, fileTypeId, duration);
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const resCsrf = await getCsrfToken();
|
||||
const csrfToken = resCsrf?.data?.token;
|
||||
|
||||
const resCsrf = await getCsrfToken();
|
||||
const csrfToken = resCsrf?.data?.token;
|
||||
const headers = {
|
||||
"X-XSRF-TOKEN": csrfToken,
|
||||
};
|
||||
const upload = new Upload(file, {
|
||||
endpoint: `${process.env.NEXT_PUBLIC_API}/media/file/upload`,
|
||||
headers: { "X-XSRF-TOKEN": csrfToken },
|
||||
retryDelays: [0, 3000, 6000, 12_000, 24_000],
|
||||
chunkSize: 20_000,
|
||||
metadata: {
|
||||
mediaid: id,
|
||||
filename: file.name,
|
||||
contentType: file.type,
|
||||
fileTypeId,
|
||||
duration,
|
||||
isWatermark: "true",
|
||||
},
|
||||
onBeforeRequest: function (req) {
|
||||
req.getUnderlyingObject().withCredentials = true;
|
||||
},
|
||||
|
||||
const upload = new Upload(file, {
|
||||
endpoint: `${process.env.NEXT_PUBLIC_API}/media/file/upload`,
|
||||
headers: headers,
|
||||
retryDelays: [0, 3000, 6000, 12_000, 24_000],
|
||||
chunkSize: 20_000,
|
||||
metadata: {
|
||||
mediaid: id,
|
||||
filename: file.name,
|
||||
contentType: file.type,
|
||||
fileTypeId: fileTypeId,
|
||||
duration,
|
||||
isWatermark: "true",
|
||||
},
|
||||
onBeforeRequest: function (req) {
|
||||
var xhr = req.getUnderlyingObject();
|
||||
xhr.withCredentials = true;
|
||||
},
|
||||
onError: async (e: any) => {
|
||||
console.log("Error upload :", e);
|
||||
error(e);
|
||||
},
|
||||
onChunkComplete: (
|
||||
chunkSize: any,
|
||||
bytesAccepted: any,
|
||||
bytesTotal: any
|
||||
) => {
|
||||
// const uploadPersen = Math.floor((bytesAccepted / bytesTotal) * 100);
|
||||
// progressInfo[idx].percentage = uploadPersen;
|
||||
// counterUpdateProgress++;
|
||||
// console.log(counterUpdateProgress);
|
||||
// setProgressList(progressInfo);
|
||||
// setCounterProgress(counterUpdateProgress);
|
||||
},
|
||||
onSuccess: async () => {
|
||||
// uploadPersen = 100;
|
||||
// progressInfo[idx].percentage = 100;
|
||||
// counterUpdateProgress++;
|
||||
// setCounterProgress(counterUpdateProgress);
|
||||
successTodo();
|
||||
if (fileTypeId == "1") {
|
||||
setIsImageUploadFinish(true);
|
||||
} else if (fileTypeId == "2") {
|
||||
setIsVideoUploadFinish(true);
|
||||
}
|
||||
if (fileTypeId == "3") {
|
||||
setIsTextUploadFinish(true);
|
||||
}
|
||||
if (fileTypeId == "4") {
|
||||
setIsAudioUploadFinish(true);
|
||||
}
|
||||
},
|
||||
onError: (e) => {
|
||||
console.log("Error upload:", e);
|
||||
reject(e);
|
||||
},
|
||||
|
||||
onSuccess: () => {
|
||||
resolve(true);
|
||||
},
|
||||
});
|
||||
|
||||
upload.start();
|
||||
});
|
||||
|
||||
upload.start();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue