-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Account Data tab in User edit * update readme
- Loading branch information
Showing
12 changed files
with
138 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { useDataProvider, useRecordContext, useTranslate } from "react-admin"; | ||
import { useEffect, useState } from "react"; | ||
import { Typography, Box, Stack, Accordion, AccordionSummary, AccordionDetails } from "@mui/material"; | ||
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward'; | ||
import { SynapseDataProvider } from "../synapse/dataProvider"; | ||
|
||
const UserAccountData = () => { | ||
const dataProvider = useDataProvider() as SynapseDataProvider; | ||
const record = useRecordContext(); | ||
const translate = useTranslate(); | ||
const [globalAccountData, setGlobalAccountData] = useState({}); | ||
const [roomsAccountData, setRoomsAccountData] = useState({}); | ||
|
||
if (!record) { | ||
return null; | ||
} | ||
|
||
useEffect(() => { | ||
const fetchAccountData = async () => { | ||
const accountData = await dataProvider.getAccountData(record.id); | ||
setGlobalAccountData(accountData.account_data.global); | ||
setRoomsAccountData(accountData.account_data.rooms); | ||
}; | ||
fetchAccountData(); | ||
}, []); | ||
|
||
if (Object.keys(globalAccountData).length === 0 && Object.keys(roomsAccountData).length === 0) { | ||
return <Typography variant="body2">{translate('ra.navigation.no_results', { | ||
resource: 'Account Data', | ||
_: 'No results found.', | ||
})}</Typography>; | ||
} | ||
|
||
return <> | ||
<Stack | ||
direction="column" | ||
spacing={2} | ||
width="100%" | ||
> | ||
<Typography variant="h6">{translate('resources.users.account_data.title')}</Typography> | ||
<Typography variant="body1"> | ||
<Box> | ||
<Accordion> | ||
<AccordionSummary expandIcon={<ArrowDownwardIcon />}> | ||
<Typography variant="h6">{translate('resources.users.account_data.global')}</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Box sx={{ whiteSpace: "pre-wrap" }}>{JSON.stringify(globalAccountData, null, 4)}</Box> | ||
</AccordionDetails> | ||
</Accordion> | ||
<Accordion> | ||
<AccordionSummary expandIcon={<ArrowDownwardIcon />}> | ||
<Typography variant="h6">{translate('resources.users.account_data.rooms')}</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Box sx={{ whiteSpace: "pre-wrap" }}>{JSON.stringify(roomsAccountData, null, 4)}</Box> | ||
</AccordionDetails> | ||
</Accordion> | ||
</Box> | ||
</Typography> | ||
</Stack> | ||
</> | ||
} | ||
|
||
export default UserAccountData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters