Skip to content

Commit

Permalink
bruh
Browse files Browse the repository at this point in the history
  • Loading branch information
ahweigl committed Apr 4, 2024
1 parent e1fec14 commit 31ab161
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/server/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async function fetchSignatureFields(
return signatureFieldsMap;
}

// type definition for mapping signature field names (ex: 'Director', 'Manager') to their data
// type definition for mapping form instances to their data
type FormInstanceData = {
id: string;
name: string;
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/employees/employees.errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum EmployeeErrorMessage {
EMPLOYEE_NOT_FOUND = 'Employee could not be found with this email',
EMPLOYEE_NOT_FOUND = 'Employee could not be found with this id',
EMPLOYEE_NOT_FOUND_CLIENT = 'Employee could not be found',
}
12 changes: 7 additions & 5 deletions apps/server/src/form-instances/form-instances.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class FormInstancesService {
// number of signatures to be created should be equal to the number of
// signature fields on the form template
if (
formTemplate.signatureFields .length !=
formTemplate.signatureFields.length !=
createFormInstanceDto.signatures.length
) {
throw Error(
Expand All @@ -72,11 +72,13 @@ export class FormInstancesService {
),
);
Logger.log('assigned user ids' + assignedUserIds.size);
// TODO here
const ids = createFormInstanceDto.signatures.map(
(signature) => signature.assignedUserId,
);
// TODO here: lists signer position ids?
Logger.log(createFormInstanceDto.signatures);
const assignedUsers = await this.employeesService.findAllWithIds(
createFormInstanceDto.signatures.map(
(signature) => signature.assignedUserId,
),
ids
);
Logger.log('assigned users' + assignedUsers.length);
if (assignedUsers.length != assignedUserIds.size) {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/client/models/CreateSignatureDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

export type CreateSignatureDto = {
order: number;
signerPositionId: string;
assignedUserId: string;
};

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const CreateFormInstanceModal: React.FC<CreateFormInstanceModalProps> = ({
const [formTypeSelected, setFormTypeSelected] = useState(false);
const [signaturePositions, setSignaturePositions] = useState<
(Option | null)[]
>([]);
const [signatureAssignedUsers, setSignatureAssignedUsers] = useState<
(Option)[]
>([]);
const [formName, setFormName] = useState('Create Form');
const createFormInstanceMutation = useMutation({
Expand Down Expand Up @@ -86,10 +89,11 @@ const CreateFormInstanceModal: React.FC<CreateFormInstanceModalProps> = ({
createFormInstanceMutation
.mutateAsync({
name: formName, // Use the updated form name
signatures: signaturePositions.map((pos, i) => {
// TODO here
signatures: signatureAssignedUsers.map((emp, i) => {
return {
order: i,
signerPositionId: pos?.value!,
assignedUserId: emp.value!,
};
}),
originatorId: user?.id!,
Expand All @@ -114,7 +118,7 @@ const CreateFormInstanceModal: React.FC<CreateFormInstanceModalProps> = ({
setFormName('Create Form');
setSelectedFormTemplate(null);
setFormTypeSelected(false);
setSignaturePositions([]);
setSignatureAssignedUsers([]);
};

function EditableControls() {
Expand Down

0 comments on commit 31ab161

Please sign in to comment.