diff --git a/frontend/src/components/Dialogs/Profile.tsx b/frontend/src/components/Dialogs/Profile.tsx index c0ad64bb..0a7760b7 100644 --- a/frontend/src/components/Dialogs/Profile.tsx +++ b/frontend/src/components/Dialogs/Profile.tsx @@ -29,10 +29,19 @@ const ProfileDialog = ({ open = false, onClose }: Props): JSX.Element => { const { federation } = useContext(FederationContext); const { garage, robotUpdatedAt } = useContext(GarageContext); const { t } = useTranslation(); + + const slot = garage.getSlot(); + const [loading, setLoading] = useState(true); + const [loadingCoordinators, setLoadingCoordinators] = useState( + Object.values(slot?.robots ?? {}).length, + ); useEffect(() => { setLoading(!garage.getSlot()?.hashId); + setLoadingCoordinators( + Object.values(slot?.robots ?? {}).filter((robot) => robot.loading).length, + ); }, [robotUpdatedAt]); return ( @@ -49,12 +58,11 @@ const ProfileDialog = ({ open = false, onClose }: Props): JSX.Element => { {t('Your Robot')} - - + {garage.getSlot()?.nickname !== undefined && (
@@ -76,6 +84,15 @@ const ProfileDialog = ({ open = false, onClose }: Props): JSX.Element => {
)}
+ + {loadingCoordinators > 0 ? ( + <> + {t('Looking for your robot!')} + + + ) : ( + <> + )}
@@ -95,15 +112,16 @@ const ProfileDialog = ({ open = false, onClose }: Props): JSX.Element => { {Object.values(federation.coordinators).map((coordinator: Coordinator): JSX.Element => { - if (garage.getSlot()?.hashId) { - return ( -
- -
- ); - } else { - return
; - } + const coordinatorRobot = garage.getSlot()?.getRobot(coordinator.shortAlias); + return ( +
+ +
+ ); })} diff --git a/frontend/src/components/MakerForm/AutocompletePayments.tsx b/frontend/src/components/MakerForm/AutocompletePayments.tsx index 17e97a0e..be677e2d 100644 --- a/frontend/src/components/MakerForm/AutocompletePayments.tsx +++ b/frontend/src/components/MakerForm/AutocompletePayments.tsx @@ -268,7 +268,7 @@ const AutocompletePayments: React.FC = (props) => { options: props.optionsType === 'fiat' ? fiatMethods : swapMethods, getOptionLabel: (option) => option.name, onInputChange: (e) => { - setVal(e.target.value ?? ''); + setVal(e?.target?.value ?? ''); }, onChange: (event, value) => { props.onAutocompleteChange(value); diff --git a/frontend/src/components/RobotInfo/index.tsx b/frontend/src/components/RobotInfo/index.tsx index 0b22e77f..b5ce895f 100644 --- a/frontend/src/components/RobotInfo/index.tsx +++ b/frontend/src/components/RobotInfo/index.tsx @@ -36,9 +36,10 @@ import { FederationContext, type UseFederationStoreType } from '../../contexts/F interface Props { coordinator: Coordinator; onClose: () => void; + disabled?: boolean; } -const RobotInfo: React.FC = ({ coordinator, onClose }: Props) => { +const RobotInfo: React.FC = ({ coordinator, onClose, disabled }: Props) => { const { garage } = useContext(GarageContext); const { setCurrentOrderId } = useContext(FederationContext); const navigate = useNavigate(); @@ -117,7 +118,7 @@ const RobotInfo: React.FC = ({ coordinator, onClose }: Props) => { const robot = slot?.getRobot(coordinator.shortAlias); return ( - + }> {`${coordinator.longAlias}:`} {(robot?.earnedRewards ?? 0) > 0 && ( diff --git a/frontend/src/contexts/FederationContext.tsx b/frontend/src/contexts/FederationContext.tsx index b73c6e2c..a1f3ac8e 100644 --- a/frontend/src/contexts/FederationContext.tsx +++ b/frontend/src/contexts/FederationContext.tsx @@ -80,13 +80,7 @@ export const FederationContextProvider = ({ useContext(AppContext); const { setMaker, garage, setBadOrder } = useContext(GarageContext); const [federation, setFederation] = useState(initialFederationContext.federation); - const sortedCoordinators = useMemo(() => { - const sortedCoordinators = federationLottery(federation); - setMaker((maker) => { - return { ...maker, coordinator: sortedCoordinators[0] }; - }); // default MakerForm coordinator is decided via sorted lottery - return sortedCoordinators; - }, []); + const sortedCoordinators = useMemo(() => federationLottery(federation), []); const [coordinatorUpdatedAt, setCoordinatorUpdatedAt] = useState( new Date().toISOString(), ); @@ -103,6 +97,12 @@ export const FederationContextProvider = ({ setInterval(() => null, delay), ); + useEffect(() => { + setMaker((maker) => { + return { ...maker, coordinator: sortedCoordinators[0] }; + }); // default MakerForm coordinator is decided via sorted lottery + }, []); + useEffect(() => { // On bitcoin network change we reset book, limits and federation info and fetch everything again const newFed = initialFederationContext.federation; @@ -144,9 +144,9 @@ export const FederationContextProvider = ({ const fetchCurrentOrder: () => void = () => { const slot = garage?.getSlot(); const robot = slot?.getRobot(); - if (currentOrderId.id && currentOrderId.shortAlias) { + if (robot && slot?.token && currentOrderId.id && currentOrderId.shortAlias) { const coordinator = federation.getCoordinator(currentOrderId.shortAlias); - void coordinator?.fetchOrder(currentOrderId.id, robot, slot.token).then((order) => { + void coordinator?.fetchOrder(currentOrderId.id, robot, slot?.token).then((order) => { onOrderReceived(order as Order); }); } else if (slot?.token && slot?.activeShortAlias && robot?.activeOrderId) { diff --git a/frontend/static/locales/ca.json b/frontend/static/locales/ca.json index cd0c9cdb..54fcf994 100644 --- a/frontend/static/locales/ca.json +++ b/frontend/static/locales/ca.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "No tens un avatar robot", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "El teu Robot", - "Your robot": "El teu robot", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Guarda-ho!", "Done": "Fet", diff --git a/frontend/static/locales/cs.json b/frontend/static/locales/cs.json index e1294f65..7c0ed022 100644 --- a/frontend/static/locales/cs.json +++ b/frontend/static/locales/cs.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "Nemáš robota a avatar", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "Tvůj robot", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Zálohuj to!", "Done": "Hotovo", diff --git a/frontend/static/locales/de.json b/frontend/static/locales/de.json index 2c1e498b..ef4a8f7d 100644 --- a/frontend/static/locales/de.json +++ b/frontend/static/locales/de.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "Du hast keinen Roboter-Avatar", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "Dein Roboter", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Speicher ihn ab!", "Done": "Fertig", diff --git a/frontend/static/locales/en.json b/frontend/static/locales/en.json index d1e30fbd..5008400b 100644 --- a/frontend/static/locales/en.json +++ b/frontend/static/locales/en.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "You do not have a robot avatar", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "Your robot", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Back it up!", "Done": "Done", diff --git a/frontend/static/locales/es.json b/frontend/static/locales/es.json index fef8740e..3c29146e 100644 --- a/frontend/static/locales/es.json +++ b/frontend/static/locales/es.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "No tienes un avatar robot", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "Tu Robot", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "¡Guárdalo!", "Done": "Hecho", diff --git a/frontend/static/locales/eu.json b/frontend/static/locales/eu.json index 755b0208..76a38043 100644 --- a/frontend/static/locales/eu.json +++ b/frontend/static/locales/eu.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "Ez daukazu robot avatarrik", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "Zure robota", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Gorde ezazu!", "Done": "Prest", diff --git a/frontend/static/locales/fr.json b/frontend/static/locales/fr.json index 9a463331..9cd77e2b 100644 --- a/frontend/static/locales/fr.json +++ b/frontend/static/locales/fr.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "Vous n'avez pas d'avatar robot", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Votre Robot", - "Your robot": "Votre robot", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Sauvegardez!", "Done": "Fait", diff --git a/frontend/static/locales/it.json b/frontend/static/locales/it.json index 772c17f2..ab1e4f52 100644 --- a/frontend/static/locales/it.json +++ b/frontend/static/locales/it.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "Non hai un avatar robot", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Il tuo Robot", - "Your robot": "Il tuo robot", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Salvalo!", "Done": "Fatto", diff --git a/frontend/static/locales/ja.json b/frontend/static/locales/ja.json index 6a2a5050..ccc98cf2 100644 --- a/frontend/static/locales/ja.json +++ b/frontend/static/locales/ja.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "ロボットのアバターがありません", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "あなたのロボット", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "バックアップを取ってください!", "Done": "完了", diff --git a/frontend/static/locales/pl.json b/frontend/static/locales/pl.json index 4d8fd7a8..6b99b0e9 100644 --- a/frontend/static/locales/pl.json +++ b/frontend/static/locales/pl.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "You do not have a robot avatar", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "Twój robot", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Utwórz kopię zapasową!", "Done": "Done", diff --git a/frontend/static/locales/pt.json b/frontend/static/locales/pt.json index 48a65426..6d23cff0 100644 --- a/frontend/static/locales/pt.json +++ b/frontend/static/locales/pt.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "Você não tem um avatar de robô", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "Seu robô", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Apoia-la!", "Done": "Feito", diff --git a/frontend/static/locales/ru.json b/frontend/static/locales/ru.json index 7cad05d8..bd3a6e86 100644 --- a/frontend/static/locales/ru.json +++ b/frontend/static/locales/ru.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "У Вас нет аватара робота", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Ваш Robot", - "Your robot": "Ваш Робот", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Сохраните его!", "Done": "Готово", diff --git a/frontend/static/locales/sv.json b/frontend/static/locales/sv.json index 7bbdbbd8..8e56fb2a 100644 --- a/frontend/static/locales/sv.json +++ b/frontend/static/locales/sv.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "Du har ingen robotavatar", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "Din robot", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Spara den!", "Done": "Klar", diff --git a/frontend/static/locales/sw.json b/frontend/static/locales/sw.json index 981687f3..4586a30f 100644 --- a/frontend/static/locales/sw.json +++ b/frontend/static/locales/sw.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "Huna picha ya mwakilishi wa roboti", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Roboti yako", - "Your robot": "Roboti yako", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "Fanya nakala rudufu!", "Done": "Imekamilika", diff --git a/frontend/static/locales/th.json b/frontend/static/locales/th.json index 4d338494..99280da2 100644 --- a/frontend/static/locales/th.json +++ b/frontend/static/locales/th.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "คุณไม่มีโรบอท", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "Your Robot", - "Your robot": "โรบอทของคุณ", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "อย่าลืมบันทึก!", "Done": "เสร็จสิ้น", diff --git a/frontend/static/locales/zh-SI.json b/frontend/static/locales/zh-SI.json index ab86f4da..0dd69936 100644 --- a/frontend/static/locales/zh-SI.json +++ b/frontend/static/locales/zh-SI.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "你没有机器人头像", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "你的机器人", - "Your robot": "你的机器人", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "请备份!", "Done": "完成", diff --git a/frontend/static/locales/zh-TR.json b/frontend/static/locales/zh-TR.json index f0c68753..a24515db 100644 --- a/frontend/static/locales/zh-TR.json +++ b/frontend/static/locales/zh-TR.json @@ -313,8 +313,8 @@ "You do not have a robot avatar": "你沒有機器人頭像", "#29": "Phrases in components/Dialogs/Profile.tsx", "Coordinators that know your robot:": "Coordinators that know your robot:", + "Looking for your robot!": "Looking for your robot!", "Your Robot": "你的機器人", - "Your robot": "你的機器人", "#30": "Phrases in components/Dialogs/StoreToken.tsx", "Back it up!": "請備份!", "Done": "完成",