Skip to content

Commit

Permalink
Merge pull request #483 from bcgov/development
Browse files Browse the repository at this point in the history
Merge dev into master
  • Loading branch information
IanFonzie authored Jul 10, 2024
2 parents a230432 + fd63c92 commit 7a59284
Show file tree
Hide file tree
Showing 16 changed files with 265 additions and 109 deletions.
28 changes: 17 additions & 11 deletions src/back-end/lib/db/affiliation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ export interface RawHistoryRecord

async function rawAffiliationToAffiliation(
connection: Connection,
params: RawAffiliation
params: RawAffiliation,
allowInactive = false
): Promise<Affiliation> {
const { user: userId, organization: orgId } = params;
const organization = getValidValue(
await readOneOrganization(connection, orgId, false),
await readOneOrganization(connection, orgId, allowInactive),
null
);
const user = getValidValue(await readOneUser(connection, userId), null);
Expand Down Expand Up @@ -136,8 +137,8 @@ export const readOneAffiliation = tryDb<[Id, Id], Affiliation | null>(
);

export const readOneAffiliationById = tryDb<[Id, boolean?], Affiliation | null>(
async (connection, id, activeOnly = true) => {
const result = await connection<RawAffiliation>("affiliations")
async (connection, id, allowInactive = false) => {
let query = connection<RawAffiliation>("affiliations")
.join(
"organizations",
"affiliations.organization",
Expand All @@ -146,16 +147,21 @@ export const readOneAffiliationById = tryDb<[Id, boolean?], Affiliation | null>(
)
.select<RawAffiliation>("affiliations.*")
.where({ "affiliations.id": id })
.andWhereNot({
...(activeOnly
? { "affiliations.membershipStatus": MembershipStatus.Inactive }
: {}),
"organizations.active": false
})
.first();

if (!allowInactive) {
query = query.andWhereNot({
"affiliations.membershipStatus": MembershipStatus.Inactive,
"organizations.active": false
});
}

const result = await query;

return valid(
result ? await rawAffiliationToAffiliation(connection, result) : null
result
? await rawAffiliationToAffiliation(connection, result, allowInactive)
: null
);
}
);
Expand Down
6 changes: 4 additions & 2 deletions src/back-end/lib/db/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import { Counter } from "shared/lib/resources/counter";
export const incrementCounters = tryDb<[string[]], Record<string, number>>(
async (connection, names) => {
// Update existing counters
const existingCounters: string[] = await connection<Counter>("viewCounters")
const existingCounters: { name: string }[] = await connection<Counter>(
"viewCounters"
)
.whereIn("name", names)
.increment("count")
.update({}, "name");

// Create new counters where applicable
for (const name of names) {
if (!existingCounters.includes(name)) {
if (!existingCounters.some(({ name: eName }) => eName === name)) {
await connection<Counter>("viewCounters").insert({
name,
count: 1
Expand Down
10 changes: 5 additions & 5 deletions src/back-end/lib/db/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async function rawHistoryRecordToHistoryRecord(
const { affiliation: affilationId, event: type, ...restOfRaw } = value;

const affiliation = getValidValue(
await readOneAffiliationById(connection, affilationId, false),
await readOneAffiliationById(connection, affilationId, true),
null
);

Expand Down Expand Up @@ -365,15 +365,14 @@ export const readOneOrganization = tryDb<
query = query.andWhere({ "organizations.active": true });
}

const resultWithViewerIsOrgAdmin = await query.first<
RawOrganization & { viewerIsOrgAdmin: boolean }
const result = await query.first<
RawOrganization & { viewerIsOrgAdmin?: boolean }
>();
const { viewerIsOrgAdmin, ...result } = resultWithViewerIsOrgAdmin;
if (result) {
if (
!session ||
(isVendor(session) &&
!(result.owner === session.user?.id || viewerIsOrgAdmin))
!(result.owner === session.user?.id || result.viewerIsOrgAdmin))
) {
delete result.owner;
delete result.numTeamMembers;
Expand Down Expand Up @@ -412,6 +411,7 @@ export const readOneOrganization = tryDb<
)
)
);
delete result.viewerIsOrgAdmin;
}
}
return valid(
Expand Down
2 changes: 1 addition & 1 deletion src/back-end/lib/db/proposal/code-with-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async function rawCWUProposalSlimToCWUProposalSlim(
: null;
const proponentOrganization = proponentOrganizationId
? getValidValue(
await readOneOrganization(connection, proponentOrganizationId),
await readOneOrganization(connection, proponentOrganizationId, true),
undefined
)
: null;
Expand Down
7 changes: 6 additions & 1 deletion src/back-end/lib/resources/opportunity/team-with-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,12 @@ const delete_: crud.Delete<
if (isInvalid(validatedTWUOpportunity)) {
return invalid({ notFound: ["Opportunity not found."] });
}
if (validatedTWUOpportunity.value.status !== TWUOpportunityStatus.Draft) {
if (
![
TWUOpportunityStatus.Draft,
TWUOpportunityStatus.UnderReview
].includes(validatedTWUOpportunity.value.status)
) {
return invalid({ permissions: [permissions.ERROR_MESSAGE] });
}
return valid(validatedTWUOpportunity.value.id);
Expand Down
6 changes: 0 additions & 6 deletions src/front-end/sass/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -964,12 +964,6 @@ nav.navbar .nav-link:hover {
}
}

.twu-banner {
background-color: $c-banner-bg;
padding: 0.75rem 0 0.75rem;
z-index: 1001; // Above nav, below modals
}

.li-paren {
counter-reset: list;
& > li {
Expand Down
2 changes: 0 additions & 2 deletions src/front-end/typescript/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,3 @@ export const CWU_PAYMENT_OPTIONS_URL =

export const TWU_BC_BID_URL =
"https://bcbid.gov.bc.ca/page.aspx/en/bpm/process_manage_extranet/176305";

export const TWU_BANNER_ACKNOWLEDGED = "twu-banner-acknowledged";
7 changes: 1 addition & 6 deletions src/front-end/typescript/lib/app/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { TWU_BANNER_ACKNOWLEDGED } from "front-end/config";
import { State, Msg } from "front-end/lib/app/types";
import * as Nav from "front-end/lib/app/view/nav";
import * as AcceptNewTerms from "front-end/lib/components/accept-new-app-terms";
Expand All @@ -16,7 +15,6 @@ const init: component.base.Init<null, State, Msg> = () => {
const [navState, navCmds] = Nav.init(null);
return [
{
showTWUBanner: false,
ready: false,
incomingRoute: null,
toasts: [],
Expand All @@ -35,10 +33,7 @@ const init: component.base.Init<null, State, Msg> = () => {
acceptNewTermsCmds,
(msg) => adt("acceptNewTerms", msg) as Msg
),
...component.cmd.mapMany(navCmds, (msg) => adt("nav", msg) as Msg),
component.cmd.localStorage.getItem(TWU_BANNER_ACKNOWLEDGED, (msg) =>
adt("setShowTWUBanner", !msg)
)
...component.cmd.mapMany(navCmds, (msg) => adt("nav", msg) as Msg)
]
];
};
Expand Down
2 changes: 0 additions & 2 deletions src/front-end/typescript/lib/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export type ModalId = "acceptNewTerms";
export interface State {
//App Internal State
ready: boolean;
showTWUBanner: boolean;
incomingRoute: router.IncomingRoute<Route> | null;
activeRoute: Route;
//Toasts
Expand Down Expand Up @@ -229,7 +228,6 @@ export type InnerMsg =
| ADT<"submitAcceptNewTerms">
| ADT<"onAcceptNewTermsResponse", AcceptNewTerms.AcceptNewTermsResponse>
| ADT<"nav", Nav.Msg>
| ADT<"setShowTWUBanner", boolean>
| ADT<"pageLanding", PageLanding.Msg>
| ADT<"pageDashboard", PageDashboard.Msg>
| ADT<"pageOpportunities", PageOpportunities.Msg>
Expand Down
19 changes: 1 addition & 18 deletions src/front-end/typescript/lib/app/update.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
TOAST_AUTO_DISMISS_DURATION,
TWU_BANNER_ACKNOWLEDGED
} from "front-end/config";
import { TOAST_AUTO_DISMISS_DURATION } from "front-end/config";
import { makeStartLoading, makeStopLoading } from "front-end/lib";
import router from "front-end/lib/app/router";
import {
Expand Down Expand Up @@ -915,20 +912,6 @@ const update: component.base.Update<State, Msg> = ({ state, msg }) => {
mapChildMsg: adtCurried<ADT<"nav", Nav.Msg>>("nav")
});

case "setShowTWUBanner":
return [
state.set("showTWUBanner", msg.value),
!msg.value
? [
component.cmd.localStorage.setItem(
TWU_BANNER_ACKNOWLEDGED,
TWU_BANNER_ACKNOWLEDGED,
adt("noop") as Msg
)
]
: []
];

case "pageOrgEdit":
return component.app.updatePage({
...defaultPageUpdateParams,
Expand Down
5 changes: 0 additions & 5 deletions src/front-end/typescript/lib/app/view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ import { SHOW_TEST_INDICATOR } from "shared/config";
import { hasAcceptedTermsOrIsAnonymous } from "shared/lib/resources/session";
import { UserType } from "shared/lib/resources/user";
import { ADT, adt, adtCurried } from "shared/lib/types";
import TWUBannner from "front-end/lib/app/view/twu-banner";

function makeViewPageProps<RouteParams, PageState, PageMsg>(
props: component_.base.ComponentViewProps<State, Msg>,
Expand Down Expand Up @@ -890,10 +889,6 @@ const view: component_.base.ComponentView<State, Msg> = (props) => {
navProps.contextualActions ? "contextual-actions-visible" : ""
} app d-flex flex-column`}
style={{ minHeight: "100vh" }}>
<TWUBannner
show={state.showTWUBanner}
onClose={() => dispatch(adt("setShowTWUBanner", false))}
/>
<Nav.view {...navProps} />
<ViewPage {...viewPageProps} />
{viewPageProps.component.simpleNav ? null : <Footer />}
Expand Down
46 changes: 0 additions & 46 deletions src/front-end/typescript/lib/app/view/twu-banner.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,8 @@ const ReviewProposalView: component_.base.View<Props> = ({
dispatch
}) => {
const phaseMembers = Team.getAddedMembers(state.team);
const organization = getSelectedOrganization(state);
const organization =
state.proposal?.organization ?? getSelectedOrganization(state);
const opportunity = state.opportunity;
return (
<Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,8 @@ const ReviewProposalView: component_.base.View<Props> = ({
state,
dispatch
}) => {
const organization = getSelectedOrganization(state);
const organization =
state.proposal?.organization ?? getSelectedOrganization(state);
const team = Team.getValues(state.team);
const resourcesWithMemberSelections = state.opportunity.resources.map(
(resource) => {
Expand Down
4 changes: 2 additions & 2 deletions src/shared/lib/resources/opportunity/team-with-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export { Addendum } from "shared/lib/resources/addendum";

export const DEFAULT_OPPORTUNITY_TITLE = "Untitled";
export const DEFAULT_QUESTIONS_WEIGHT = 25;
export const DEFAULT_CODE_CHALLENGE_WEIGHT = 50;
export const DEFAULT_PRICE_WEIGHT = 25;
export const DEFAULT_CODE_CHALLENGE_WEIGHT = 65;
export const DEFAULT_PRICE_WEIGHT = 10;
export const MAX_RESOURCE_QUESTIONS = 100;
export const MAX_RESOURCE_QUESTION_WORD_LIMIT = 3000;
export const DEFAULT_RESOURCE_QUESTION_RESPONSE_WORD_LIMIT = 300;
Expand Down
Loading

0 comments on commit 7a59284

Please sign in to comment.