@star-insure/sdk 3.1.1 → 3.1.3

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.
@@ -25,6 +25,7 @@ export declare type TPageHeaderAction = {
25
25
  target?: '_self' | '_blank';
26
26
  onClick?: Function;
27
27
  type?: 'button' | 'submit';
28
+ hidden?: boolean;
28
29
  };
29
30
  export declare type Environment = 'production' | 'staging' | 'testing' | 'local';
30
31
  export declare type Breadcrumb = {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@star-insure/sdk",
3
3
  "description": "The SDK for Star Insure client apps with shared helper functions and TypeScript definitions.",
4
4
  "author": "alexclark_nz",
5
- "version": "3.1.1",
5
+ "version": "3.1.3",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -12,6 +12,7 @@ export function BackButton({ back }: { back?: string | boolean }) {
12
12
  */
13
13
  React.useEffect(() => {
14
14
  if (typeof window !== 'undefined') {
15
+ if (!breadcrumbs) return;
15
16
  // Set back button URL
16
17
  if (back && typeof back === 'boolean') {
17
18
  // If we haven't provided a path as a prop, use the last breadcrumb that's not the current one
@@ -133,6 +133,10 @@ export default function PageHeader({
133
133
  checkScroll();
134
134
  }
135
135
 
136
+ const filteredActions = React.useMemo(() => {
137
+ return actions.filter(action => !action.hidden);
138
+ }, [actions]);
139
+
136
140
  return (
137
141
  <section className={cn('col-span-full max-w-full rounded-lg bg-white p-2 shadow', className)}>
138
142
  <div className={cn('grid grid-cols-[auto_1fr_auto] min-h-[60px] rounded gap-4 bg-gray-100 p-3', innerClassName)}>
@@ -160,11 +164,11 @@ export default function PageHeader({
160
164
  )}
161
165
  </div>
162
166
 
163
- {actions.length > 0 && (
167
+ {filteredActions.length > 0 && (
164
168
  <div className="flex items-center gap-3">
165
169
  {filterOptions.length > 0 && <div className="w-[1px] h-full bg-gray-300" />}
166
170
  <nav className="flex items-center gap-2">
167
- {actions.map((action) => (
171
+ {filteredActions.map((action) => (
168
172
  <Action key={`${action.title}-${action.as}-${action.href}`} {...action} />
169
173
  ))}
170
174
  </nav>
package/src/lib/page.tsx CHANGED
@@ -7,7 +7,7 @@ import { AuthContext, Breadcrumb, Environment } from '../types';
7
7
  */
8
8
  type CustomPageProps = {
9
9
  env: Environment;
10
- breadcrumbs: Breadcrumb[];
10
+ breadcrumbs?: Breadcrumb[];
11
11
  links: Record<string, string>;
12
12
  access_token?: string;
13
13
  impersonate_id?: number;
@@ -30,6 +30,7 @@ export type TPageHeaderAction = {
30
30
  target?: '_self' | '_blank';
31
31
  onClick?: Function;
32
32
  type?: 'button' | 'submit';
33
+ hidden?: boolean;
33
34
  };
34
35
 
35
36
  export type Environment = 'production' | 'staging' | 'testing' | 'local';