Deep-audit + build-out across all products to fully-usable state; all typecheck clean. - gitgram-web (99): wire Store feature to real endpoints, close 9 gaps - gitgram-backend (100): close 8 flow gaps, document infra-provisioning items - gitgram-mobile (90): fix API base-URL/path mismatch (404s) + copy proximity components into components/proximity wired to real screens; 15 gaps, +react-native-svg - aitm-core (95): wire natural-language CLI flow end-to-end; 11 gaps - aitm-api (97): fix teams metadata runtime bug; copy a2a-js server/client/grpc into src/a2a and wire A2A route; crates.io package search; 8 gaps - aitm-mcp (100): fix A2A client/server card mismatch; 9 gaps - aitm-website (95): build missing docs routes; 9 gaps Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
150 lines
4.0 KiB
TypeScript
150 lines
4.0 KiB
TypeScript
import api from './api';
|
|
|
|
// Report target types
|
|
export type ReportTargetType = 'POST' | 'COMMENT' | 'USER' | 'REEL' | 'STORY';
|
|
|
|
// Report reasons
|
|
export type ReportReason = 'SPAM' | 'HARASSMENT' | 'INAPPROPRIATE' | 'MISINFORMATION' | 'OTHER';
|
|
|
|
// Report status
|
|
export type ReportStatus = 'PENDING' | 'REVIEWING' | 'RESOLVED' | 'DISMISSED';
|
|
|
|
export interface CreateReportData {
|
|
targetType: ReportTargetType;
|
|
targetId: string;
|
|
reason: ReportReason;
|
|
description?: string;
|
|
}
|
|
|
|
export interface Report {
|
|
id: string;
|
|
targetType: ReportTargetType;
|
|
targetId: string;
|
|
reason: ReportReason;
|
|
description?: string;
|
|
status: ReportStatus;
|
|
createdAt: string;
|
|
resolvedAt?: string;
|
|
resolution?: string;
|
|
}
|
|
|
|
export interface ReportResponse {
|
|
message: string;
|
|
reportId: string;
|
|
}
|
|
|
|
export interface MyReportsResponse {
|
|
reports: Report[];
|
|
pagination: {
|
|
page: number;
|
|
limit: number;
|
|
total: number;
|
|
pages: number;
|
|
};
|
|
}
|
|
|
|
// Human-readable reason labels
|
|
export const REPORT_REASON_LABELS: Record<ReportReason, string> = {
|
|
SPAM: 'Spam',
|
|
HARASSMENT: 'Harassment or bullying',
|
|
INAPPROPRIATE: 'Inappropriate content',
|
|
MISINFORMATION: 'False information',
|
|
OTHER: 'Other',
|
|
};
|
|
|
|
// Human-readable reason descriptions
|
|
export const REPORT_REASON_DESCRIPTIONS: Record<ReportReason, string> = {
|
|
SPAM: 'Unwanted commercial content or repetitive posts',
|
|
HARASSMENT: 'Abusive, threatening, or bullying behavior',
|
|
INAPPROPRIATE: 'Nudity, violence, or other inappropriate content',
|
|
MISINFORMATION: 'Deliberately false or misleading information',
|
|
OTHER: 'Something else not listed above',
|
|
};
|
|
|
|
export const reportService = {
|
|
// Submit a new report
|
|
createReport: async (data: CreateReportData): Promise<ReportResponse> => {
|
|
const response = await api.post('/reports', data);
|
|
return response.data;
|
|
},
|
|
|
|
// Get user's submitted reports
|
|
getMyReports: async (page: number = 1, limit: number = 20): Promise<MyReportsResponse> => {
|
|
const response = await api.get('/reports/my-reports', {
|
|
params: { page, limit },
|
|
});
|
|
return response.data;
|
|
},
|
|
|
|
// Get a specific report by ID
|
|
getReport: async (reportId: string): Promise<Report> => {
|
|
const response = await api.get(`/reports/my-reports/${reportId}`);
|
|
return response.data;
|
|
},
|
|
|
|
// Helper: Report a post
|
|
reportPost: async (postId: string, reason: ReportReason, description?: string): Promise<ReportResponse> => {
|
|
return reportService.createReport({
|
|
targetType: 'POST',
|
|
targetId: postId,
|
|
reason,
|
|
description,
|
|
});
|
|
},
|
|
|
|
// Helper: Report a comment
|
|
reportComment: async (commentId: string, reason: ReportReason, description?: string): Promise<ReportResponse> => {
|
|
return reportService.createReport({
|
|
targetType: 'COMMENT',
|
|
targetId: commentId,
|
|
reason,
|
|
description,
|
|
});
|
|
},
|
|
|
|
// Helper: Report a user
|
|
reportUser: async (userId: string, reason: ReportReason, description?: string): Promise<ReportResponse> => {
|
|
return reportService.createReport({
|
|
targetType: 'USER',
|
|
targetId: userId,
|
|
reason,
|
|
description,
|
|
});
|
|
},
|
|
|
|
// Helper: Report a reel
|
|
reportReel: async (reelId: string, reason: ReportReason, description?: string): Promise<ReportResponse> => {
|
|
return reportService.createReport({
|
|
targetType: 'REEL',
|
|
targetId: reelId,
|
|
reason,
|
|
description,
|
|
});
|
|
},
|
|
|
|
// Helper: Report a story
|
|
reportStory: async (storyId: string, reason: ReportReason, description?: string): Promise<ReportResponse> => {
|
|
return reportService.createReport({
|
|
targetType: 'STORY',
|
|
targetId: storyId,
|
|
reason,
|
|
description,
|
|
});
|
|
},
|
|
|
|
// Legacy method for backward compatibility
|
|
submitReport: async (data: {
|
|
category: string;
|
|
description: string;
|
|
email?: string;
|
|
}) => {
|
|
const response = await api.post('/feedback', {
|
|
category: 'report',
|
|
subject: data.category,
|
|
message: data.description,
|
|
email: data.email,
|
|
});
|
|
return response.data;
|
|
},
|
|
};
|