Przeglądaj źródła

update

tags/Baseline_30082024_FRONTEND_UAT
MSI\derek 1 rok temu
rodzic
commit
bafdbfaa43
6 zmienionych plików z 27 dodań i 26 usunięć
  1. +1
    -1
      src/app/api/staff/actions.ts
  2. +7
    -3
      src/components/CreateStaff/CreateStaff.tsx
  3. +1
    -3
      src/components/CreateStaff/StaffInfo.tsx
  4. +16
    -8
      src/components/SkillSearch/SkillSearch.tsx
  5. +1
    -9
      src/components/SkillSearch/SkillSearchWrapper.tsx
  6. +1
    -2
      src/components/StaffSearch/StaffSearch.tsx

+ 1
- 1
src/app/api/staff/actions.ts Wyświetl plik

@@ -23,7 +23,7 @@ export interface CreateStaffInputs {
joinDate?: string; joinDate?: string;
currentPositionId: number; currentPositionId: number;
joinPositionId?: number; joinPositionId?: number;
gradeId?: number;
gradeId: number;
teamId?: number teamId?: number
departmentId?: number; departmentId?: number;
phone1: string; phone1: string;


+ 7
- 3
src/components/CreateStaff/CreateStaff.tsx Wyświetl plik

@@ -76,11 +76,11 @@ const CreateStaff: React.FC<formProps> = ({ combos }) => {
haveError = true haveError = true
formProps.setError("email", { message: t("Please Enter Correct Email."), type: "required" }) formProps.setError("email", { message: t("Please Enter Correct Email."), type: "required" })
} }
if(!regex_phone.test(data.phone1)) {
if (!regex_phone.test(data.phone1)) {
haveError = true haveError = true
formProps.setError("phone1", { message: t("Please Enter Correct Phone No.."), type: "required" }) formProps.setError("phone1", { message: t("Please Enter Correct Phone No.."), type: "required" })
} }
if(data.emergContactPhone && !regex_phone.test(data.emergContactPhone)) {
if (data.emergContactPhone && !regex_phone.test(data.emergContactPhone)) {
haveError = true haveError = true
formProps.setError("emergContactPhone", { message: t("Please Enter Correct Phone No.."), type: "required" }) formProps.setError("emergContactPhone", { message: t("Please Enter Correct Phone No.."), type: "required" })
} }
@@ -90,12 +90,15 @@ const CreateStaff: React.FC<formProps> = ({ combos }) => {
formProps.setError("phone2", { message: t("Please Enter Correct Phone No.."), type: "required" }) formProps.setError("phone2", { message: t("Please Enter Correct Phone No.."), type: "required" })
} }
} }
if (data.phone1 === data.phone2 || data.phone1 === data.emergContactPhone || data.phone2 === data.emergContactPhone) {
if (data.phone1 === data.phone2 || data.phone1 === data.emergContactPhone || data.phone2 && data.phone2 === data.emergContactPhone && data.phone2.length > 0) {
haveError = true haveError = true
formProps.setError("phone1", { message: t("Please Enter Different Phone No.."), type: "required" }) formProps.setError("phone1", { message: t("Please Enter Different Phone No.."), type: "required" })
if (data.phone2!.length > 0) { if (data.phone2!.length > 0) {
formProps.setError("phone2", { message: t("Please Enter Different Phone No.."), type: "required" }) formProps.setError("phone2", { message: t("Please Enter Different Phone No.."), type: "required" })
} }
console.log(data.phone1)
console.log(data.emergContactPhone)
console.log(data.phone1 === data.emergContactPhone)
formProps.setError("emergContactPhone", { message: t("Please Enter Different Phone No.."), type: "required" }) formProps.setError("emergContactPhone", { message: t("Please Enter Different Phone No.."), type: "required" })
} }
if (!regex_email.test(data.email)) { if (!regex_email.test(data.email)) {
@@ -122,6 +125,7 @@ const CreateStaff: React.FC<formProps> = ({ combos }) => {
return return
} }
console.log("passed") console.log("passed")
console.log(data)
await saveStaff(data) await saveStaff(data)
router.replace("/settings/staff") router.replace("/settings/staff")
} catch (e: any) { } catch (e: any) {


+ 1
- 3
src/components/CreateStaff/StaffInfo.tsx Wyświetl plik

@@ -190,7 +190,7 @@ const StaffInfo: React.FC<Props> = ({ combos }) => {
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
<FormControl fullWidth> <FormControl fullWidth>
<InputLabel>{t("Grade")}</InputLabel>
<InputLabel required>{t("Grade")}</InputLabel>
<Controller <Controller
control={control} control={control}
name="gradeId" name="gradeId"
@@ -376,7 +376,6 @@ const StaffInfo: React.FC<Props> = ({ combos }) => {
<TextField <TextField
label={t("Emergency Contact Name")} label={t("Emergency Contact Name")}
fullWidth fullWidth
required
{...register("emergContactName" {...register("emergContactName"
// , { // , {
// required: "Emergency Contact Name required!", // required: "Emergency Contact Name required!",
@@ -395,7 +394,6 @@ const StaffInfo: React.FC<Props> = ({ combos }) => {
<TextField <TextField
label={t("Emergency Contact Phone")} label={t("Emergency Contact Phone")}
fullWidth fullWidth
required
{...register("emergContactPhone" {...register("emergContactPhone"
// , { // , {
// required: "Emergency Contact Phone required!", // required: "Emergency Contact Phone required!",


+ 16
- 8
src/components/SkillSearch/SkillSearch.tsx Wyświetl plik

@@ -21,16 +21,24 @@ const SkillSearch: React.FC<Props> = ({ skill }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [filteredSkill, setFilteredSkill] = useState(skill); const [filteredSkill, setFilteredSkill] = useState(skill);
const router = useRouter(); const router = useRouter();
// translation
const skillName = t("Skill Name")
const skillCode = t("Skill Code")
const deleteSuccess = t("Delete Success")
const edit = t("Actions")
const name = t("name")
const code = t("code")
const description = t("description")


const searchCriteria: Criterion<SearchParamNames>[] = useMemo( const searchCriteria: Criterion<SearchParamNames>[] = useMemo(
() => [ () => [
{ {
label: t("Skill Name"),
label: skillName,
paramName: "name", paramName: "name",
type: "text", type: "text",
}, },
{ {
label: t("Skill Code"),
label: skillCode,
paramName: "code", paramName: "code",
type: "text", type: "text",
}, },
@@ -50,8 +58,8 @@ const SkillSearch: React.FC<Props> = ({ skill }) => {
const deleteClick = useCallback((skill: SkillResult) => { const deleteClick = useCallback((skill: SkillResult) => {
deleteDialog(async () => { deleteDialog(async () => {
await deleteSkill(skill.id); await deleteSkill(skill.id);
successDialog("Delete Success", t);
// setFilteredSkill((prev) => prev.filter((obj) => obj.id !== skill.id));
successDialog(deleteSuccess, t);
setFilteredSkill((prev) => prev.filter((obj) => obj.id !== skill.id));
}, t); }, t);
}, []); }, []);


@@ -59,13 +67,13 @@ const SkillSearch: React.FC<Props> = ({ skill }) => {
() => [ () => [
{ {
name: "action", name: "action",
label: t("Actions"),
label: edit,
onClick: onSkillClick, onClick: onSkillClick,
buttonIcon: <EditNote />, buttonIcon: <EditNote />,
}, },
{ name: "name", label: t("name") },
{ name: "code", label: t("code") },
{ name: "description", label: t("description") },
{ name: "name", label: name },
{ name: "code", label: code },
{ name: "description", label: description },
{ {
name: "delete", name: "delete",
label: t("Delete"), label: t("Delete"),


+ 1
- 9
src/components/SkillSearch/SkillSearchWrapper.tsx Wyświetl plik

@@ -1,15 +1,7 @@
import React from "react"; import React from "react";
import SkillSearch from "./SkillSearch"; import SkillSearch from "./SkillSearch";
import SkillSearchLoading from "./SkillSearchLoading"; import SkillSearchLoading from "./SkillSearchLoading";
import { comboProp, fetchCompanyCombo } from "@/app/api/companys/actions";
import { fetchTeamCombo } from "@/app/api/team/actions";
import { fetchDepartmentCombo } from "@/app/api/departments/actions";
import { fetchPositionCombo } from "@/app/api/positions/actions";
import { fetchGradeCombo } from "@/app/api/grades/actions";
import { fetchSkillCombo } from "@/app/api/skill/actions";
import { fetchSalaryCombo } from "@/app/api/salarys/actions";
import { SkillResult, fetchSkill } from "@/app/api/skill";
// import { preloadStaff } from "@/app/api/staff";
import { fetchSkill } from "@/app/api/skill";


interface SubComponents { interface SubComponents {
Loading: typeof SkillSearchLoading; Loading: typeof SkillSearchLoading;


+ 1
- 2
src/components/StaffSearch/StaffSearch.tsx Wyświetl plik

@@ -27,7 +27,6 @@ type SearchQuery = Partial<Omit<StaffResult, "id">>;
type SearchParamNames = keyof SearchQuery; type SearchParamNames = keyof SearchQuery;


const StaffSearch: React.FC<Props> = ({ staff, teams, grades, positions, isAuthed }) => { const StaffSearch: React.FC<Props> = ({ staff, teams, grades, positions, isAuthed }) => {
console.log(staff)
const { t } = useTranslation(); const { t } = useTranslation();
const [filteredStaff, setFilteredStaff] = useState(staff); const [filteredStaff, setFilteredStaff] = useState(staff);
const router = useRouter(); const router = useRouter();
@@ -108,7 +107,7 @@ const StaffSearch: React.FC<Props> = ({ staff, teams, grades, positions, isAuthe
label: t("Users"), label: t("Users"),
onClick: onUserClick, onClick: onUserClick,
buttonIcon: <Person />, buttonIcon: <Person />,
isHidden: !isAuthed,
isHidden: isAuthed,
}, },
{ name: "team", label: t("Team") }, { name: "team", label: t("Team") },
{ name: "name", label: t("Staff Name") }, { name: "name", label: t("Staff Name") },


Ładowanie…
Anuluj
Zapisz