316 lines
7.2 KiB
TypeScript
316 lines
7.2 KiB
TypeScript
import { httpPost, httpGet, httpPut } from "./http-config/http-base-service";
|
|
import {
|
|
httpPostInterceptor,
|
|
httpGetInterceptor,
|
|
httpPutInterceptor,
|
|
httpDeleteInterceptor,
|
|
} from "./http-config/http-interceptor-service";
|
|
|
|
// Types
|
|
export interface ApprovalWorkflowStepRequest {
|
|
stepOrder: number;
|
|
stepName: string;
|
|
requiredUserLevelId: number;
|
|
canSkip?: boolean;
|
|
autoApproveAfterHours?: number;
|
|
isActive?: boolean;
|
|
conditionType?: string;
|
|
conditionValue?: string;
|
|
}
|
|
|
|
export interface ClientApprovalSettingsRequest {
|
|
requiresApproval?: boolean;
|
|
autoPublishArticles?: boolean;
|
|
approvalExemptUsers: number[];
|
|
approvalExemptRoles: number[];
|
|
approvalExemptCategories: number[];
|
|
requireApprovalFor: string[];
|
|
skipApprovalFor: string[];
|
|
isActive?: boolean;
|
|
}
|
|
|
|
export interface UpdateApprovalWorkflowWithClientSettingsRequest {
|
|
workflowId: number;
|
|
name: string;
|
|
description: string;
|
|
isActive: boolean;
|
|
isDefault: boolean;
|
|
steps: ApprovalWorkflowStepRequest[];
|
|
clientSettings: {
|
|
approvalExemptCategories: any[];
|
|
approvalExemptRoles: any[];
|
|
approvalExemptUsers: any[];
|
|
autoPublishArticles: boolean;
|
|
isActive: boolean;
|
|
requireApprovalFor: any[];
|
|
requiresApproval: boolean;
|
|
skipApprovalFor: any[];
|
|
};
|
|
}
|
|
|
|
export interface CreateApprovalWorkflowWithClientSettingsRequest {
|
|
name: string;
|
|
description: string;
|
|
isActive?: boolean;
|
|
isDefault?: boolean;
|
|
requiresApproval?: boolean;
|
|
autoPublish?: boolean;
|
|
steps: ApprovalWorkflowStepRequest[];
|
|
clientApprovalSettings: ClientApprovalSettingsRequest;
|
|
}
|
|
|
|
export interface UserLevelsCreateRequest {
|
|
name: string;
|
|
aliasName: string;
|
|
levelNumber: number;
|
|
parentLevelId?: number;
|
|
provinceId?: number;
|
|
group?: string;
|
|
isApprovalActive?: boolean;
|
|
isActive?: boolean;
|
|
}
|
|
|
|
export interface UserLevel {
|
|
id: number;
|
|
name: string;
|
|
aliasName: string;
|
|
levelNumber: number;
|
|
parentLevelId?: number;
|
|
provinceId?: number;
|
|
group?: string;
|
|
isApprovalActive: boolean;
|
|
isActive: boolean;
|
|
createdAt?: string;
|
|
updatedAt?: string;
|
|
}
|
|
|
|
export interface WorkflowStep {
|
|
id: number;
|
|
workflowId: number;
|
|
stepOrder: number;
|
|
stepName: string;
|
|
requiredUserLevelId: number;
|
|
canSkip: boolean;
|
|
autoApproveAfterHours?: number;
|
|
isActive: boolean;
|
|
parentStepId?: number;
|
|
conditionType: string;
|
|
conditionValue: string;
|
|
isParallel: boolean;
|
|
branchName?: string;
|
|
branchOrder?: number;
|
|
clientId: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
workflow?: any;
|
|
requiredUserLevel?: any;
|
|
parentStep?: any;
|
|
childSteps?: any;
|
|
}
|
|
|
|
export interface ApprovalWorkflow {
|
|
id: number;
|
|
name: string;
|
|
description: string;
|
|
isDefault: boolean;
|
|
isActive: boolean;
|
|
requiresApproval: boolean;
|
|
autoPublish: boolean;
|
|
clientId: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
steps: WorkflowStep[];
|
|
}
|
|
|
|
export interface ComprehensiveWorkflowStep {
|
|
id: number;
|
|
workflowId: number;
|
|
stepOrder: number;
|
|
stepName: string;
|
|
requiredUserLevelId: number;
|
|
requiredUserLevelName: string;
|
|
canSkip: boolean;
|
|
autoApproveAfterHours?: number;
|
|
isActive: boolean;
|
|
parentStepId?: number;
|
|
parentStepName?: string;
|
|
conditionType: string;
|
|
conditionValue: string;
|
|
isParallel: boolean;
|
|
branchName?: string;
|
|
branchOrder?: number;
|
|
hasChildren: boolean;
|
|
isFirstStep: boolean;
|
|
isLastStep: boolean;
|
|
}
|
|
|
|
export interface ComprehensiveWorkflow {
|
|
id: number;
|
|
name: string;
|
|
description: string;
|
|
isDefault: boolean;
|
|
isActive: boolean;
|
|
requiresApproval: boolean;
|
|
autoPublish: boolean;
|
|
clientId: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
totalSteps: number;
|
|
activeSteps: number;
|
|
hasBranches: boolean;
|
|
maxStepOrder: number;
|
|
}
|
|
|
|
export interface ClientSettings {
|
|
id: number;
|
|
clientId: string;
|
|
requiresApproval: boolean;
|
|
defaultWorkflowId: number;
|
|
defaultWorkflowName: string;
|
|
autoPublishArticles: boolean;
|
|
approvalExemptUsers?: any;
|
|
approvalExemptRoles?: any;
|
|
approvalExemptCategories?: any;
|
|
requireApprovalFor?: any;
|
|
skipApprovalFor?: any;
|
|
isActive: boolean;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
exemptUsersDetails: any[];
|
|
exemptRolesDetails: any[];
|
|
exemptCategoriesDetails: any[];
|
|
}
|
|
|
|
export interface WorkflowStatistics {
|
|
totalArticlesProcessed: number;
|
|
pendingArticles: number;
|
|
approvedArticles: number;
|
|
rejectedArticles: number;
|
|
averageProcessingTime: number;
|
|
mostActiveStep: string;
|
|
lastUsedAt?: string;
|
|
}
|
|
|
|
export interface ComprehensiveWorkflowResponse {
|
|
workflow: ComprehensiveWorkflow;
|
|
steps: ComprehensiveWorkflowStep[];
|
|
clientSettings: ClientSettings;
|
|
relatedData: {
|
|
userLevels: any[];
|
|
};
|
|
statistics: WorkflowStatistics;
|
|
lastUpdated: string;
|
|
}
|
|
|
|
export interface User {
|
|
id: number;
|
|
fullname: string;
|
|
username: string;
|
|
email: string;
|
|
}
|
|
|
|
export interface UserRole {
|
|
id: number;
|
|
roleName: string;
|
|
description?: string;
|
|
}
|
|
|
|
export interface ArticleCategory {
|
|
id: number;
|
|
categoryName: string;
|
|
description?: string;
|
|
}
|
|
|
|
export interface Province {
|
|
id: number;
|
|
prov_name: string;
|
|
}
|
|
|
|
// API Functions
|
|
export async function createApprovalWorkflowWithClientSettings(
|
|
data: CreateApprovalWorkflowWithClientSettingsRequest
|
|
) {
|
|
const url = "approval-workflows/with-client-settings";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function updateApprovalWorkflowWithClientSettings(data: any) {
|
|
const url = "approval-workflows/with-client-settings";
|
|
return httpPutInterceptor(url, data);
|
|
}
|
|
|
|
export async function getUserLevels() {
|
|
const url = "user-levels";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function createUserLevel(data: UserLevelsCreateRequest) {
|
|
const url = "user-levels";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function updateUserLevel(
|
|
id: number,
|
|
data: UserLevelsCreateRequest
|
|
) {
|
|
const url = `user-levels/${id}`;
|
|
return httpPutInterceptor(url, data);
|
|
}
|
|
|
|
export async function deleteUserLevel(id: number) {
|
|
const url = `user-levels/${id}`;
|
|
return httpDeleteInterceptor(url);
|
|
}
|
|
|
|
export async function getUsers() {
|
|
const url = "users";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getUserRoles() {
|
|
const url = "user-roles";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getArticleCategories() {
|
|
const url = "article-categories";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getProvinces() {
|
|
const url = "provinces?limit=100";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getApprovalWorkflows() {
|
|
const url = "approval-workflows";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function updateApprovalWorkflow(
|
|
id: number,
|
|
data: CreateApprovalWorkflowWithClientSettingsRequest
|
|
) {
|
|
const url = `approval-workflows/${id}`;
|
|
return httpPutInterceptor(url, data);
|
|
}
|
|
|
|
export async function deleteApprovalWorkflow(id: number) {
|
|
const url = `approval-workflows/${id}`;
|
|
return httpDeleteInterceptor(url);
|
|
}
|
|
|
|
export async function getApprovalWorkflowComprehensiveDetails() {
|
|
const url = `approval-workflows/comprehensive-details`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
// export async function getApprovalWorkflowComprehensiveDetails(
|
|
// clientId?: string | number
|
|
// ) {
|
|
// const url = clientId
|
|
// ? `approval-workflows/comprehensive-details/${clientId}`
|
|
// : `approval-workflows/comprehensive-details`;
|
|
|
|
// return httpGetInterceptor(url);
|
|
// }
|