diff --git a/db/db.go b/db/db.go index b09dc5d01..c1b3d0dcc 100644 --- a/db/db.go +++ b/db/db.go @@ -503,25 +503,30 @@ func (db database) GetAllBounties(r *http.Request) []BountyData { keys := r.URL.Query() tags := keys.Get("tags") // this is a string of tags separated by commas offset, limit, sortBy, direction, search := utils.GetPaginationParams(r) + ms := []BountyData{} + orderQuery := "" limitQuery := "" searchQuery := "" + if sortBy != "" && direction != "" { orderQuery = "ORDER BY " + "body." + sortBy + " " + direction } else { orderQuery = " ORDER BY " + "body." + sortBy + "" + "DESC" } - if offset != 0 && limit != 0 { + if limit != 0 { limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset) } if search != "" { searchQuery = fmt.Sprintf("WHERE LOWER(body.title) LIKE %s", "'%"+search+"%'") } - rawQuery := "SELECT body.*, body.id as bounty_id, body.description as bounty_description, body.created as bounty_created, body.updated as bounty_updated, body.org_uuid, person.*, person.owner_alias as assignee_alias, person.id as assignee_id, person.description as assignee_description, person.created as assignee_created, person.updated as assignee_updated, owner.id as bounty_owner_id, owner.uuid as owner_uuid, owner.owner_pub_key as owner_key, owner.owner_alias as owner_alias, owner.description as owner_description, owner.price_to_meet as owner_price_to_meet, owner.unique_name as owner_unique_name, owner.tags as owner_tags, owner.img as owner_img, owner.created as owner_created, owner.updated as owner_updated, owner.last_login as owner_last_login, owner.owner_route_hint as owner_route_hint, owner.owner_contact_key as owner_contact_key, org.name as organization_name, org.uuid as organization_uuid, org.img as organization_img FROM public.bounty AS body LEFT OUTER JOIN public.people AS person ON body.assignee = person.owner_pub_key LEFT OUTER JOIN public.people as owner ON body.owner_id = owner.owner_pub_key LEFT OUTER JOIN public.organizations as org ON body.org_uuid = org.uuid" + query := "SELECT body.*, body.id as bounty_id, body.description as bounty_description, body.created as bounty_created, body.updated as bounty_updated, body.org_uuid, person.*, person.owner_alias as assignee_alias, person.id as assignee_id, person.description as assignee_description, person.created as assignee_created, person.updated as assignee_updated, owner.id as bounty_owner_id, owner.uuid as owner_uuid, owner.owner_pub_key as owner_key, owner.owner_alias as owner_alias, owner.description as owner_description, owner.price_to_meet as owner_price_to_meet, owner.unique_name as owner_unique_name, owner.tags as owner_tags, owner.img as owner_img, owner.created as owner_created, owner.updated as owner_updated, owner.last_login as owner_last_login, owner.owner_route_hint as owner_route_hint, owner.owner_contact_key as owner_contact_key, org.name as organization_name, org.uuid as organization_uuid, org.img as organization_img FROM public.bounty AS body LEFT OUTER JOIN public.people AS person ON body.assignee = person.owner_pub_key LEFT OUTER JOIN public.people as owner ON body.owner_id = owner.owner_pub_key LEFT OUTER JOIN public.organizations as org ON body.org_uuid = org.uuid" - theQuery := db.db.Raw(rawQuery + " " + searchQuery + " " + orderQuery + " " + limitQuery) + allQuery := query + " " + searchQuery + " " + orderQuery + " " + limitQuery + + theQuery := db.db.Raw(allQuery) if tags != "" { // pull out the tags and add them in here diff --git a/frontend/app/src/components/form/style.ts b/frontend/app/src/components/form/style.ts index 4a5fbb006..92c4398ae 100644 --- a/frontend/app/src/components/form/style.ts +++ b/frontend/app/src/components/form/style.ts @@ -25,7 +25,7 @@ export const OrgWrap = styled.div` height: inherit; flex-direction: column; align-content: center; - min-width: 500px; + min-width: 550px; max-width: auto; `; diff --git a/frontend/app/src/people/main/FocusView.tsx b/frontend/app/src/people/main/FocusView.tsx index f5b37458a..bc5ed5b7a 100644 --- a/frontend/app/src/people/main/FocusView.tsx +++ b/frontend/app/src/people/main/FocusView.tsx @@ -64,9 +64,9 @@ const B = styled.div` overflow-y: auto; box-sizing: border-box; ${EnvWithScrollBar({ - thumbColor: '#5a606c', - trackBackgroundColor: 'rgba(0,0,0,0)' - })} + thumbColor: '#5a606c', + trackBackgroundColor: 'rgba(0,0,0,0)' +})} `; function FocusedView(props: FocusViewProps) { const { @@ -101,10 +101,10 @@ function FocusedView(props: FocusViewProps) { const isTorSave = canEdit && main.isTorSave(); - const userOrganizations = main.organizations.map((org: Organization) => ({ + const userOrganizations = main.organizations.length ? main.organizations.map((org: Organization) => ({ label: toCapitalize(org.name), value: org.uuid - })); + })) : []; function isNotHttps(url: string | undefined) { if (main.isTorSave() || url?.startsWith('http://')) { @@ -369,8 +369,8 @@ function FocusedView(props: FocusViewProps) { extraHTML={ ui.meInfo.verification_signature ? { - twitter: `Post this to your twitter account to verify:
Sphinx Verification: ${ui.meInfo.verification_signature}` - } + twitter: `Post this to your twitter account to verify:
Sphinx Verification: ${ui.meInfo.verification_signature}` + } : {} } /> diff --git a/frontend/app/src/people/widgetViews/OrganizationDetails.tsx b/frontend/app/src/people/widgetViews/OrganizationDetails.tsx index 3479b5920..ba909a799 100644 --- a/frontend/app/src/people/widgetViews/OrganizationDetails.tsx +++ b/frontend/app/src/people/widgetViews/OrganizationDetails.tsx @@ -12,7 +12,10 @@ import { Formik } from 'formik'; import { FormField, validator } from 'components/form/utils'; import { BountyRoles, BudgetHistory, Organization, PaymentHistory, Person } from 'store/main'; import MaterialIcon from '@material/react-material-icon'; +import { Route, Router, Switch, useRouteMatch } from 'react-router-dom'; import { userHasRole } from 'helpers'; +import { BountyModal } from 'people/main/bountyModal'; +import history from '../../config/history'; import { Modal } from '../../components/common'; import { colors } from '../../config/colors'; import { nonWidgetConfigs } from '../utils/Constants'; @@ -145,6 +148,15 @@ const CheckLabel = styled.label` margin: 0px; `; +const ViewBounty = styled.p` + padding: 0px; + margin: 0px; + cursor: pointer; + font-size: 0.9rem; + color: green; + font-size: bold; +`; + const OrganizationDetails = (props: { close: () => void; org: Organization | undefined }) => { const [loading, setIsLoading] = useState(false); const isMobile = useIsMobile(); @@ -168,6 +180,8 @@ const OrganizationDetails = (props: { close: () => void; org: Organization | und const [lnInvoice, setLnInvoice] = useState(''); const [invoiceStatus, setInvoiceStatus] = useState(false); const [amount, setAmount] = useState(1); + const { path, url } = useRouteMatch(); + const pollMinutes = 2; @@ -376,6 +390,14 @@ const OrganizationDetails = (props: { close: () => void; org: Organization | und } }; + const viewBounty = async (bountyId: number) => { + ui.setBountyPerson(ui.meInfo?.id); + + history.push({ + pathname: `${url}/${bountyId}/${0}` + }); + } + useEffect(() => { getOrganizationUsers(); getOrganizationUsersCount(); @@ -567,8 +589,8 @@ const OrganizationDetails = (props: { close: () => void; org: Organization | und style={ item.name === 'github_description' && !values.ticket_url ? { - display: 'none' - } + display: 'none' + } : undefined } /> @@ -738,16 +760,20 @@ const OrganizationDetails = (props: { close: () => void; org: Organization | und Sender + Recipient Amount Date + {paymentsHistory.map((pay: PaymentHistory, i: number) => ( {pay.sender_name} + {pay.receiver_name} {pay.amount} sats - {moment(pay.created).fromNow()} + {moment(pay.created).format('DD/MM/YY')} + viewBounty(pay.bounty_id)}>View bounty ))} @@ -798,7 +824,7 @@ const OrganizationDetails = (props: { close: () => void; org: Organization | und {b.amount} sats {b.payment_type} {b.status ? 'settled' : 'peending'} - {moment(b.created).fromNow()} + {moment(b.created).format('DD/MM/YY')} ))} @@ -808,6 +834,13 @@ const OrganizationDetails = (props: { close: () => void; org: Organization | und )} + + + + + + + ); }; diff --git a/frontend/app/src/people/widgetViews/OrganizationView.tsx b/frontend/app/src/people/widgetViews/OrganizationView.tsx index c7426b683..16329fa50 100644 --- a/frontend/app/src/people/widgetViews/OrganizationView.tsx +++ b/frontend/app/src/people/widgetViews/OrganizationView.tsx @@ -82,7 +82,7 @@ const Organizations = (props: { person: Person }) => { const isMobile = useIsMobile(); const config = widgetConfigs['organizations']; const formRef = useRef(null); - const isMyProfile = ui?.meInfo?.pubkey == props?.person?.owner_pubkey; + const isMyProfile = ui?.meInfo?.pubkey === props?.person?.owner_pubkey; const schema = [...config.schema]; @@ -247,8 +247,8 @@ const Organizations = (props: { person: Person }) => { style={ item.name === 'github_description' && !values.ticket_url ? { - display: 'none' - } + display: 'none' + } : undefined } /> diff --git a/frontend/app/src/store/main.ts b/frontend/app/src/store/main.ts index 2119ee6d6..3490bf3e0 100644 --- a/frontend/app/src/store/main.ts +++ b/frontend/app/src/store/main.ts @@ -714,7 +714,7 @@ export class MainStore { @persist('list') peopleWanteds: PersonWanted[] = []; - setPeopleWanteds(wanteds: PersonWanted[]) { + @action setPeopleWanteds(wanteds: PersonWanted[]) { this.peopleWanteds = wanteds; } @@ -771,19 +771,19 @@ export class MainStore { // for search always reset page if (queryParams && queryParams.resetPage) { - this.peopleWanteds = ps3; + this.setPeopleWanteds(ps3); uiStore.setPeopleWantedsPageNumber(1); } else { // all other cases, merge - this.peopleWanteds = this.doPageListMerger( + const wanteds = this.doPageListMerger( this.peopleWanteds, ps3, (n: any) => uiStore.setPeopleWantedsPageNumber(n), queryParams, 'wanted' ); + this.setPeopleWanteds(wanteds); } - this.setPeopleWanteds(ps3); return ps3; } catch (e) { console.log('fetch failed getPeopleWanteds: ', e); @@ -793,7 +793,7 @@ export class MainStore { personAssignedWanteds: PersonWanted[] = []; - setPersonWanteds(wanteds: PersonWanted[]) { + @action setPersonWanteds(wanteds: PersonWanted[]) { this.personAssignedWanteds = wanteds; } @@ -840,7 +840,7 @@ export class MainStore { createdWanteds: PersonWanted[] = []; - setCreatedWanteds(wanteds: PersonWanted[]) { + @action setCreatedWanteds(wanteds: PersonWanted[]) { this.createdWanteds = wanteds; } @@ -953,17 +953,19 @@ export class MainStore { // for search always reset page if (queryParams && queryParams.resetPage) { - this.peopleWanteds = ps3; + this.setPeopleWanteds(ps3); uiStore.setPeopleWantedsPageNumber(1); } else { // all other cases, merge - this.peopleWanteds = this.doPageListMerger( + const wanteds = this.doPageListMerger( this.peopleWanteds, ps3, (n: any) => uiStore.setPeopleWantedsPageNumber(n), queryParams, 'wanted' ); + + this.setPeopleWanteds(wanteds); } return ps3; } catch (e) {