minor improvements enhancing code readability
This commit is contained in:
parent
723e0dd953
commit
de56496a18
|
@ -33,6 +33,23 @@ const MyTools: React.FC<
|
|||
/** === USE EFFECT HOOKS === */
|
||||
React.useEffect(() => {
|
||||
(async () => {
|
||||
await initListData();
|
||||
})();
|
||||
}, [props]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (myTools.length > 0 && errorMessage) {
|
||||
setErrorMessage(undefined);
|
||||
}
|
||||
if (myTools.length === 0) {
|
||||
setErrorMessage(
|
||||
errorMsgNotFound
|
||||
);
|
||||
}
|
||||
}, [myTools]);
|
||||
|
||||
/** === FUNCTIONS === */
|
||||
async function initListData(): Promise<void> {
|
||||
if (props.wpLists?.personalToolsList && props.wpSite?.url) {
|
||||
const tmpTools = await getUsersTools(props.context, props.userEmail, { list: props.wpLists.personalToolsList, siteUrl: props.wpSite.url });
|
||||
if (tmpTools) {
|
||||
|
@ -49,24 +66,12 @@ const MyTools: React.FC<
|
|||
setSelectableTools(tmpSelectTools);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, [props]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (myTools.length > 0 && errorMessage) {
|
||||
setErrorMessage(undefined);
|
||||
}
|
||||
if (myTools.length === 0) {
|
||||
setErrorMessage(
|
||||
errorMsgNotFound
|
||||
);
|
||||
}
|
||||
}, [myTools]);
|
||||
|
||||
/** === FUNCTIONS === */
|
||||
const handleClickOpen = (): void => {
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
const handleClose = (): void => {
|
||||
setOpen(false);
|
||||
};
|
||||
|
|
|
@ -40,7 +40,6 @@ export const getSelectableTools = async (
|
|||
context: WebPartContext,
|
||||
availableToolsList: ListDefintion,
|
||||
): Promise<Array<ITool>> => {
|
||||
console.log([context, availableToolsList]);
|
||||
const sourceWeb = await getSourceWeb(context, availableToolsList?.siteUrl ?? '');
|
||||
const sourceList = sourceWeb.lists.getById(availableToolsList?.list?.id ?? '');
|
||||
const requestRes = await sourceList.items();
|
||||
|
|
Loading…
Reference in New Issue