Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/backend/src/middleware/requests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextFunction, Request, Response } from 'express'
import _ from 'lodash'
import omit from 'lodash/omit'

/**
* Removes attributes from a request's body. So if "_id" is passed in, "_id" will be removed
Expand All @@ -21,4 +21,4 @@ export const removeRequestAttributes =
export const removeAttributesFrom = <T extends object, K extends keyof T>(
obj: T,
attributes: K[]
): Omit<T, K> => _.omit(obj, attributes)
): Omit<T, K> => omit(obj, attributes)
11 changes: 6 additions & 5 deletions apps/backend/src/routes/api/patients.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import express, { Response } from 'express';
import mongoose from 'mongoose';

import _ from 'lodash';
import pick from 'lodash/pick'
import assign from 'lodash/assign'
import {
uploadFile,
downloadFile,
Expand Down Expand Up @@ -100,7 +101,7 @@ router.get(
stepData = stepData.toObject();

// Filter out fields that the user cannot view
stepData = _.pick(stepData, readableFields);
stepData = pick(stepData, readableFields);

// Update the patient data
patientData.set(step.key, stepData, { strict: false });
Expand Down Expand Up @@ -162,7 +163,7 @@ router.put(
return sendResponse(res, 404, `Patient "${id}" not found`);

// Copy over the attributes from the request
_.assign(patient, req.body);
assign(patient, req.body);
patient.lastEdited = new Date();
patient.lastEditedBy = req.user.name;

Expand Down Expand Up @@ -364,7 +365,7 @@ router.post(

// Filter out request fields that the user cannot write
const writableFields = await getWritableFields(req.user, stepKey);
req.body = _.pick(req.body, writableFields);
req.body = pick(req.body, writableFields);

// Find the patient's step data
let Model;
Expand Down Expand Up @@ -458,7 +459,7 @@ const updatePatientStepData = async (patientId: string, StepModel: typeof mongoo
return newStepDataModel.save();
}

patientStepData = _.assign(patientStepData, data);
patientStepData = assign(patientStepData, data);
return patientStepData.save();
};

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/routes/api/public.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express, { Response } from 'express';
import _ from 'lodash';

import {
sendResponse,
} from '../../utils/response';
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/utils/initDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Step,
StepStatus,
} from '@3dp4me/types'
import _ from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import log from 'loglevel'
import mongoose, { SchemaDefinitionProperty } from 'mongoose'
import encrypt from 'mongoose-encryption'
Expand Down Expand Up @@ -265,5 +265,5 @@ const generateFieldsFromMetadata = (fieldsMetadata: Field[], baseSchema = {}) =>
}
})

return Object.assign(_.cloneDeep(baseSchema), ...generatedSchema)
return Object.assign(cloneDeep(baseSchema), ...generatedSchema)
}
4 changes: 2 additions & 2 deletions apps/backend/src/utils/keyUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReservedStep } from '@3dp4me/types'
import _ from 'lodash'
import camelCase from 'lodash/camelCase'

/* Returns a string of specified length composed of random alphanumeric characters */
const randomAlphanumeric = (length: number) => {
Expand All @@ -18,7 +18,7 @@ const generateKeyWithCamelCase = (input: string) => {
return randomAlphanumeric(10)
}

return _.camelCase(input)
return camelCase(input)
}

const checkKeyCollision = (newKey: string, otherKeys: string[]) =>
Expand Down
13 changes: 7 additions & 6 deletions apps/backend/src/utils/stepUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Field, ReservedStep, Step } from '@3dp4me/types'
import _ from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import assign from 'lodash/assign'
import { ClientSession, HydratedDocument, PipelineStage } from 'mongoose'

