import { sendFetch, PageProps } from './index'
import { ResPage } from './type'
import { organizationTypeEnum } from '@/store/organization'
import * as URL from "./URL";

// 

export type OrganizationType = {
    ancestors: string
    contact: string
    orderNum: number
    orgId: number
    parentId: number
    orgName: string
    password: string
    type: organizationTypeEnum | null
    userName: string
    confirmPwd?: string,
    msgAuthCode?: string

}

export const addOrgFetch = (params: Partial<OrganizationType>) =>
    sendFetch<PageProps<OrganizationType>>(URL.addOrganization, {
        method: "post",
        body: JSON.stringify(params),
    });
export const alterOrgFetch = (params: Partial<OrganizationType>) =>
    sendFetch<PageProps<OrganizationType>>(URL.alterOrganization, {
        method: "post",
        body: JSON.stringify(params),
    });
export const delOrgFetch = (params: Partial<OrganizationType>) =>
    sendFetch<PageProps<OrganizationType>>(URL.delOrganization, {
        method: "post",
        body: JSON.stringify(params),
    });
export const getOrgListFetch = (params: PageProps<Partial<OrganizationType>>) =>
    sendFetch<ResPage<PageProps<OrganizationType>>>(URL.organizationPage, {
        method: "post",
        body: JSON.stringify(params),
    });

