-
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.
Merge pull request #1186 from Chia-Network/refactor/glossary-page
feat: add per organization sync status
- Loading branch information
Showing
6 changed files
with
69 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { useGetOrganizationsMapQuery, useGetOrganizationsListQuery } from '@/api/cadt/v1/organizations'; | ||
|
||
interface SyncIndicatorProps { | ||
detailed: boolean; | ||
orgUid?: string; | ||
} | ||
|
||
/** | ||
* Component to display sync status indicator. | ||
* It shows a green circle if the organization is synced, and a pulsing yellow circle if syncing. | ||
* When 'detailed' is true, it also shows a label next to the indicator. | ||
* The sync status is determined based on 'orgUid' from the organizations data. | ||
*/ | ||
const SyncIndicator: React.FC<SyncIndicatorProps> = ({ detailed, orgUid }) => { | ||
const { data: organizationsMap } = useGetOrganizationsMapQuery(null, { | ||
skip: !orgUid, | ||
}); | ||
|
||
const { data: organizationList } = useGetOrganizationsListQuery(null, { | ||
skip: Boolean(orgUid), | ||
}); | ||
|
||
let isSynced = false; | ||
|
||
if (!orgUid) { | ||
isSynced = !organizationList?.some((org) => !org.synced); | ||
} else { | ||
isSynced = organizationsMap?.[orgUid]?.synced; | ||
} | ||
|
||
return ( | ||
<div className={`flex items-center space-x-2 ${detailed ? 'p-2 rounded-lg shadow bg-white dark:bg-gray-800' : ''}`}> | ||
<div className={`${isSynced ? 'bg-green-500' : 'animate-pulse bg-yellow-500'} h-4 w-4 rounded-full`}></div> | ||
{detailed && ( | ||
<span className={`text-sm ${isSynced ? 'text-green-700' : 'text-yellow-600'}`}> | ||
{isSynced ? 'Synced' : 'Syncing...'} | ||
</span> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export { SyncIndicator }; |
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,2 +1,3 @@ | ||
export * from './SearchBox'; | ||
export * from './OrganizationSelector'; | ||
export * from './OrganizationSelector'; | ||
export * from './SyncIndicator'; |
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