import { removeAttributesFrom } from '../middleware/requests'
Expand Down Expand Up @@ -191,7 +192,7 @@ const updateElementNumbers = <T extends Step | Field, K extends keyof T>(
// number for the field that it is pointing at. The elements in deletedElements get priority,
// meaning they always keep the same field number.

const updatedElements = _.cloneDeep(goodElements)
const updatedElements = cloneDeep(goodElements)

let currElementNumber = 0
let deletedElementPointer = 0
Expand All @@ -218,7 +219,7 @@ const updateElementNumbers = <T extends Step | Field, K extends keyof T>(
}

const updateFieldKeys = (fields: Field[]) => {
const clonedFields = _.cloneDeep(fields)
const clonedFields = cloneDeep(fields)
const currentFieldKeys = clonedFields.map((field) => field.key ?? '')

for (let i = 0; i < clonedFields.length; i++) {
Expand Down Expand Up @@ -253,8 +254,8 @@ const updateFieldInTransaction = async (
session: ClientSession,
level: number
) => {
const savedFields = _.cloneDeep(fieldsInDB)
let updatedFields = _.cloneDeep(fieldsFromRequest)
const savedFields = cloneDeep(fieldsInDB)
let updatedFields = cloneDeep(fieldsFromRequest)

const addedFields = await getAddedFields(session, savedFields, updatedFields)

Expand Down Expand Up @@ -425,7 +426,7 @@ const updateStepInTransaction = async (
return abortAndError(session, 'Step not found on final update')
}

_.assign(step, strippedBody)
assign(step, strippedBody)
await step.save({ session, validateBeforeSave: false })

// Return the model so that we can do validation later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import Checkbox from '@mui/material/Checkbox'
import FormControl from '@mui/material/FormControl'
import Modal from '@mui/material/Modal'
import NativeSelect from '@mui/material/NativeSelect'
import _ from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import clone from 'lodash/clone'
import React, { ChangeEventHandler, ReactNode, useState } from 'react'
import { trackPromise } from 'react-promise-tracker'

Expand Down Expand Up @@ -65,28 +66,28 @@ const CreateFieldModal = ({
}

const addOption = () => {
const updatedOptions = _.cloneDeep(options)
const updatedOptions = cloneDeep(options)
updatedOptions.push({ EN: '', AR: '' })
setOptions(updatedOptions)
}

const updateOptionField = (index: number, val: string, language: Language) => {
const updatedOptions = _.cloneDeep(options)
const updatedOptions = cloneDeep(options)
updatedOptions[index][language] = val
setOptions(updatedOptions)
}

const moveOption = (currIndex: number, newIndex: number) => {
if (newIndex >= 0 && newIndex < options.length) {
const updatedOptions = _.cloneDeep(options)
const updatedOptions = cloneDeep(options)
const removedChoice = updatedOptions.splice(currIndex, 1)[0]
updatedOptions.splice(newIndex, 0, removedChoice)
setOptions(updatedOptions)
}
}

const deleteOption = (index: number) => {
const updatedOptions = _.cloneDeep(options)
const updatedOptions = cloneDeep(options)
updatedOptions.splice(index, 1)
setOptions(updatedOptions)
}
Expand Down Expand Up @@ -120,7 +121,7 @@ const CreateFieldModal = ({
}

const updateDisplayName = (value: string, language: Language) => {
const updatedDisplayName = _.clone(displayName)
const updatedDisplayName = clone(displayName)
updatedDisplayName[language] = value

setDisplayName(updatedDisplayName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import './CreateStepModal.scss'
import { BaseStep, Field, Language } from '@3dp4me/types'
import Button from '@mui/material/Button'
import Modal from '@mui/material/Modal'
import _ from 'lodash'
import clone from 'lodash/clone'
import { useState } from 'react'

import { useErrorWrap } from '../../hooks/useErrorWrap'
Expand Down Expand Up @@ -36,7 +36,7 @@ const CreateStepModal = ({
setSelectedRoles(roleIds)
}
const updateDisplayName = (value: string, language: Language) => {
const updatedDisplayName = _.clone(displayName)
const updatedDisplayName = clone(displayName)
updatedDisplayName[language] = value

setDisplayName(updatedDisplayName)
Expand Down
13 changes: 7 additions & 6 deletions apps/frontend/src/components/EditFieldModal/EditFieldModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import FormControl from '@mui/material/FormControl'
import FormControlLabel from '@mui/material/FormControlLabel'
import Modal from '@mui/material/Modal'
import NativeSelect from '@mui/material/NativeSelect'
import _ from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import clone from 'lodash/clone'
import React, { ChangeEvent, ReactNode, useEffect, useState } from 'react'
import swal from 'sweetalert'

Expand Down Expand Up @@ -71,28 +72,28 @@ const EditFieldModal = ({
}

const addOption = () => {
const updatedOptions = _.cloneDeep(options)
const updatedOptions = cloneDeep(options)
updatedOptions.push({ EN: '', AR: '' })
setOptions(updatedOptions)
}

const updateOptionField = (index: number, val: string, language: Language) => {
const updatedOptions = _.cloneDeep(options)
const updatedOptions = cloneDeep(options)
updatedOptions[index][language] = val
setOptions(updatedOptions)
}

const moveOption = (currIndex: number, newIndex: number) => {
if (newIndex >= 0 && newIndex < options.length) {
const updatedOptions = _.cloneDeep(options)
const updatedOptions = cloneDeep(options)
const removedChoice = updatedOptions.splice(currIndex, 1)[0]
updatedOptions.splice(newIndex, 0, removedChoice)
setOptions(updatedOptions)
}
}

const deleteOption = (index: number) => {
const updatedOptions = _.cloneDeep(options)
const updatedOptions = cloneDeep(options)
updatedOptions.splice(index, 1)
setOptions(updatedOptions)
}
Expand Down Expand Up @@ -126,7 +127,7 @@ const EditFieldModal = ({
}

const updateDisplayName = (value: string, language: Language) => {
const updatedDisplayName = _.clone(displayName)
const updatedDisplayName = clone(displayName)
updatedDisplayName[language] = value

setDisplayName(updatedDisplayName)
Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/src/components/EditRoleModal/EditRoleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import FormControl from '@mui/material/FormControl'
import InputLabel from '@mui/material/InputLabel'
import Modal from '@mui/material/Modal'
import Select, { SelectChangeEvent } from '@mui/material/Select'
import _ from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import React, { useEffect, useState } from 'react'
import { trackPromise } from 'react-promise-tracker'
import swal from 'sweetalert'
Expand Down Expand Up @@ -49,11 +49,11 @@ const EditRoleModal = ({
allRoles,
}: EditRoleModalProps) => {
const [translations, selectedLang] = useTranslations()
const [userData, setUserData] = useState(_.cloneDeep(userInfo))
const [userData, setUserData] = useState(cloneDeep(userInfo))
const errorWrap = useErrorWrap()

useEffect(() => {
setUserData(_.cloneDeep(userInfo))
setUserData(cloneDeep(userInfo))
}, [userInfo])

const onRolesChange = (id: string, roles: string[]) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/components/EditStepModal/EditStepModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Language, Step, TranslatedString } from '@3dp4me/types'
import Button from '@mui/material/Button'
import FormControlLabel from '@mui/material/FormControlLabel'
import Modal from '@mui/material/Modal'
import _ from 'lodash'
import clone from 'lodash/clone'
import React, { useEffect, useState } from 'react'
import swal from 'sweetalert'

Expand Down Expand Up @@ -56,7 +56,7 @@ const EditStepModal = ({
setSelectedRoles(roles)
}
const updateDisplayName = (value: string, language: Language) => {
const updatedDisplayName = _.clone(displayName)
const updatedDisplayName = clone(displayName)
updatedDisplayName[language] = value

setDisplayName(updatedDisplayName)
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/components/Fields/FieldGroup/FieldGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import '../Fields.scss'

import { Field } from '@3dp4me/types'
import _ from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import swal from 'sweetalert'

import { useTranslations } from '../../../hooks/useTranslations'
Expand All @@ -23,7 +23,7 @@

export interface FieldGroupProps {
isDisabled: boolean
handleSimpleUpdate: (field: string, value: any) => void

Check warning on line 26 in apps/frontend/src/components/Fields/FieldGroup/FieldGroup.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
handleFileDownload: (field: string, value: any) => void
handleFileUpload: (field: string, value: any) => void
handleFileDelete: (field: string, value: any) => void
Expand Down Expand Up @@ -75,7 +75,7 @@
}

const doRemoveGroup = (groupNumber: number) => {
const newData = _.cloneDeep(props.value)
const newData = cloneDeep(props.value)
newData.splice(groupNumber, 1)
props.handleSimpleUpdate(props.metadata.key, newData)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Language, Nullish, Patient, PatientTagsField, ReservedStep, Step } from
import CloseIcon from '@mui/icons-material/Close'
import Button from '@mui/material/Button'
import Modal from '@mui/material/Modal'
import _ from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import React, { useEffect, useState } from 'react'
import swal from 'sweetalert'

Expand Down Expand Up @@ -44,10 +44,10 @@ const ManagePatientModal = ({
onUploadProfilePicture,
}: ManagePatientModalProps) => {
const [translations, selectedLang] = useTranslations()
const [updatedPatientData, setUpdatedPatientData] = useState(_.cloneDeep(patientData))
const [updatedPatientData, setUpdatedPatientData] = useState(cloneDeep(patientData))

useEffect(() => {
setUpdatedPatientData(_.cloneDeep(patientData))
setUpdatedPatientData(cloneDeep(patientData))
}, [patientData])

const onFieldUpdate = (key: string, value: string) => {
Expand Down Expand Up @@ -222,7 +222,7 @@ const ManagePatientModal = ({
ReservedStep.Root
] as Nullish<Step>
if (root) {
onStepSave(ReservedStep.Root, _.cloneDeep(root))
onStepSave(ReservedStep.Root, cloneDeep(root))
}
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import './ManageRoleModal.scss'
import { Nullish, PatientTagsField, Role } from '@3dp4me/types'
import Button from '@mui/material/Button'
import Modal from '@mui/material/Modal'
import _ from 'lodash'
import cloneDeep from 'lodash/cloneDeep'
import { useEffect, useState } from 'react'
import { trackPromise } from 'react-promise-tracker'
import swal from 'sweetalert'
Expand Down Expand Up @@ -46,7 +46,7 @@ const ManageRoleModal = ({
})

useEffect(() => {
setRole(_.cloneDeep(roleInfo))
setRole(cloneDeep(roleInfo))
}, [roleInfo])

const onDelete = async () => {
Expand Down
Loading
Loading