fixed indexing wrong group when getting permissions
This commit is contained in:
parent
1b1d6e4485
commit
b4c1a543de
4 changed files with 53 additions and 21 deletions
|
|
@ -5,7 +5,7 @@
|
|||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
"start-local": "VITE_AUTH0_AUDIENCE=bxt-dev.api.adaptiveagriculture.ca VITE_APP_API_URL=http://localhost:50052/v1 VITE_APP_WS_URL=ws://localhost:50052/v1/live VITE_APP_BILLING_URL=http://localhost:50053/v1 VITE_APP_RECLUSE_URL=http://localhost:50054/v1 VITE_APP_GITLAB_URL=http://localhost:50055/v1 vite",
|
||||
"start-local": "VITE_AUTH0_CLIENT_ID=dzJTpqIeMA4Rwk4xujtwPbAO3TY32bM1 VITE_AUTH0_AUDIENCE=bxt-dev.api.adaptiveagriculture.ca VITE_APP_API_URL=http://localhost:50052/v1 VITE_APP_WS_URL=ws://localhost:50052/v1/live VITE_APP_BILLING_URL=http://localhost:50053/v1 VITE_APP_RECLUSE_URL=http://localhost:50054/v1 VITE_APP_GITLAB_URL=http://localhost:50055/v1 vite",
|
||||
"start-dev": "VITE_AUTH0_CLIENT_ID=dzJTpqIeMA4Rwk4xujtwPbAO3TY32bM1 VITE_APP_API_URL=https://bxt-dev.api.adaptiveagriculture.ca/v1 VITE_AUTH0_CLIENT_DOMAIN=brandxtech.auth0.com VITE_AUTH0_AUDIENCE=bxt-dev.api.adaptiveagriculture.ca VITE_AUTH0_DEV_CLIENT_ID=dzJTpqIeMA4Rwk4xujtwPbAO3TY32bM1 vite",
|
||||
"start-staging": "VITE_AUTH0_CLIENT_ID=3ib460VvLwdeyse5iUSQfxkVdQaUmphP VITE_AUTH0_AUDIENCE=stagingapi.brandxtech.ca VITE_AUTH0_CLIENT_DOMAIN=adaptivestaging.us.auth0.com VITE_APP_API_URL=https://stagingapi.brandxtech.ca/v1 VITE_APP_WS_URL=ws://stagingapi.brandxtech.ca/v1/live VITE_APP_AUTH0_CLIENT_DOMAIN=adaptivestaging.us.auth0.com VITE_APP_AUTH0_AUDIENCE=stagingapi.brandxtech.ca vite",
|
||||
"build": "tsc -b && vite build",
|
||||
|
|
|
|||
|
|
@ -120,10 +120,15 @@ export default function Devices() {
|
|||
setGroups(newGroups);
|
||||
};
|
||||
|
||||
const getGroupKey = () => {
|
||||
return parseInt(tab+1)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setGroupPermissions([])
|
||||
if (tab === "all") return
|
||||
groupAPI.getGroupPermissions(parseInt(tab)).then(resp => {
|
||||
groupAPI.getGroupPermissions(getGroupKey()).then(resp => {
|
||||
console.log(resp)
|
||||
setGroupPermissions(resp.data.permissions)
|
||||
})
|
||||
}, [tab])
|
||||
|
|
@ -155,7 +160,7 @@ export default function Devices() {
|
|||
if (tab !== "all") {
|
||||
let keys = getContextKeys()
|
||||
//keys.splice(keys.length - 1, 0, getGroup().id().toString());
|
||||
keys.push(getGroup().id().toString());
|
||||
keys.push(getGroupKey().toString());
|
||||
return keys
|
||||
} else {
|
||||
return getContextKeys()
|
||||
|
|
@ -376,7 +381,7 @@ export default function Devices() {
|
|||
}
|
||||
|
||||
const getGroup = () => {
|
||||
let group = groups[parseInt(tab)]
|
||||
let group = groups[parseInt(tab+1)]
|
||||
return group
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,8 @@ export default function TeamPage() {
|
|||
<Grid2 container direction={"column"} spacing={isMobile ? 0 : 0.5} >
|
||||
<Grid2 >
|
||||
<Typography variant={isMobile ? "h5" : "h4"} className={classes.ellipsis} >
|
||||
{team.name()}
|
||||
{/* {team.name()} */}
|
||||
<SmartBreadcrumb paddingBottom={1} teamName={team.name()} />
|
||||
{/* <SmartBreadcrumb /> */}
|
||||
</Typography>
|
||||
</Grid2>
|
||||
|
|
@ -215,8 +216,6 @@ export default function TeamPage() {
|
|||
<PageContainer padding={isMobile ? 0 : 2}>
|
||||
<Box className={classes.container}>
|
||||
<Box className={classes.leftBox}>
|
||||
<SmartBreadcrumb paddingBottom={1} teamName={team.name()} />
|
||||
<SmartBreadcrumb />
|
||||
{title()}
|
||||
</Box>
|
||||
<Box className={classes.rightBox}>
|
||||
|
|
|
|||
|
|
@ -42,6 +42,20 @@ export interface IGroupAPIContext {
|
|||
updateGroupPermissions: (id: number, users: User[]) => Promise<any>;
|
||||
}
|
||||
|
||||
function buildQueryString(params: Record<string, string | string[] | number | null | undefined>): string {
|
||||
// Filter out null, undefined, or empty string values
|
||||
const validParams = Object.entries(params)
|
||||
.filter(([_, value]) => value != null && value !== '')
|
||||
.map(([key, value]) => `${key}=${value}`);
|
||||
|
||||
if (validParams.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Join parameters with '&' and prepend '?'
|
||||
return `?${validParams.join('&')}`;
|
||||
}
|
||||
|
||||
export const GroupAPIContext = createContext<IGroupAPIContext>({} as IGroupAPIContext);
|
||||
|
||||
interface Props {}
|
||||
|
|
@ -53,8 +67,16 @@ export default function GroupProvider(props: PropsWithChildren<Props>) {
|
|||
const [{ as }] = useGlobalState();
|
||||
|
||||
const addGroup = (group: pond.GroupSettings) => {
|
||||
let url = pondURL("/groups")
|
||||
if (as) url = pondURL("/groups?as=" + as)
|
||||
// let url = pondURL("/groups")
|
||||
// let keys = getContextKeys()
|
||||
// let types = getContextTypes()
|
||||
// if (as) url = pondURL("/groups?as=" + as)
|
||||
const params = {
|
||||
keys: getContextKeys(),
|
||||
types: getContextTypes(),
|
||||
as: getContextTypes().includes("team") ? undefined : as
|
||||
}
|
||||
let url = pondURL(`/groups${buildQueryString(params)}`)
|
||||
return new Promise<AxiosResponse>((resolve, reject) => {
|
||||
post(url, group).then(resp => {
|
||||
return resolve(resp)
|
||||
|
|
@ -157,19 +179,25 @@ export default function GroupProvider(props: PropsWithChildren<Props>) {
|
|||
keys?: string[],
|
||||
types?: string[],
|
||||
) => {
|
||||
keys = keys ? keys : getContextKeys();
|
||||
types = types? types : getContextTypes();
|
||||
let url = "/groupPermissions/" + id
|
||||
if (as) {
|
||||
url = url + "?as=" + as +
|
||||
+
|
||||
(keys ? "?keys=" + keys.toString() : "") +
|
||||
(types ? "&types=" + types.toString() : "")
|
||||
} else {
|
||||
url = url +
|
||||
(keys ? "?keys=" + keys.toString() : "") +
|
||||
(types ? "&types=" + types.toString() : "")
|
||||
// keys = keys ? keys : getContextKeys();
|
||||
// types = types? types : getContextTypes();
|
||||
// let url = "/groupPermissions/" + id
|
||||
// if (as) {
|
||||
// url = url + "?as=" + as +
|
||||
// +
|
||||
// (keys ? "?keys=" + keys.toString() : "") +
|
||||
// (types ? "&types=" + types.toString() : "")
|
||||
// } else {
|
||||
// url = url +
|
||||
// (keys ? "?keys=" + keys.toString() : "") +
|
||||
// (types ? "&types=" + types.toString() : "")
|
||||
// }
|
||||
const params = {
|
||||
keys: getContextKeys(),
|
||||
types: getContextTypes(),
|
||||
as: getContextTypes().includes("team") ? undefined : as,
|
||||
}
|
||||
let url = `/groupPermissions/${id}${buildQueryString(params)}`
|
||||
return new Promise<AxiosResponse<pond.GetPermissionsResponse>>((resolve, reject) => {
|
||||
get<pond.GetPermissionsResponse>(pondURL(url)).then(resp => {
|
||||
resp.data = pond.GetPermissionsResponse.fromObject(resp.data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue