diff --git a/frontend/app/src/people/widgetViews/OrganizationDetails.tsx b/frontend/app/src/people/widgetViews/OrganizationDetails.tsx
index 72ba484d8..25322e983 100644
--- a/frontend/app/src/people/widgetViews/OrganizationDetails.tsx
+++ b/frontend/app/src/people/widgetViews/OrganizationDetails.tsx
@@ -181,13 +181,15 @@ const OrganizationDetails = (props: {
const getPaymentsHistory = useCallback(async () => {
if (!viewReportDisabled) {
const paymentHistories = await main.getPaymentHistories(uuid, 1, 2000);
- const payments = paymentHistories.map((history: PaymentHistory) => {
- if (!history.payment_type) {
- history.payment_type = 'payment';
- }
- return history;
- });
- setPaymentsHistory(payments);
+ if (Array.isArray(paymentHistories)) {
+ const payments = paymentHistories.map((history: PaymentHistory) => {
+ if (!history.payment_type) {
+ history.payment_type = 'payment';
+ }
+ return history;
+ });
+ setPaymentsHistory(payments);
+ }
}
}, [main, uuid, viewReportDisabled]);
@@ -437,7 +439,7 @@ const OrganizationDetails = (props: {
YOUR BALANCE
- {orgBudget.toLocaleString()} SATS
+ {orgBudget ? orgBudget.toLocaleString() : 0} SATS
{satToUsd(orgBudget)} USD
@@ -486,44 +488,47 @@ const OrganizationDetails = (props: {
- {users.map((user: Person, i: number) => (
-
-
-
- {user.unique_name}
- {user.owner_pubkey}
-
-
-
- handleSettingsClick(user)}
- />
-
-
- {
- setUser(user);
- handleDeleteClick(user);
- }}
- />
-
-
-
- ))}
+ {users.map((user: Person, i: number) => {
+ const isUser = user.owner_pubkey === ui.meInfo?.owner_pubkey;
+ return (
+
+
+
+ {user.unique_name}
+ {user.owner_pubkey}
+
+
+
+ handleSettingsClick(user)}
+ />
+
+
+ {
+ setUser(user);
+ handleDeleteClick(user);
+ }}
+ />
+
+
+
+ );
+ })}
diff --git a/frontend/app/src/people/widgetViews/OrganizationView.tsx b/frontend/app/src/people/widgetViews/OrganizationView.tsx
index 70929a0c3..3e5797389 100644
--- a/frontend/app/src/people/widgetViews/OrganizationView.tsx
+++ b/frontend/app/src/people/widgetViews/OrganizationView.tsx
@@ -134,13 +134,14 @@ const Organizations = (props: { person: Person }) => {
const [organization, setOrganization] = useState();
const [disableFormButtons, setDisableFormButtons] = useState(false);
const [toasts, setToasts]: any = useState([]);
- const [user, setUser] = useState();
const { main, ui } = useStores();
const isMobile = useIsMobile();
const config = widgetConfigs['organizations'];
const formRef = useRef(null);
const isMyProfile = ui?.meInfo?.pubkey === props?.person?.owner_pubkey;
+ const user_pubkey = ui.meInfo?.owner_pubkey;
+
const schema = [...config.schema];
const initValues = {
@@ -168,9 +169,6 @@ const Organizations = (props: { person: Person }) => {
if (ui.selectedPerson) {
const orgs = await main.getUserOrganizations(ui.selectedPerson);
main.setDropDownOrganizations(orgs);
-
- const user = await main.getPersonById(ui.selectedPerson);
- setUser(user);
}
setIsLoading(false);
}, [main, ui.selectedPerson]);
@@ -207,12 +205,12 @@ const Organizations = (props: { person: Person }) => {
-
+
- {ui.meInfo?.owner_pubkey && (
+ {user_pubkey && (
{
setOrganization(org);
setDetailsOpen(true);
diff --git a/frontend/app/src/people/widgetViews/organization/ManageOrgButton.tsx b/frontend/app/src/people/widgetViews/organization/ManageOrgButton.tsx
index 5f18fa05d..634fb80a2 100644
--- a/frontend/app/src/people/widgetViews/organization/ManageOrgButton.tsx
+++ b/frontend/app/src/people/widgetViews/organization/ManageOrgButton.tsx
@@ -17,8 +17,12 @@ const ManageButton = (props: { user_pubkey: string; org: any; action: () => void
userHasRole(main.bountyRoles, userRoles, 'VIEW REPORT');
const getUserRoles = useCallback(async () => {
- const userRoles = await main.getUserRoles(org.uuid, user_pubkey);
- setUserRoles(userRoles);
+ try {
+ const userRoles = await main.getUserRoles(org.uuid, user_pubkey);
+ setUserRoles(userRoles);
+ } catch (e) {
+ console.error('User roles error', e);
+ }
}, [org.uuid, main, user_pubkey]);
useEffect(() => {
diff --git a/handlers/organizations.go b/handlers/organizations.go
index 7787237bf..7497f5b6c 100644
--- a/handlers/organizations.go
+++ b/handlers/organizations.go
@@ -140,7 +140,7 @@ func CreateOrganizationUser(w http.ResponseWriter, r *http.Request) {
}
// check if the user is the organization admin
- if pubKeyFromAuth == org.OwnerPubKey {
+ if orgUser.OwnerPubKey == org.OwnerPubKey {
w.WriteHeader(http.StatusUnauthorized)
json.NewEncoder(w).Encode("Cannot add organization admin as a user")
return