A package that simplifies the work hour management system (get/post) process.
- add
id
toUploadConfig
. - fix
upload
function error handling
Using npm:
$ npm install whms
In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with require()
use the following approach:
const whms = require("whms").default;
// whms.<method> will now provide autocomplete and parameter typings
Upload Work Reocrd List to database
import whms from "whms";
whms.upload({
id: 69,
employeeAccount: "John Doe",
projectCode: "C000",
content: "This is a content",
dateStart: "2021-09-06",
dateEnd: "2021-09-08",
passHoliday: true,
exclude: ["2021-09-07"],
}).then((response) => {
console.log(response);
});
Get data from work hour management system
import whms from 'whms';
whms.get({
method: "getProjects",
data: {}
});
whms.get({
method: "getAvalibleProjects",
data: {}
});
whms.get({
method: "getProjectsByCondition",
data: {
projectCodeSearch: "",
projectNameSearch: "",
projectShowAll: false
}
});
whms.get({
method: "getWorkRecord",
data: {
workRecordEmployeeId: 69,
workRecordCreateDate: new Date().getTime() // Unix time
}
});
whms.get({
method: "getEmployees",
data: {
employeeShowDisabled: true
}
});
whms.get({
method: "getEmployeesByCondition"
data: {
employeeIdSearch: "",
employeeNameSearch: ""
}
});
Post data to work hour management system
import whms from "whms";
whms.post({
method: "addWorkRecord",
data: {
workRecordList: [], // Array<WorkRecord> length should be 8
},
});
Generate Work Record List
import whms, { Employee, WorkRecord } from "whms";
const employee: Employee = {
id: 69,
code: "",
name: "John Doe",
account: "johndoe",
password: "password",
tel: "123-45678",
ext: "234",
email: "johndoe@example.com",
enabled: true,
};
const wrList: WorkRecord[] = whms.generateWorkReocrd({
employee: employee, // employee object
projectId: 10, // project index
content: "This is a content.",
createDate: 0, // unix time
});
console.log(wrList.length); // print 8
{
id: 69,
employeeAccount: "johndoe", // [optional] `employeeaccount` is your account not usernmae
projectCode: "C000",
content: "This is a content",
// date format: "yyyy-MM-dd" or "yyyy/MM/dd"
dateStart: "2021-09-06",
dateEnd: "2021-09-08",
passHoliday: true,
exclude: ["2021-09-07"]
}