ubk.erp.webpack 1.4.3 → 1.4.4

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/README.md CHANGED
@@ -562,15 +562,22 @@ const LibraryPage = ({ token }) => {
562
562
  import { AddStaff } from "ubk.erp.webpack";
563
563
 
564
564
  const AddStaffPage = ({ token }) => {
565
+ const handleStepComplete = (payload) => {
566
+ // Fires after Basic, Experience and Payroll each save successfully
567
+ console.log("Step saved:", payload.step, payload.staffId, payload.data);
568
+ };
569
+
565
570
  const handleFinished = (rec) => {
566
- // Optionally refresh staff list or show a notification
567
- console.log("Staff created successfully",rec);
571
+ // Fires once, after the final (Payroll) step saves
572
+ console.log("Staff created successfully", rec.staffId, rec);
568
573
  };
569
574
 
570
- return <AddStaff token={token} onFinished={handleFinished} />;
575
+ return <AddStaff token={token} onStepComplete={handleStepComplete} onFinished={handleFinished} />;
571
576
  };
572
577
  ```
573
578
 
579
+ `AddStaff` accepts the same callbacks as `StaffWizard` (`onStepComplete`, `onReturn`, `onFinished`) — see **StaffWizard — Return Callback** below. `onFinished` is only called after all three steps are saved.
580
+
574
581
  ### Store
575
582
 
576
583
  | Component | Description |
@@ -617,6 +624,7 @@ const AddStaffPage = ({ token }) => {
617
624
  | `onNavigate` | `(action: string, record: object) => void` | No | Called when the Edit button is clicked. Receives `("staff-edit", record)`. If provided, the parent handles navigation. |
618
625
  | `onFinished` | `(res: any) => void` | No | Called after the wizard (edit drawer) completes successfully. |
619
626
  | `onDelete` | `(payload: DeletePayload) => void` | No | Called after a staff member is deactivated. |
627
+ | `onPasswordChange` | `(payload: PasswordChangePayload) => void` | No | Called after a staff member's password is changed successfully. Receives `{ id, password, record, response }` — `password` is the new password as entered, `response` is the API response from `updateStaffPassword`. |
620
628
 
621
629
  ## DeletePayload Shape
622
630
 
@@ -632,6 +640,7 @@ const AddStaffPage = ({ token }) => {
632
640
 
633
641
  - Clicking the **Edit** button: if `onNavigate` is provided, it calls `onNavigate("staff-edit", record)`. Otherwise, opens an inline edit drawer with `StaffWizard` in `mode="edit"`.
634
642
  - Clicking **Delete/Deactivate**: sends a deactivate request to the API. On success, refreshes the list and calls `onDelete({ id, record, response })`.
643
+ - Clicking **Change password** (key icon): opens a modal with New Password + Confirm Password. On save it posts `{ staff_id, new_passwod }` to `api/branchapi/staff/updateStaffPassword` (override with `VITE_HR_STAFF_CHANGE_PASSWORD_URL`), then calls `onPasswordChange({ id, password, record, response })`.
635
644
  - `onFinished` fires after the edit wizard completes successfully, allowing the parent to refresh its own data.
636
645
 
637
646
  ## Usage
@@ -674,24 +683,26 @@ const StaffPage = ({ token }) => {
674
683
  | `mode` | `'add' \| 'edit'` | No | Determines whether basic info is edited or created. Default: `"add"`. |
675
684
  | `staffId` | `string` | No | Staff ID when editing; ignored when `mode="add"`. |
676
685
  | `onStepComplete` | `(payload: object) => void` | No | Called after **every** step's successful save. |
677
- | `onFinished` | `() => void` | No | Called after the final (Payroll) step completes. |
686
+ | `onReturn` | `(payload: object) => void` | No | Alias of `onStepComplete` — receives the same payload. |
687
+ | `onFinished` | `(result: object) => void` | No | Called after the final (Payroll) step completes. Receives `{ staffId, payroll, result, data }`. |
678
688
 
679
689
  ## Payload Shape
680
690
 
681
- The `onStepComplete` callback receives an object:
691
+ The `onStepComplete` / `onReturn` callback receives an object:
682
692
 
683
693
  ```ts
684
694
  {
685
695
  step: "basic" | "experience" | "payroll";
686
- data?: object; // Step-specific data
696
+ staffId: string | number | null; // id of the staff being created/edited
697
+ data: object; // Step-specific data (below)
687
698
  }
688
699
  ```
689
700
 
690
701
  | Step | `data` contents |
691
702
  | :--- | :--- |
692
- | `"basic"` | `{ staffId, basic }` from Step1's `onSubmitted` |
693
- | `"experience"` | `{ experience, result }` from Step2's `onSubmitted` |
694
- | `"payroll"` | `{ payroll, result }` from Step3's `onSubmitted` |
703
+ | `"basic"` | `{ staffId, basic, data }` from Step1 (`data` = raw API response) |
704
+ | `"experience"` | `{ experience, result, data }` from Step2 |
705
+ | `"payroll"` | `{ payroll, result, data }` from Step3 |
695
706
 
696
707
  ## Behavior
697
708
 
@@ -1,7 +1,8 @@
1
1
  import { default as React } from 'react';
2
2
  export default AddStaff;
3
- declare function AddStaff({ token, onFinished, onReturn }: {
3
+ declare function AddStaff({ token, onStepComplete, onFinished, onReturn }: {
4
4
  token: any;
5
+ onStepComplete: any;
5
6
  onFinished: any;
6
7
  onReturn: any;
7
8
  }): React.JSX.Element;
@@ -1,7 +1,8 @@
1
1
  import { default as React } from 'react';
2
2
  export default AddStaffPage;
3
- declare function AddStaffPage({ token, onFinished, onReturn }: {
3
+ declare function AddStaffPage({ token, onStepComplete, onFinished, onReturn }: {
4
4
  token: any;
5
+ onStepComplete: any;
5
6
  onFinished: any;
6
7
  onReturn: any;
7
8
  }): React.JSX.Element;
@@ -3,6 +3,7 @@ export const addStaffEndpoints: {
3
3
  searchByRole: any;
4
4
  searchByKeywords: any;
5
5
  deactivate: any;
6
+ changePassword: any;
6
7
  basicById: any;
7
8
  experienceById: any;
8
9
  payrollById: any;
@@ -6,6 +6,7 @@ export namespace endpoints {
6
6
  let searchByRole: any;
7
7
  let searchByKeywords: any;
8
8
  let deactivate: any;
9
+ let changePassword: any;
9
10
  let basicById: any;
10
11
  let experienceById: any;
11
12
  let payrollById: any;
@@ -1,8 +1,9 @@
1
1
  import { default as React } from 'react';
2
2
  export default StaffDirectoryPage;
3
- declare function StaffDirectoryPage({ token, onNavigate, onFinished, onDelete, }: {
3
+ declare function StaffDirectoryPage({ token, onNavigate, onFinished, onDelete, onPasswordChange, }: {
4
4
  token: any;
5
5
  onNavigate: any;
6
6
  onFinished: any;
7
7
  onDelete: any;
8
+ onPasswordChange: any;
8
9
  }): React.JSX.Element;
@@ -3,6 +3,7 @@ export const staffEndpoints: {
3
3
  searchByRole: any;
4
4
  searchByKeywords: any;
5
5
  deactivate: any;
6
+ changePassword: any;
6
7
  basicById: any;
7
8
  experienceById: any;
8
9
  payrollById: any;
@@ -1,8 +1,9 @@
1
1
  import { default as React } from 'react';
2
2
  export default StaffDirectory;
3
- declare function StaffDirectory({ token, onNavigate, onFinished, onDelete }: {
3
+ declare function StaffDirectory({ token, onNavigate, onFinished, onDelete, onPasswordChange }: {
4
4
  token: any;
5
5
  onNavigate: any;
6
6
  onFinished: any;
7
7
  onDelete: any;
8
+ onPasswordChange: any;
8
9
  }): React.JSX.Element;
@@ -1,9 +1,10 @@
1
1
  import { default as React } from 'react';
2
2
  export default StaffWizard;
3
- declare function StaffWizard({ token, mode, staffId: staffIdProp, onStepComplete, onFinished, }: {
3
+ declare function StaffWizard({ token, mode, staffId: staffIdProp, onStepComplete, onFinished, onReturn, }: {
4
4
  token: any;
5
5
  mode?: string | undefined;
6
6
  staffId: any;
7
7
  onStepComplete: any;
8
8
  onFinished: any;
9
+ onReturn: any;
9
10
  }): React.JSX.Element;