|
1 | 1 | import { |
2 | 2 | Box, |
| 3 | + Button, |
3 | 4 | debounce, |
4 | 5 | Dialog, |
5 | 6 | DialogContent, |
@@ -27,8 +28,10 @@ import { |
27 | 28 | disableUser, |
28 | 29 | editUser, |
29 | 30 | editUserRole, |
| 31 | + getLastWeekInvitations, |
30 | 32 | getSingleUser, |
31 | | - getUsers |
| 33 | + getUsers, |
| 34 | + inviteUsers |
32 | 35 | } from '../../../slices/user'; |
33 | 36 | import { OwnUser } from '../../../models/user'; |
34 | 37 | import { PermissionEntity, Role } from '../../../models/owns/role'; |
@@ -74,7 +77,9 @@ const People = ({ openModal, handleCloseModal, initialEmail }: PropsType) => { |
74 | 77 | const { peopleId } = useParams(); |
75 | 78 | const { hasEditPermission, user } = useAuth(); |
76 | 79 | const [enabledOnly, setEnabledOnly] = useState<boolean>(true); |
77 | | - const { users, loadingGet, singleUser } = useSelector((state) => state.users); |
| 80 | + const { users, loadingGet, singleUser, lastWeekInvitations } = useSelector( |
| 81 | + (state) => state.users |
| 82 | + ); |
78 | 83 | const [openDrawerFromUrl, setOpenDrawerFromUrl] = useState<boolean>(false); |
79 | 84 | const [criteria, setCriteria] = useState<SearchCriteria>({ |
80 | 85 | filterFields: [], |
@@ -167,6 +172,14 @@ const People = ({ openModal, handleCloseModal, initialEmail }: PropsType) => { |
167 | 172 | window.history.replaceState(null, 'User', `/app/people-teams/people`); |
168 | 173 | setDetailDrawerOpen(false); |
169 | 174 | }; |
| 175 | + |
| 176 | + const onResendInvites = () => { |
| 177 | + lastWeekInvitations.forEach((invitation) => { |
| 178 | + dispatch(inviteUsers(invitation.roleId, [invitation.email], false, true)); |
| 179 | + }); |
| 180 | + showSnackBar(t('users_invite_success'), 'success'); |
| 181 | + }; |
| 182 | + |
170 | 183 | const defautfields: Array<IField> = [ |
171 | 184 | { |
172 | 185 | name: 'rate', |
@@ -278,6 +291,10 @@ const People = ({ openModal, handleCloseModal, initialEmail }: PropsType) => { |
278 | 291 | dispatch(getUsers(criteria, enabledOnly)); |
279 | 292 | }, [criteria, enabledOnly]); |
280 | 293 |
|
| 294 | + useEffect(() => { |
| 295 | + dispatch(getLastWeekInvitations()); |
| 296 | + }, []); |
| 297 | + |
281 | 298 | //see changes in ui on edit |
282 | 299 | useEffect(() => { |
283 | 300 | if (singleUser || users.content.length) { |
@@ -444,6 +461,39 @@ const People = ({ openModal, handleCloseModal, initialEmail }: PropsType) => { |
444 | 461 | /> |
445 | 462 | </Stack> |
446 | 463 | </Stack> |
| 464 | + {lastWeekInvitations.length > 0 && ( |
| 465 | + <Box |
| 466 | + sx={{ |
| 467 | + mb: 2, |
| 468 | + p: 2, |
| 469 | + bgcolor: 'info.light', |
| 470 | + color: 'info.contrastText', |
| 471 | + borderRadius: 1 |
| 472 | + }} |
| 473 | + > |
| 474 | + <Stack |
| 475 | + direction="row" |
| 476 | + justifyContent="space-between" |
| 477 | + alignItems="center" |
| 478 | + > |
| 479 | + <Typography variant="subtitle2"> |
| 480 | + {lastWeekInvitations.length === 1 |
| 481 | + ? `${lastWeekInvitations[0].email} - ${lastWeekInvitations[0].roleName}` |
| 482 | + : t('n_pending_invites', { |
| 483 | + count: lastWeekInvitations.length |
| 484 | + })} |
| 485 | + </Typography> |
| 486 | + <Button |
| 487 | + onClick={onResendInvites} |
| 488 | + variant="contained" |
| 489 | + color="secondary" |
| 490 | + size="small" |
| 491 | + > |
| 492 | + {t('resend_invites')} |
| 493 | + </Button> |
| 494 | + </Stack> |
| 495 | + </Box> |
| 496 | + )} |
447 | 497 | {RenderPeopleList()} |
448 | 498 |
|
449 | 499 | <Drawer |
|
0 commit comments