Skip to content

Commit

Permalink
Merge branch 'main' into ft/bulk-stock-item-import
Browse files Browse the repository at this point in the history
  • Loading branch information
makombe authored Jan 15, 2024
2 parents 9d901c4 + 9e96211 commit 3883838
Show file tree
Hide file tree
Showing 44 changed files with 10,488 additions and 12,216 deletions.
541 changes: 0 additions & 541 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

550 changes: 0 additions & 550 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

This file was deleted.

10 changes: 4 additions & 6 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
nodeLinker: node-modules
compressionLevel: mixed

enableGlobalCache: false

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.3.cjs
27 changes: 10 additions & 17 deletions src/config-schema.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import { Type, validator } from "@openmrs/esm-framework";
import { Type } from "@openmrs/esm-framework";
export const configSchema = {
casualGreeting: {
_type: Type.Boolean,
printItemCost: {
type: Type.Boolean,
_default: false,
_description: "Whether to use a casual greeting (or a formal one).",
_description: "Whether to print item costs on the print out",
},
whoToGreet: {
_type: Type.Array,
_default: ["World"],
_description:
"Who should be greeted. Names will be separated by a comma and space.",
_elements: {
_type: Type.String,
},
_validators: [
validator((v) => v.length > 0, "At least one person must be greeted."),
],
printBalanceOnHand: {
type: Type.Boolean,
_default: false,
_description: "Whether to print balance on hand on the print out",
},
};

export type Config = {
casualGreeting: boolean;
whoToGreet: Array<string>;
printItemCost: boolean;
printBalanceOnHand: boolean;
};
96 changes: 96 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,99 @@ export const PRINT_LOGO =
export const PRINT_LOGO_TEXT = "Ministry of Health";

export const MAIN_STORE_LOCATION_TAG = "Main Store";

export const BASE_OPENMRS_APP_URL = "/openmrs/";

export const STOCKMGMT_RESOURCE_URL = "/openmrs/stockmanagement/spa.page/";
export const STOCKMGMT_SPA_PAGE_URL = "/openmrs/stockmanagement/spa.page";
export const URL_PRINT_LOGO = () =>
PRINT_LOGO
? `${BASE_OPENMRS_APP_URL}${PRINT_LOGO}`
: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
export const CLOSE_PRINT_AFTER_PRINT = true;
export const ALLOW_STOCK_ISSUE_WITHOUT_REQUISITION = false;

export const BASE_URL_CONFIGURED = BASE_OPENMRS_APP_URL;
export const LOGIN_URL = BASE_OPENMRS_APP_URL + "login.htm";

export const ROUTING_BASE_URL = "/";
export const URL_STOCK_HOME = ROUTING_BASE_URL + "home";

export const URL_STOCK_OPERATIONS = ROUTING_BASE_URL + "stock-operations";
export const URL_STOCK_OPERATIONS_ROUTES = URL_STOCK_OPERATIONS + "/*";
export const URL_STOCK_OPERATIONS_NEW = URL_STOCK_OPERATIONS + "/new/*";
export const URL_STOCK_OPERATIONS_NEW_OPERATION = (
name: string,
requisitionUuid?: string
): string =>
`${URL_STOCK_OPERATIONS}/new/${name}${
requisitionUuid ? `?requisition=${requisitionUuid}` : ""
}`;
export const URL_STOCK_OPERATIONS_EDIT = URL_STOCK_OPERATIONS + "/:id";
export const URL_STOCK_OPERATIONS_REDIRECT = (
uuid: string,
tab?: string
): string =>
`${URL_STOCK_OPERATIONS}/redirect/${uuid}${tab ? `?tab=${tab}` : ""}`;
export const URL_STOCK_OPERATION = (uuid: string, tab?: string): string =>
`${URL_STOCK_OPERATIONS}/${uuid}${tab ? `?tab=${tab}` : ""}`;

export const URL_USER_ROLE_SCOPES = ROUTING_BASE_URL + "user-role-scopes";
export const URL_USER_ROLE_SCOPES_ROUTES = URL_USER_ROLE_SCOPES + "/*";
export const URL_USER_ROLE_SCOPES_NEW = URL_USER_ROLE_SCOPES + "/new";
export const URL_USER_ROLE_SCOPES_EDIT = URL_USER_ROLE_SCOPES + "/:id";
export const URL_USER_ROLE_SCOPE = (uuid: string): string =>
`${URL_USER_ROLE_SCOPES}/${uuid}`;

export const URL_STOCK_ITEMS = ROUTING_BASE_URL + "stock-items";
export const URL_STOCK_ITEMS_ROUTES = ROUTING_BASE_URL + "stock-items/*";
export const URL_STOCK_ITEMS_NEW = URL_STOCK_ITEMS + "/new";
export const URL_STOCK_ITEMS_EDIT = URL_STOCK_ITEMS + "/:id";
export const URL_STOCK_ITEM = (uuid: string, tab?: string): string =>
`${URL_STOCK_ITEMS}/${uuid}${tab ? `?tab=${tab}` : ""}`;
export const URL_STOCK_ITEMS_REDIRECT = (uuid: string, tab?: string): string =>
`${URL_STOCK_ITEMS}/redirect/${uuid}${tab ? `?tab=${tab}` : ""}`;
export const URL_IMPORT_ERROR_FILE = (importSessionId: string) =>
`${BASE_OPENMRS_APP_URL}ws/rest/v1/stockmanagement/stockitemimport?id=${importSessionId}`;
export const URL_IMPORT_TEMPLATE_FILE = `${BASE_OPENMRS_APP_URL}moduleResources/stockmanagement/templates/Import_Stock_Items.xlsx`;

export const URL_STOCK_SOURCES = ROUTING_BASE_URL + "stock-sources";
export const URL_STOCK_SOURCES_ROUTES = URL_STOCK_SOURCES + "/*";

export const URL_SIGN_IN = ROUTING_BASE_URL + "sign-in";
export const URL_SIGN_OUT = ROUTING_BASE_URL + "sign-out";

export const URL_ACCESS_DENIED = ROUTING_BASE_URL + "access-denied";
export const URL_NOT_FOUND = "/*";
export const URL_WILDCARD = "*";

export const REACT_ROUTER_PREFIX = "#";

export const URL_LOCATIONS = ROUTING_BASE_URL + "locations";
export const URL_LOCATIONS_ROUTES = ROUTING_BASE_URL + "locations/*";
export const URL_LOCATIONS_NEW = () =>
`${BASE_OPENMRS_APP_URL}admin/locations/location.form`;
export const URL_LOCATIONS_EDIT = (id: number) =>
`${BASE_OPENMRS_APP_URL}admin/locations/location.form?locationId=${id}`;

export const URL_STOCK_REPORTS = ROUTING_BASE_URL + "stock-reports";
export const URL_STOCK_REPORTS_ROUTES = ROUTING_BASE_URL + "stock-reports/*";
export const URL_STOCK_REPORT = (uuid: string): string =>
`${URL_STOCK_REPORTS}/${uuid}`;
export const URL_BATCH_JOB_ARTIFACT = (
uuid: string,
download: boolean
): string =>
`${BASE_OPENMRS_APP_URL}ws/rest/v1/stockmanagement/batchjobartifact?id=${uuid}${
download ? "&download=1" : ""
}`;

export function extractErrorMessagesFromResponse(errorObject) {
const fieldErrors = errorObject?.responseBody?.error?.fieldErrors;
if (!fieldErrors) {
return [errorObject?.responseBody?.error?.message ?? errorObject?.message];
}
return Object.values(fieldErrors).flatMap((errors: Array<Error>) =>
errors.map((error) => error.message)
);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import { Control, Controller, FieldValues } from "react-hook-form";
import { ComboBox } from "@carbon/react";
import { ComboBoxProps } from "@carbon/react/lib/components/ComboBox/ComboBox";

interface ControlledComboBoxProps<T> extends ComboBoxProps {
interface ControlledComboBoxProps<T> {
controllerName: string;
name: string;
control: Control<FieldValues, T>;
onChange?: (e: { selectedItem: never }) => void;
}

const ControlledComboBox = <T,>(props: ControlledComboBoxProps<T>) => {
Expand Down
Loading

0 comments on commit 3883838

Please sign in to comment.