+ {accounts?.length === 1 ? (
+ <>
+ {/* No accordion for 1 account notification */}
+
+
+ {accounts?.[0]?.email}{' '}
+
+
+ is requesting account approval...
+
+
+
{
+ acceptAll(accounts);
+ }}
+ declineCallback={() => {
+ declineAll(accounts);
+ }}
+ pl="3.25rem"
+ />
+ >
+ ) : (
+ <>
+ {/* Accordion for >1 account notification in block */}
+
+
+ {accounts?.[0]?.email} and {accounts?.length - 1} other
+ {accounts?.length - 1 > 1 && 's'}{' '}
+
+
+ {accounts?.length - 1 > 1 ? 'are' : 'is'} requesting account approval...
+
+
+
+
+
+
+
+
+ {
+ setDisableChildrenButtons(true);
+ acceptAll(accounts);
+ }}
+ declineCallback={() => {
+ setDisableChildrenButtons(true);
+ declineAll(accounts);
+ }}
+ />
+
+
+
+ {accounts?.map(({ id, email, approveCallback, declineCallback }) => (
+
+
+
+ {email}
+
+
+
+ {
+ await approveCallback();
+ toast({
+ title: `Approved ${email}.`,
+ status: 'success',
+ duration: 9000,
+ isClosable: true,
+ });
+ setAccounts(accounts =>
+ accounts.filter(account => account.id !== id),
+ );
+ }}
+ declineCallback={async () => {
+ await declineCallback();
+ toast({
+ title: `Declined ${email}.`,
+ status: 'info',
+ duration: 9000,
+ isClosable: true,
+ });
+ setAccounts(accounts =>
+ accounts.filter(account => account.id !== id),
+ );
+ }}
+ disableChildrenButtons={disableChildrenButtons}
+ />
+
+
+ ))}
+
+
+
+
+ >
+ )}
+
+