- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
New Components - talenthr #14078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Components - talenthr #14078
Changes from all commits
6ac3fac
              388f1aa
              5d57988
              7d37b30
              78f96fb
              1061d05
              c28dd7e
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,182 @@ | ||||||
| import { | ||||||
| OVERTIME_STATUS, | ||||||
| PAY_RATE_PERIOD_OPTIONS, | ||||||
| PAY_RATE_SCHEDULE_OPTIONS, | ||||||
| } from "../../common/constants.mjs"; | ||||||
| import talenthr from "../../talenthr.app.mjs"; | ||||||
|  | ||||||
| export default { | ||||||
| key: "talenthr-create-employee", | ||||||
| name: "Create Employee", | ||||||
| description: "Hires a new employee and registers them in the system. [See the documentation](https://apidocs.talenthr.io/#2950f0ba-b27b-4d4b-855f-4b79b667767c)", | ||||||
| version: "0.0.1", | ||||||
| type: "action", | ||||||
| props: { | ||||||
| talenthr, | ||||||
| firstName: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "firstName", | ||||||
| ], | ||||||
| }, | ||||||
| lastName: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "lastName", | ||||||
| ], | ||||||
| }, | ||||||
| email: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "email", | ||||||
| ], | ||||||
| }, | ||||||
| hireDate: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "hireDate", | ||||||
| ], | ||||||
| }, | ||||||
| employmentStatusId: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "employmentStatusId", | ||||||
| ], | ||||||
| }, | ||||||
| reportsToEmployeeId: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "employeeId", | ||||||
| ], | ||||||
| optional: true, | ||||||
| }, | ||||||
| jobTitleId: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "jobTitleId", | ||||||
| ], | ||||||
| optional: true, | ||||||
| }, | ||||||
| jobLocationId: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "jobLocationId", | ||||||
| ], | ||||||
| optional: true, | ||||||
| }, | ||||||
| divisionId: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "divisionId", | ||||||
| ], | ||||||
| optional: true, | ||||||
| }, | ||||||
| departmentId: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "departmentId", | ||||||
| ], | ||||||
| optional: true, | ||||||
| }, | ||||||
| payRate: { | ||||||
| type: "string", | ||||||
| label: "Pay Rate", | ||||||
| description: "Employee's wage and must have 2 decimals. E.g 1255.38", | ||||||
| }, | ||||||
| payRatePeriod: { | ||||||
| type: "string", | ||||||
| label: "Pay Rate Period", | ||||||
| description: "The period over which money is earned.", | ||||||
| options: PAY_RATE_PERIOD_OPTIONS, | ||||||
| }, | ||||||
| payRateSchedule: { | ||||||
| type: "string", | ||||||
| label: "Pay Rate Schedule", | ||||||
| description: "Frequency of the wage.", | ||||||
| options: PAY_RATE_SCHEDULE_OPTIONS, | ||||||
| optional: true, | ||||||
| }, | ||||||
| overtimeStatus: { | ||||||
| type: "string", | ||||||
| label: "Overtime Status", | ||||||
| description: "Determining whether an employee is exempt or non-exempt from overtime regulations.", | ||||||
| options: OVERTIME_STATUS, | ||||||
| optional: true, | ||||||
| }, | ||||||
| preventEmail: { | ||||||
| type: "boolean", | ||||||
| label: "Prevent Email", | ||||||
| description: "Opt for 'true', if you don't want to send an invitation email to the hiring employee, else 'false'.", | ||||||
| optional: true, | ||||||
| }, | ||||||
| isExisting: { | ||||||
| type: "boolean", | ||||||
| label: "Is Existing", | ||||||
| description: "Opt for 'false' if the employee is a new hire and you want to run the Automatic Onboarding process, else 'true'.", | ||||||
| optional: true, | ||||||
| }, | ||||||
| whoId: { | ||||||
| type: "integer", | ||||||
| label: "Who Id", | ||||||
| description: "The employee who will meet the newly hired employee. Required if **When Time** and address is present.", | ||||||
| optional: true, | ||||||
| }, | ||||||
| address: { | ||||||
| propDefinition: [ | ||||||
| talenthr, | ||||||
| "address", | ||||||
| ], | ||||||
| optional: true, | ||||||
| }, | ||||||
| whenTime: { | ||||||
| type: "string", | ||||||
| label: "When Time", | ||||||
| description: "The date time that the meeting will take place. Required if **Who Id** and address is present. The hire date must be formatted as 'YYYY-MM-DD HH:II'.", | ||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the description for 'whenTime' property The description for  Apply this diff: -          description: "The date time that the meeting will take place. Required if **Who Id** and address is present. The hire date must be formatted as 'YYYY-MM-DD HH:II'.",
+          description: "The date and time that the meeting will take place. Required if **Who Id** and address is present. The date and time must be formatted as 'YYYY-MM-DD HH:II'.",📝 Committable suggestion
 
        Suggested change
       
 | ||||||
| optional: true, | ||||||
| }, | ||||||
| 
      Comment on lines
    
      +119
     to 
      +136
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add validation for dependent fields 'whoId', 'whenTime', and 'address' The properties  You could add a validation check like this before making the API call: if (
  (this.whoId || this.whenTime || this.address) &&
  !(this.whoId && this.whenTime && this.address)
) {
  throw new Error("When providing 'whoId', 'whenTime', or 'address', all three fields must be provided together.");
} | ||||||
| instructions: { | ||||||
| type: "string", | ||||||
| label: "Instructions", | ||||||
| description: "Important Instructions for the newly hired employee.", | ||||||
| optional: true, | ||||||
| }, | ||||||
| }, | ||||||
| async run({ $ }) { | ||||||
| const response = await this.talenthr.createEmployee({ | ||||||
| $, | ||||||
| data: { | ||||||
| first_name: this.firstName, | ||||||
| last_name: this.lastName, | ||||||
| email: this.email, | ||||||
| hire_date: this.hireDate, | ||||||
| employment_status: { | ||||||
| employment_status_id: this.employmentStatusId, | ||||||
| }, | ||||||
| reports_to_employee_id: this.reportsToEmployeeId, | ||||||
| job_record: { | ||||||
| job_title_id: this.jobTitleId, | ||||||
| location_id: this.jobLocationId, | ||||||
| division_id: this.divisionId, | ||||||
| department_id: this.departmentId, | ||||||
| }, | ||||||
| compensation_record: { | ||||||
| pay_rate: parseFloat(this.payRate), | ||||||
| pay_rate_period: this.payRatePeriod, | ||||||
| pay_rate_schedule: this.payRateSchedule, | ||||||
| overtime_status: this.overtimeStatus, | ||||||
| }, | ||||||
| prevent_email: this.preventEmail, | ||||||
| is_existing: this.isExisting, | ||||||
| hire_packet: { | ||||||
| who_id: this.whoId, | ||||||
| address: this.address, | ||||||
| when_time: this.whenTime, | ||||||
| instructions: this.instrwuctions, | ||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in property value 'this.instrwuctions' There's a typo in  Apply this diff to fix the typo: -              instructions: this.instrwuctions,
+              instructions: this.instructions,📝 Committable suggestion
 
        Suggested change
       
 | ||||||
| }, | ||||||
| }, | ||||||
| }); | ||||||
|  | ||||||
| $.export("$summary", `Successfully created employee: ${response.data.id}`); | ||||||
| return response; | ||||||
| }, | ||||||
| }; | ||||||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import talenthr from "../../talenthr.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "talenthr-respond-time-off-request", | ||
| name: "Respond to Time Off Request", | ||
| description: "Responds to an employee's time off request. This action requires the request ID and the response status as props. [See the documentation](https://apidocs.talenthr.io/)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| talenthr, | ||
| employeeId: { | ||
| propDefinition: [ | ||
| talenthr, | ||
| "employeeId", | ||
| ], | ||
| }, | ||
| timeOffRequestId: { | ||
| propDefinition: [ | ||
| talenthr, | ||
| "timeOffRequestId", | ||
| ({ employeeId }) => ({ | ||
| employeeId, | ||
| }), | ||
| ], | ||
| }, | ||
| accept: { | ||
| type: "boolean", | ||
| label: "Accept", | ||
| description: "Approve 'true' or Reject 'false' the specified time off request. If the time off request has been answered or it has been cancelled then you cannot appove or reject it.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.talenthr.respondToTimeOffRequest({ | ||
| timeOffRequestId: this.timeOffRequestId, | ||
| employeeId: this.employeeId, | ||
| data: { | ||
| accept: this.accept, | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", `Successfully responded to time off request with ID ${this.timeOffRequestId}`); | ||
| return response; | ||
| }, | ||
| }; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider changing 'payRate' type to 'number'
Since
payRaterepresents a numeric value, it would be more appropriate to set its type to"number"instead of"string". This ensures proper validation and handling of numerical input.Apply this diff:
📝 Committable suggestion