form builder service and hooks
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import axios from "@/config/axios";
|
||||
import type {
|
||||
CreateFieldType,
|
||||
CreateFieldValueType,
|
||||
FieldDetailResponseType,
|
||||
FieldResponseType,
|
||||
FieldValueDetailResponseType,
|
||||
FieldValuesResponseType,
|
||||
} from "../types/Types";
|
||||
|
||||
export const createField = async (id: number, params: CreateFieldType) => {
|
||||
const { data } = await axios.post(`/admin/entity/${id}/field`, params);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getFields = async (id: number) => {
|
||||
const { data } = await axios.get<FieldResponseType>(
|
||||
`/admin/entity/${id}/field`,
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getFieldDetail = async (id: number) => {
|
||||
const { data } = await axios.get<FieldDetailResponseType>(
|
||||
`/admin/entity/field/${id}`,
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const updateField = async (id: number, params: CreateFieldType) => {
|
||||
const { data } = await axios.patch(`/admin/entity/field/${id}`, params);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const deleteFields = async (id: number) => {
|
||||
const { data } = await axios.delete(`/admin/entity/field/${id}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getFieldValues = async (id: number) => {
|
||||
const { data } = await axios.get<FieldValuesResponseType>(
|
||||
`/admin/entity/field/${id}/option`,
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const createFieldValues = async (
|
||||
id: number,
|
||||
params: CreateFieldValueType,
|
||||
) => {
|
||||
const { data } = await axios.post(`/admin/entity/field/${id}/option`, params);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const updateFieldValues = async (
|
||||
id: number,
|
||||
params: CreateFieldValueType,
|
||||
) => {
|
||||
const { data } = await axios.patch(
|
||||
`/admin/entity/field/option/${id}`,
|
||||
params,
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getFieldValueDetail = async (id: number) => {
|
||||
const { data } = await axios.get<FieldValueDetailResponseType>(
|
||||
`/admin/entity/field/option/${id}`,
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const deleteFieldValue = async (id: number) => {
|
||||
const { data } = await axios.delete(`/admin/entity/field/option/${id}`);
|
||||
return data;
|
||||
};
|
||||
Reference in New Issue
Block a user