🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

reactstrap-react-lib

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactstrap-react-lib - npm Package Compare versions

Comparing version

to
1.0.14

lib/lib/forms/Enum.d.ts

20

lib/lib/forms/FormDelete.d.ts
/// <reference types="react" />
import { AxiosError, AxiosResponse } from 'axios';
import { AxiosError, AxiosResponse, AxiosRequestConfig } from 'axios';
import { RequestMethods } from "./types";
interface Props {

@@ -26,5 +27,20 @@ /**This API uri for deleteing Post request */

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 }: Props): JSX.Element;
declare function Delete({ curUri, id, onSuccess, onError, successCallBack, errorCallback, validation, method, AxiosRequestConfig }: Props): JSX.Element;
export default Delete;
//# sourceMappingURL=FormDelete.d.ts.map

40

lib/lib/forms/FormDelete.js

@@ -40,8 +40,9 @@ "use strict";

const ModelP_1 = __importDefault(require("../ModelP"));
function Delete({ curUri, id, onSuccess, onError, successCallBack, errorCallback }) {
function Delete({ curUri, id, onSuccess, onError, successCallBack, errorCallback, validation = () => "", method = "POST", 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) => __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g;
const submitHandle = (_curUri, _id, _onSuccess, _onError, _validation) => __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
let validationErrorMessage = "";
try {

@@ -51,11 +52,32 @@ (_a = modRef.current) === null || _a === void 0 ? void 0 : _a.close();

(_c = alerRef.current) === null || _c === void 0 ? void 0 : _c.alertLight();
let res = yield axios_1.default.post(_curUri, { id: _id }).then(res => res);
let _curObj = { id: _id };
validationErrorMessage = _validation();
if (validationErrorMessage !== "") {
(_d = alerRef.current) === null || _d === void 0 ? void 0 : _d.alertError(validationErrorMessage);
(_e = butRef.current) === null || _e === void 0 ? void 0 : _e.hideSpin();
return;
}
``;
let res;
if (method === "GET") {
res = yield axios_1.default.get(_curUri, AxiosRequestConfig).then(res => res);
}
else if (method === "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 {
// default method
res = yield axios_1.default.post(_curUri, _curObj, AxiosRequestConfig).then(res => res);
}
let _successMessage = _onSuccess(res, successCallBack);
(_d = butRef.current) === null || _d === void 0 ? void 0 : _d.hideSpin();
(_e = alerRef.current) === null || _e === void 0 ? void 0 : _e.alertSuccess(_successMessage);
(_f = butRef.current) === null || _f === void 0 ? void 0 : _f.hideSpin();
(_g = alerRef.current) === null || _g === void 0 ? void 0 : _g.alertSuccess(_successMessage);
}
catch (error) {
let _errorMessage = _onError(error, errorCallback);
(_f = alerRef.current) === null || _f === void 0 ? void 0 : _f.alertError(_errorMessage);
(_g = butRef.current) === null || _g === void 0 ? void 0 : _g.hideSpin();
(_h = alerRef.current) === null || _h === void 0 ? void 0 : _h.alertError(_errorMessage);
(_j = butRef.current) === null || _j === void 0 ? void 0 : _j.hideSpin();
}

@@ -68,3 +90,3 @@ });

var _a;
submitHandle(curUri, id, onSuccess, onError);
submitHandle(curUri, id, onSuccess, onError, validation);
(_a = modRef.current) === null || _a === void 0 ? void 0 : _a.close();

@@ -71,0 +93,0 @@ }, modelTitle: "Do you want to delete data ?", modelText: "Press Ok to delete data from server \n Press cancel to exit" }),

@@ -1,3 +0,4 @@

import { AxiosError, AxiosResponse } from 'axios';
import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
import { ReactFragment } from 'react';
import { RequestMethods } from "./types";
interface Props {

@@ -31,10 +32,19 @@ /** req.body for post request */

/**
* This function is for validation before submitting inthe front end itself
* in case of failed validadtion return string
* If validation did succeed return ""
* 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 }: Props) => JSX.Element;
declare const FormSubmit: ({ curObj, curUri, Inputs, reset, onSuccess, onError, successCallBack, errorCallback, validation, method, 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 = () => "" }) => {
const FormSubmit = ({ curObj, curUri, Inputs, reset, onSuccess, onError, successCallBack, errorCallback, validation = () => "", method = "POST", AxiosRequestConfig = {} }) => {
const butRef = react_1.useRef(null);

@@ -58,3 +58,16 @@ const modRef = react_1.useRef(null);

}
let res = yield axios_1.default.post(_curUri, _curObj).then(res => res);
let res;
if (method === "GET") {
res = yield axios_1.default.get(_curUri, AxiosRequestConfig).then(res => res);
}
else if (method === "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 {
// default method
res = yield axios_1.default.post(_curUri, _curObj, AxiosRequestConfig).then(res => res);
}
let _successMessage = _onSuccess(res, successCallBack);

@@ -61,0 +74,0 @@ (_f = butRef.current) === null || _f === void 0 ? void 0 : _f.hideSpin();

{
"name": "reactstrap-react-lib",
"version": "1.0.13",
"version": "1.0.14",
"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