@kanda-libs/ks-component-ts 0.2.209 → 0.2.211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanda-libs/ks-component-ts",
3
- "version": "0.2.209",
3
+ "version": "0.2.211",
4
4
  "description": "Kanda form component library",
5
5
  "main": "dist/index.esm.js",
6
6
  "module": "dist/index.esm.js",
@@ -0,0 +1,11 @@
1
+ import type { StringIndexedObject } from "~/types";
2
+
3
+ // Without explicitly mentioning this class, it won't appear in the tailwind
4
+ // config build as COMPANY_RISK_FLAG_STROKES passes to Icon which uses string concatenation
5
+ export const COMPANY_RISK_YELLOW = "text-yellow";
6
+
7
+ export const COMPANY_RISK_FLAG_STROKES: StringIndexedObject<string> = {
8
+ red: "red-200",
9
+ yellow: "yellow",
10
+ green: "green-500",
11
+ };
@@ -0,0 +1,31 @@
1
+ import React, { type FunctionComponent } from "react";
2
+ import { Icon } from "@kanda-libs/ks-design-library";
3
+ import type { Monitor } from "generated/components/schemas";
4
+ import type { StringIndexedObject } from "~/types";
5
+ import { COMPANY_RISK_FLAG_STROKES } from "./constants";
6
+ import useCompanyRiskFlag from "./useCompanyRiskFlag";
7
+
8
+ export interface CompanyRiskFlagProps {
9
+ id?: string;
10
+ monitors?: StringIndexedObject<Monitor>;
11
+ className?: string;
12
+ }
13
+
14
+ const CompanyRiskFlag: FunctionComponent<CompanyRiskFlagProps> = function ({
15
+ id,
16
+ monitors = {},
17
+ className = "",
18
+ }) {
19
+ const { level } = useCompanyRiskFlag(id, monitors);
20
+
21
+ return (
22
+ <Icon
23
+ icon="flag"
24
+ size={18}
25
+ stroke={COMPANY_RISK_FLAG_STROKES[level as string]}
26
+ className={className}
27
+ />
28
+ );
29
+ };
30
+
31
+ export default CompanyRiskFlag;
@@ -0,0 +1,17 @@
1
+ import type { Flag, Monitor } from "@kanda-libs/ks-frontend-services";
2
+ import type { StringIndexedObject } from "~/types";
3
+
4
+ export interface CompanyRiskFlagHook {
5
+ level?: Flag["level"];
6
+ }
7
+
8
+ export default function useCompanyRiskFlag(
9
+ id: string = "",
10
+ monitors: StringIndexedObject<Monitor>
11
+ ): CompanyRiskFlagHook {
12
+ const monitor = monitors[id];
13
+
14
+ return {
15
+ level: monitor?.flag?.level || "green",
16
+ };
17
+ }
@@ -1,4 +1,5 @@
1
1
  export { default as AddFieldButton } from "./AddFieldButton";
2
+ export { default as CompanyRiskFlag } from "./CompanyRiskFlag";
2
3
  export { default as Dropzone } from "./Dropzone";
3
4
  export { default as DropzoneContext } from "./Dropzone/DropzoneContext";
4
5
  export { default as FieldHandle } from "./Handle";
@@ -1,6 +1,7 @@
1
1
  import * as t from "io-ts";
2
2
 
3
3
  export const CompanyDirectorReport = t.type({
4
+ people_id: t.string,
4
5
  number_of_current_appointments: t.number,
5
6
  current_appointment_ccj: t.number,
6
7
  number_of_inactive_appointments: t.number,
@@ -11,6 +12,7 @@ export const CompanyDirectorReport = t.type({
11
12
  });
12
13
 
13
14
  export interface CompanyDirectorReport {
15
+ people_id: string;
14
16
  number_of_current_appointments: number;
15
17
  current_appointment_ccj: number;
16
18
  number_of_inactive_appointments: number;