-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68b1776
commit 0552338
Showing
21 changed files
with
270 additions
and
65 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
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
53 changes: 31 additions & 22 deletions
53
fe1-web/src/features/linked-organizations/components/BroadcastLinkedOrgInfo.tsx
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 |
---|---|---|
@@ -1,44 +1,53 @@ | ||
import React, { useEffect } from 'react'; | ||
import { Hash } from 'core/objects'; | ||
import { LinkedOrganizationsHooks } from '../hooks'; | ||
import { catchup, subscribeToChannel } from 'core/network'; | ||
import { dispatch } from 'core/redux'; | ||
import React from 'react'; | ||
import { useToast } from 'react-native-toast-notifications'; | ||
|
||
import { Hash } from 'core/objects'; | ||
import { FOUR_SECONDS } from 'resources/const'; | ||
|
||
import { LinkedOrganizationsHooks } from '../hooks'; | ||
import { tokensExchange } from '../network'; | ||
|
||
interface BroadcastLinkedOrgInfoProps { | ||
linkedLaoId: Hash, | ||
linkedLaoId: Hash; | ||
} | ||
|
||
|
||
|
||
const BroadcastLinkedOrgInfo: React.FC<BroadcastLinkedOrgInfoProps> = ({ | ||
linkedLaoId | ||
}) => { | ||
const BroadcastLinkedOrgInfo: React.FC<BroadcastLinkedOrgInfoProps> = ({ linkedLaoId }) => { | ||
const laoId = LinkedOrganizationsHooks.useCurrentLaoId(); | ||
console.log(LinkedOrganizationsHooks.useGetLaoById(laoId)) | ||
const isOrganizer = LinkedOrganizationsHooks.useIsLaoOrganizer(laoId); | ||
const toast = useToast(); | ||
const fetchedLao = LinkedOrganizationsHooks.useGetLaoById(linkedLaoId); | ||
if (fetchedLao?.last_roll_call_id === undefined) { | ||
toast.show(`Data Exchange failed: Linked Organization has no last roll call id`, { | ||
const fetchedRollCall = LinkedOrganizationsHooks.useGetRollCallById( | ||
fetchedLao!.last_roll_call_id!, | ||
); | ||
|
||
if (fetchedRollCall === undefined) { | ||
toast.show(`Data Exchange failed: RollCall ID is undefined`, { | ||
type: 'danger', | ||
placement: 'bottom', | ||
duration: FOUR_SECONDS, | ||
}); | ||
return (null); | ||
return null; | ||
} | ||
const fetchedRollCall = LinkedOrganizationsHooks.useGetRollCallById(fetchedLao.last_roll_call_id); | ||
if (fetchedRollCall === undefined) { | ||
toast.show(`Data Exchange failed: RollCall ID is undefined`, { | ||
if (fetchedRollCall.attendees === undefined) { | ||
toast.show(`Data Exchange failed: RollCall Attendees is undefined`, { | ||
type: 'danger', | ||
placement: 'bottom', | ||
duration: FOUR_SECONDS, | ||
}); | ||
return (null); | ||
return null; | ||
} | ||
console.log(fetchedRollCall.attendees) | ||
return (null); | ||
tokensExchange(laoId, linkedLaoId, fetchedRollCall.id, fetchedRollCall.attendees) | ||
.then(() => { | ||
console.log('Data Exchange successfull'); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
toast.show(`Could not exchange Tokens, error: ${err}`, { | ||
type: 'danger', | ||
placement: 'bottom', | ||
duration: FOUR_SECONDS, | ||
}); | ||
}); | ||
return null; | ||
}; | ||
|
||
export default BroadcastLinkedOrgInfo; |
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
Oops, something went wrong.