147 lines
3.5 KiB
TypeScript
147 lines
3.5 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 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 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;
|
|
provinceName: string;
|
|
}
|
|
|
|
// API Functions
|
|
export async function createApprovalWorkflowWithClientSettings(data: CreateApprovalWorkflowWithClientSettingsRequest) {
|
|
const url = "approval-workflows/with-client-settings";
|
|
return httpPostInterceptor(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";
|
|
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);
|
|
}
|