Prettier format pending files
This commit is contained in:
parent
5fd2bf5890
commit
4a2384f087
1 changed files with 37 additions and 29 deletions
|
|
@ -51,7 +51,9 @@ export default async function handler(req: any, res: any) {
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (!adminCheck?.is_admin) {
|
if (!adminCheck?.is_admin) {
|
||||||
return res.status(403).json({ error: "Only admins can view verification requests" });
|
return res
|
||||||
|
.status(403)
|
||||||
|
.json({ error: "Only admins can view verification requests" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const query_builder = supabase
|
const query_builder = supabase
|
||||||
|
|
@ -85,7 +87,13 @@ export default async function handler(req: any, res: any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method === "POST") {
|
if (method === "POST") {
|
||||||
const { action, request_id, rejection_reason, submission_notes, portfolio_links } = body;
|
const {
|
||||||
|
action,
|
||||||
|
request_id,
|
||||||
|
rejection_reason,
|
||||||
|
submission_notes,
|
||||||
|
portfolio_links,
|
||||||
|
} = body;
|
||||||
const authUser = req.headers["x-user-id"];
|
const authUser = req.headers["x-user-id"];
|
||||||
|
|
||||||
if (!authUser) {
|
if (!authUser) {
|
||||||
|
|
@ -102,7 +110,9 @@ export default async function handler(req: any, res: any) {
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (existingRequest) {
|
if (existingRequest) {
|
||||||
return res.status(400).json({ error: "You already have a pending verification request" });
|
return res
|
||||||
|
.status(400)
|
||||||
|
.json({ error: "You already have a pending verification request" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create verification request
|
// Create verification request
|
||||||
|
|
@ -121,14 +131,12 @@ export default async function handler(req: any, res: any) {
|
||||||
if (requestError) throw requestError;
|
if (requestError) throw requestError;
|
||||||
|
|
||||||
// Log the submission
|
// Log the submission
|
||||||
await supabase
|
await supabase.from("ethos_verification_audit_log").insert({
|
||||||
.from("ethos_verification_audit_log")
|
request_id: request.id,
|
||||||
.insert({
|
action: "submitted",
|
||||||
request_id: request.id,
|
actor_id: authUser,
|
||||||
action: "submitted",
|
notes: "Artist submitted verification request",
|
||||||
actor_id: authUser,
|
});
|
||||||
notes: "Artist submitted verification request",
|
|
||||||
});
|
|
||||||
|
|
||||||
return res.status(201).json({ data: request });
|
return res.status(201).json({ data: request });
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +150,9 @@ export default async function handler(req: any, res: any) {
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (!adminCheck?.is_admin) {
|
if (!adminCheck?.is_admin) {
|
||||||
return res.status(403).json({ error: "Only admins can approve verification" });
|
return res
|
||||||
|
.status(403)
|
||||||
|
.json({ error: "Only admins can approve verification" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: request, error: updateError } = await supabase
|
const { data: request, error: updateError } = await supabase
|
||||||
|
|
@ -165,14 +175,12 @@ export default async function handler(req: any, res: any) {
|
||||||
.eq("user_id", request.user_id);
|
.eq("user_id", request.user_id);
|
||||||
|
|
||||||
// Log the approval
|
// Log the approval
|
||||||
await supabase
|
await supabase.from("ethos_verification_audit_log").insert({
|
||||||
.from("ethos_verification_audit_log")
|
request_id,
|
||||||
.insert({
|
action: "approved",
|
||||||
request_id,
|
actor_id: authUser,
|
||||||
action: "approved",
|
notes: "Artist verified by admin",
|
||||||
actor_id: authUser,
|
});
|
||||||
notes: "Artist verified by admin",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Send verification email
|
// Send verification email
|
||||||
const { data: userData } = await supabase
|
const { data: userData } = await supabase
|
||||||
|
|
@ -233,7 +241,9 @@ export default async function handler(req: any, res: any) {
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (!adminCheck?.is_admin) {
|
if (!adminCheck?.is_admin) {
|
||||||
return res.status(403).json({ error: "Only admins can reject verification" });
|
return res
|
||||||
|
.status(403)
|
||||||
|
.json({ error: "Only admins can reject verification" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: request, error: updateError } = await supabase
|
const { data: request, error: updateError } = await supabase
|
||||||
|
|
@ -251,14 +261,12 @@ export default async function handler(req: any, res: any) {
|
||||||
if (updateError) throw updateError;
|
if (updateError) throw updateError;
|
||||||
|
|
||||||
// Log the rejection
|
// Log the rejection
|
||||||
await supabase
|
await supabase.from("ethos_verification_audit_log").insert({
|
||||||
.from("ethos_verification_audit_log")
|
request_id,
|
||||||
.insert({
|
action: "rejected",
|
||||||
request_id,
|
actor_id: authUser,
|
||||||
action: "rejected",
|
notes: rejection_reason,
|
||||||
actor_id: authUser,
|
});
|
||||||
notes: rejection_reason,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Send rejection email
|
// Send rejection email
|
||||||
const { data: userData } = await supabase
|
const { data: userData } = await supabase
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue