1234567891011121314151617181920212223242526272829303132 |
- import React from 'react';
-
- let allBtns = [];
- let current = [];
-
- const AuthButton = ({ children, name, noRight }) => {
- const btn = allBtns.filter(x => x.code === name)[0]
-
-
-
-
-
-
-
-
- if (!btn) {
- return <>{children}</>
- }
-
- const hasRight = current.filter(x => x.code === name)[0]
-
- return hasRight ? <>{children}</> : <>{noRight}</>
- }
-
- const setAllBtnAuth = x => allBtns = x;
- const setUserBtnAuth = x => current = x;
-
- export default AuthButton;
- export {
- setAllBtnAuth,
- setUserBtnAuth,
- };
|