reactstrap-react-lib
Advanced tools
Comparing version
/// <reference types="react" /> | ||
import { AxiosError, AxiosResponse, AxiosRequestConfig } from 'axios'; | ||
import { RequestMethods } from "./types"; | ||
interface Props { | ||
/**This API uri for deleteing Post request */ | ||
curUri: string; | ||
import { propMaster } from "../Interfaces/interfaces"; | ||
interface Props extends propMaster { | ||
/**id is value by which the record has to be deleted */ | ||
id: any; | ||
/** | ||
* This function is call back on success from server HTTP response | ||
* @res This on success response from server | ||
*/ | ||
onSuccess: (res: AxiosResponse, successCallBack?: (...arg: any) => any) => string; | ||
/** | ||
* This is props as callback function to passesed inside onSuccess function | ||
*/ | ||
successCallBack?: (...arg: any) => any; | ||
/** | ||
* This function is call back on error from server HTTP response | ||
* @error error eecived from server | ||
*/ | ||
onError: (error: AxiosError, errorCallback?: (...arg: any) => any) => string; | ||
/** | ||
* This is props as a callback function to passesed inside onError function | ||
*/ | ||
errorCallback?: (...arg: any) => any; | ||
/** | ||
* This function is for validation before submitting in the form | ||
* In case of failed validadtion return string which is not equal to "" | ||
* If validation did succeed then return "" | ||
*/ | ||
validation?: () => string; | ||
/** | ||
* THis is form submit method | ||
* value could be "GET" | "POST" | "PUT" | "DELETE" | ||
*/ | ||
method?: RequestMethods; | ||
/** | ||
* AxiosRequestConfig optional config to be passed in the api call | ||
*/ | ||
AxiosRequestConfig?: AxiosRequestConfig; | ||
} | ||
declare function Delete({ curUri, id, onSuccess, onError, successCallBack, errorCallback, validation, method, AxiosRequestConfig }: Props): JSX.Element; | ||
declare function Delete({ curUri, curObj, onSuccess, onError, successCallBack, errorCallback, validation, AxiosRequestConfig }: Props): JSX.Element; | ||
export default Delete; | ||
//# sourceMappingURL=FormDelete.d.ts.map |
@@ -40,7 +40,7 @@ "use strict"; | ||
const ModelP_1 = __importDefault(require("../ModelP")); | ||
function Delete({ curUri, id, onSuccess, onError, successCallBack, errorCallback, validation = () => "", method = "POST", AxiosRequestConfig = {} }) { | ||
function Delete({ curUri, curObj, onSuccess, onError, successCallBack, errorCallback, validation = () => "", AxiosRequestConfig = {} }) { | ||
const butRef = react_1.useRef(null); | ||
const modRef = react_1.useRef(null); | ||
const alerRef = react_1.useRef(null); | ||
const submitHandle = (_curUri, _id, _onSuccess, _onError, _validation) => __awaiter(this, void 0, void 0, function* () { | ||
const submitHandle = (_curUri, _curObj, _onSuccess, _onError, _validation) => __awaiter(this, void 0, void 0, function* () { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j; | ||
@@ -52,3 +52,2 @@ let validationErrorMessage = ""; | ||
(_c = alerRef.current) === null || _c === void 0 ? void 0 : _c.alertLight(); | ||
let _curObj = { id: _id }; | ||
validationErrorMessage = _validation(); | ||
@@ -62,9 +61,9 @@ if (validationErrorMessage !== "") { | ||
let res; | ||
if (method === "GET") { | ||
if (_curObj[0] === "GET") { | ||
res = yield axios_1.default.get(_curUri, AxiosRequestConfig).then(res => res); | ||
} | ||
else if (method === "DELETE") { | ||
else if (_curObj[0] === "DELETE") { | ||
res = yield axios_1.default.delete(_curUri, AxiosRequestConfig).then(res => res); | ||
} | ||
else if (method === "PUT") { | ||
else if (_curObj[0] === "PUT") { | ||
res = yield axios_1.default.put(_curUri, _curObj, AxiosRequestConfig).then(res => res); | ||
@@ -91,3 +90,3 @@ } | ||
var _a; | ||
submitHandle(curUri, id, onSuccess, onError, validation); | ||
submitHandle(curUri, curObj, onSuccess, onError, validation); | ||
(_a = modRef.current) === null || _a === void 0 ? void 0 : _a.close(); | ||
@@ -94,0 +93,0 @@ }, modelTitle: "Do you want to delete data ?", modelText: "Press Ok to delete data from server \n Press cancel to exit" }), |
@@ -1,49 +0,9 @@ | ||
import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
import { ReactFragment } from 'react'; | ||
import { RequestMethods } from "./types"; | ||
interface Props { | ||
/** req.body for post request */ | ||
curObj: {}; | ||
/**API rroute uri for post request */ | ||
curUri: string; | ||
import { propMaster } from "../Interfaces/interfaces"; | ||
interface Props extends propMaster { | ||
/**This is Form input elements. do not add Form elemet thise get rendered inside the form itself */ | ||
Inputs: ReactFragment; | ||
/** pass function with reseting the values i.e. curObj and etc */ | ||
reset: () => void; | ||
/** | ||
* This function is call back on success from server HTTP response | ||
* @res This on success response from server | ||
*/ | ||
onSuccess: (res: AxiosResponse, successCallBack?: (...arg: any) => any) => string; | ||
/** | ||
* This is props as callback function to passesed inside onSuccess function | ||
*/ | ||
successCallBack?: (...arg: any) => any; | ||
/** | ||
* This function is call back on error from server HTTP response | ||
* @error error eecived from server | ||
*/ | ||
onError: (error: AxiosError, errorCallback?: (...arg: any) => any) => string; | ||
/** | ||
* This is props as a callback function to passesed inside onError function | ||
*/ | ||
errorCallback?: (...arg: any) => any; | ||
/** | ||
* This function is for validation before submitting in the form | ||
* In case of failed validadtion return string which is not equal to "" | ||
* If validation did succeed then return "" | ||
*/ | ||
validation?: () => string; | ||
/** | ||
* THis is form submit method | ||
* value could be "GET" | "POST" | "PUT" | "DELETE" | ||
*/ | ||
method?: RequestMethods; | ||
/** | ||
* AxiosRequestConfig optional config to be passed in the api call | ||
*/ | ||
AxiosRequestConfig?: AxiosRequestConfig; | ||
} | ||
declare const FormSubmit: ({ curObj, curUri, Inputs, reset, onSuccess, onError, successCallBack, errorCallback, validation, method, AxiosRequestConfig }: Props) => JSX.Element; | ||
declare const FormSubmit: ({ curObj, curUri, Inputs, reset, onSuccess, onError, successCallBack, errorCallback, validation, AxiosRequestConfig }: Props) => JSX.Element; | ||
export default FormSubmit; | ||
//# sourceMappingURL=FormSubmit.d.ts.map |
@@ -40,3 +40,3 @@ "use strict"; | ||
const ModelP_1 = __importDefault(require("../ModelP")); | ||
const FormSubmit = ({ curObj, curUri, Inputs, reset, onSuccess, onError, successCallBack, errorCallback, validation = () => "", method = "POST", AxiosRequestConfig = {} }) => { | ||
const FormSubmit = ({ curObj, curUri, Inputs, reset, onSuccess, onError, successCallBack, errorCallback, validation = () => "", AxiosRequestConfig = {} }) => { | ||
const butRef = react_1.useRef(null); | ||
@@ -59,14 +59,14 @@ const modRef = react_1.useRef(null); | ||
let res; | ||
if (method === "GET") { | ||
if (_curObj[0] === "GET") { | ||
res = yield axios_1.default.get(_curUri, AxiosRequestConfig).then(res => res); | ||
} | ||
else if (method === "DELETE") { | ||
else if (_curObj[0] === "DELETE") { | ||
res = yield axios_1.default.delete(_curUri, AxiosRequestConfig).then(res => res); | ||
} | ||
else if (method === "PUT") { | ||
res = yield axios_1.default.put(_curUri, _curObj, AxiosRequestConfig).then(res => res); | ||
else if (_curObj[0] === "PUT") { | ||
res = yield axios_1.default.put(_curUri, _curObj[1], AxiosRequestConfig).then(res => res); | ||
} | ||
else { | ||
// default method | ||
res = yield axios_1.default.post(_curUri, _curObj, AxiosRequestConfig).then(res => res); | ||
// default method POST | ||
res = yield axios_1.default.post(_curUri, _curObj[1], AxiosRequestConfig).then(res => res); | ||
} | ||
@@ -73,0 +73,0 @@ let _successMessage = _onSuccess(res, successCallBack); |
{ | ||
"name": "reactstrap-react-lib", | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"description": "This is a lib for react and next", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
104345
24.53%71
24.56%1726
23.11%