init
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import api from "@/config/config";
|
||||
import { API } from "../../api";
|
||||
import { getUserDto } from "@/interface/admin";
|
||||
|
||||
export const apiGetListUser = async (payload: getUserDto) => {
|
||||
const response = await api.get(API.Admin.GET_LIST_USERS, {
|
||||
params: payload,
|
||||
});
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiChangeRole = async (id: string, payload: any) => {
|
||||
const response = await api.patch(API.Admin.CHANGE_ROLE(id), payload);
|
||||
return response?.data;
|
||||
};
|
||||
export const apiDeleteUser = async (id: string) => {
|
||||
const response = await api.delete(API.Admin.DELETE_USER(id));
|
||||
return response?.data;
|
||||
};
|
||||
export const apiRestoreUser = async (id: string) => {
|
||||
const response = await api.patch(API.Admin.RESTORE_USER(id));
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiGetAllRole = async () => {
|
||||
const response = await api.get(API.Admin.GET_ALL_ROLE);
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiGetUserMedia = async (id: string) => {
|
||||
const response = await api.get(API.Admin.GET_USER_MEDIA(id));
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiUpdateApplicationStatus = async (id: string, payload: any) => {
|
||||
const response = await api.put(API.Admin.UPDATE_APPLICATION_STATUS(id), payload);
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiGetUserById = async (userId: string) => {
|
||||
const response = await api.get(API.Admin.GET_USER_BY_ID(userId));
|
||||
return response?.data;
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
import api from "@/config/config";
|
||||
import { API } from "../../api";
|
||||
|
||||
export const apiCreateOTP = async (email: string) => {
|
||||
const token_type = 2;
|
||||
const response = await api.post(API.Auth.CREATEOTP, {
|
||||
email,
|
||||
token_type
|
||||
});
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiVerifyOTP = async (email: string, token: string) => {
|
||||
const body = { email, token, token_type: 2 };
|
||||
const response = await api.post(API.Auth.VERIFYOTP, body);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiSignUp = async (payload: any) => {
|
||||
const response = await api.post(API.Auth.SIGNUP, payload);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiLogout = async () => {
|
||||
const response = await api.post(API.Auth.LOGOUT);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiSignIn = async (payload: any) => {
|
||||
const response = await api.post(API.Auth.SIGNIN, payload);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiResetPassword = async (payload: any) => {
|
||||
const response = await api.post(API.Auth.FORGOT_PASSWORD, payload);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetCurrentUser = async () => {
|
||||
const response = await api.get(API.User.CURRENT);
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiChangePassword = async (payload: any) => {
|
||||
const response = await api.patch(API.User.CHANGE_PASSWORD, payload);
|
||||
return response?.data;
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
export const statusConfig: Record<string, { container: string; dot: string }> = {
|
||||
PENDING: {
|
||||
container: `
|
||||
bg-amber-50
|
||||
border-amber-200
|
||||
text-amber-700
|
||||
shadow-sm
|
||||
`,
|
||||
dot: "bg-amber-500",
|
||||
},
|
||||
APPROVED: {
|
||||
container: `
|
||||
bg-emerald-50
|
||||
border-emerald-200
|
||||
text-emerald-700
|
||||
shadow-sm
|
||||
`,
|
||||
dot: "bg-emerald-500",
|
||||
},
|
||||
REJECTED: {
|
||||
container: `
|
||||
bg-red-50
|
||||
border-red-200
|
||||
text-red-700
|
||||
shadow-sm
|
||||
`,
|
||||
dot: "bg-red-500",
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
import api from "@/config/config";
|
||||
import { API } from "../../api";
|
||||
|
||||
export const createHistorianCV = async (payload: any) => {
|
||||
const response = await api.post(API.Historian.CREATE_CV, payload);
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiGetUserApplications = async (payload :any) => {
|
||||
const response = await api.get(API.Historian.APPLICATION, { params: payload });
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiDeleteHistorianCV = async (id: number | string) => {
|
||||
const response = await api.delete(API.Historian.DELETE_CV(id));
|
||||
return response?.data;
|
||||
};
|
||||
@@ -0,0 +1,130 @@
|
||||
import api from "@/config/config";
|
||||
import { API } from "../../api";
|
||||
import { payloadPresignedMedia } from "@/interface/media";
|
||||
import axios from "axios";
|
||||
|
||||
export const apiGetCurrentUserMedia = async (
|
||||
payload: payloadPresignedMedia,
|
||||
) => {
|
||||
const response = await api.get(API.Media.PRESIGNED, {
|
||||
params: payload,
|
||||
});
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export type FileType =
|
||||
| "image"
|
||||
| "video"
|
||||
| "audio"
|
||||
| "pdf"
|
||||
| "docx"
|
||||
| "text"
|
||||
| "other";
|
||||
|
||||
export const getFileType = (mime: string): FileType => {
|
||||
if (!mime) return "other";
|
||||
|
||||
if (mime.startsWith("image/")) return "image";
|
||||
if (mime.startsWith("video/")) return "video";
|
||||
if (mime.startsWith("audio/")) return "audio";
|
||||
|
||||
if (mime === "application/pdf") return "pdf";
|
||||
|
||||
if (
|
||||
mime ===
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
||||
)
|
||||
return "docx";
|
||||
|
||||
if (mime.startsWith("text/")) return "text";
|
||||
|
||||
return "other";
|
||||
};
|
||||
|
||||
type PreSignedResponse = {
|
||||
token_id: string;
|
||||
upload_url: string;
|
||||
storage_key: string;
|
||||
signed_headers: Record<string, string>;
|
||||
};
|
||||
|
||||
export const uploadFileToS3 = async (
|
||||
file: File,
|
||||
presigned: PreSignedResponse,
|
||||
) => {
|
||||
const res = await axios.put(presigned.upload_url, file, {
|
||||
headers: {
|
||||
...presigned.signed_headers,
|
||||
"Content-Type": file.type,
|
||||
},
|
||||
});
|
||||
// console.log("Response from S3 upload:", res);
|
||||
};
|
||||
|
||||
export const confirmUpload = async (token_id: string) => {
|
||||
const res = await api.post("/media/presigned/complete", {
|
||||
token_id,
|
||||
});
|
||||
// console.log("Response from confirm upload:", res);
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const uploadMedia = async (file: File) => {
|
||||
const { data: presigned } = await api.get<PreSignedResponse>(
|
||||
"/media/presigned",
|
||||
{
|
||||
params: {
|
||||
fileName: file.name,
|
||||
content_type: file.type,
|
||||
size: file.size,
|
||||
},
|
||||
},
|
||||
);
|
||||
// console.log("Presigned URL:", presigned);
|
||||
|
||||
await uploadFileToS3(file, presigned);
|
||||
|
||||
const media = await confirmUpload(presigned.token_id);
|
||||
// console.log("Media sau khi upload:", media);
|
||||
return media;
|
||||
};
|
||||
|
||||
export const getPresignedUrl = async (file: File) => {
|
||||
const { data: presigned } = await api.get<PreSignedResponse>(
|
||||
"/media/presigned",
|
||||
{
|
||||
params: {
|
||||
fileName: file.name,
|
||||
content_type: file.type,
|
||||
size: file.size,
|
||||
},
|
||||
},
|
||||
);
|
||||
// console.log("Presigned URL:", presigned);
|
||||
return presigned;
|
||||
};
|
||||
|
||||
export const getMediaById = async (mediaId: number | string) => {
|
||||
const response = await api.get(API.Media.GET_MEDIA_BY_ID(mediaId));
|
||||
return response?.data;
|
||||
}
|
||||
|
||||
export const deleteMedia = async (mediaIds: string[]) => {
|
||||
const response = await api.delete(API.Media.DELETE_MEDIA, {
|
||||
data: {
|
||||
media_ids: mediaIds
|
||||
}
|
||||
});
|
||||
return response?.data;
|
||||
}
|
||||
export const deleteMediaById = async (mediaId: string) => {
|
||||
const response = await api.delete(API.Media.DELETE_MEDIA_BY_ID(mediaId));
|
||||
return response?.data;
|
||||
}
|
||||
|
||||
export const getMedia = async (payload: any) => {
|
||||
const response = await api.get(API.Media.GET_MEDIA, {
|
||||
params: payload,
|
||||
});
|
||||
return response?.data;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import api from "@/config/config";
|
||||
import { API } from "../../api";
|
||||
import { Profile } from "@/interface/user";
|
||||
|
||||
export const apiGetCurrentUserMedia = async () => {
|
||||
const response = await api.get(API.User.MEDIA);
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiGetCurrentUserApplications = async () => {
|
||||
const response = await api.get(API.User.APPLICATION);
|
||||
return response?.data;
|
||||
};
|
||||
|
||||
export const apiUpdateUser = async (payload: Profile) => {
|
||||
const response = await api.put(API.User.Update, payload);
|
||||
return response?.data;
|
||||
};
|
||||
Reference in New Issue
Block a user