Quellcode durchsuchen

update edit team

tags/Baseline_30082024_FRONTEND_UAT
MSI\derek vor 1 Jahr
Ursprung
Commit
5437a6878a
3 geänderte Dateien mit 21 neuen und 12 gelöschten Zeilen
  1. +13
    -1
      src/components/EditSkill/EditSkill.tsx
  2. +8
    -10
      src/components/EditTeam/Allocation.tsx
  3. +0
    -1
      src/components/EditTeam/EditTeam.tsx

+ 13
- 1
src/components/EditSkill/EditSkill.tsx Datei anzeigen

@@ -32,7 +32,10 @@ interface Props {
skills: SkillResult[];
}

const EditSkill: React.FC<Props> = async ({ skills }) => {
const EditSkill: React.FC<Props> = async ({
skills
}) => {
const codeList = skills.map(s => s.code.toLowerCase().trim())
const { t } = useTranslation();
const formProps = useForm<CreateSkillInputs>();
const [serverError, setServerError] = useState("");
@@ -49,6 +52,15 @@ const EditSkill: React.FC<Props> = async ({ skills }) => {
async (data) => {
try {
console.log(data);
let haveError = false
haveError = codeList.includes(data.code.toLowerCase().trim())
if (haveError) {
formProps.setError("code", { message: t("Duplicated Code"), type: "required" })
return
}
data.name = data.name.trim()
data.code = data.code.trim()
data.description = data.description.trim()
const postData = {
...data,
id: id,


+ 8
- 10
src/components/EditTeam/Allocation.tsx Datei anzeigen

@@ -50,9 +50,10 @@ const Allocation: React.FC<Props> = ({ allStaffs: staff, teamLead }) => {
} = useFormContext<CreateTeamInputs>();

const initialStaffs = staff.map((s) => ({ ...s }));
const [filteredStaff, setFilteredStaff] = useState(initialStaffs);
const [selectedStaff, setSelectedStaff] = useState<typeof filteredStaff>(() => {
const rearrangedStaff = filteredStaff.sort((a, b) => {
const noTeamstaffs = initialStaffs.filter((staff) => !staff.team)
const [filteredStaff, setFilteredStaff] = useState<typeof initialStaffs>(noTeamstaffs);
const [selectedStaff, setSelectedStaff] = useState<typeof initialStaffs>(() => {
const rearrangedStaff = initialStaffs.sort((a, b) => {
if (a.id === teamLead) return -1;
if (b.id === teamLead) return 1;
return 0;
@@ -69,6 +70,7 @@ const Allocation: React.FC<Props> = ({ allStaffs: staff, teamLead }) => {

const removeStaff = useCallback((staff: StaffResult) => {
setSelectedStaff((s) => s.filter((s) => s.id !== staff.id));
setFilteredStaff((prev) => [...prev, ...initialStaffs.filter((s) => s.id === staff.id)])
setDeletedStaffIds((prevIds) => [...prevIds, staff.id]);
}, []);

@@ -100,7 +102,7 @@ const Allocation: React.FC<Props> = ({ allStaffs: staff, teamLead }) => {
if (defaultValues !== undefined) {
resetField("addStaffIds");
setSelectedStaff(
initialStaffs.filter((s) => defaultValues.addStaffIds?.includes(s.id))
noTeamstaffs.filter((s) => defaultValues.addStaffIds?.includes(s.id))
);
}
}, [defaultValues]);
@@ -165,8 +167,8 @@ const Allocation: React.FC<Props> = ({ allStaffs: staff, teamLead }) => {
}, []);

React.useEffect(() => {
setFilteredStaff(
initialStaffs.filter((i) => {
setFilteredStaff((prev) =>
prev.filter((i) => {
const q = query.toLowerCase();
return (
i.staffId.toLowerCase().includes(q)
@@ -177,10 +179,6 @@ const Allocation: React.FC<Props> = ({ allStaffs: staff, teamLead }) => {
);
}, [staff, query]);

useEffect(() => {
// console.log(getValues("addStaffIds"))
}, [initialStaffs]);

const resetStaff = React.useCallback(() => {
clearQueryInput();
clearValues();


+ 0
- 1
src/components/EditTeam/EditTeam.tsx Datei anzeigen

@@ -26,7 +26,6 @@ interface Props {

const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => {
const { team, staffIds } = teamInfo;
console.log(team.name)
// console.log(staffIds)
const { t } = useTranslation();
const formProps = useForm<CreateTeamInputs>();


Laden…
Abbrechen
Speichern