Skip to content

Conversation

ghazwarhili
Copy link
Contributor

@ghazwarhili ghazwarhili commented Jan 3, 2025

@basseche
Copy link
Contributor

basseche commented Jan 6, 2025

suggestion to fix this PR

The problem with this fix that :

  • it will introduce a bug, because it doesn't take into account user modification of the name, it will always calls endPoint.
  • it does not solve problem of UniqueNameInput component.
  • it is a refactoring it will make PrefilledNameInput component obsolete and we should remove it.


const activeDirectory = useSelector((state: AppState) => state.activeDirectory);
const userId = useSelector((state: AppState) => state.user?.profile.sub);
const [modifiedByUser, setModifiedByUser] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [modifiedByUser, setModifiedByUser] = useState(false);
const [nameModifiedByUser, setNameModifiedByUser] = useState(false);

const MAX_FILE_SIZE_IN_BYTES = MAX_FILE_SIZE_IN_MO * 1024 * 1024;

export default function UploadNewCase({
modifiedByUser = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
modifiedByUser = false,
nameModifiedByUser = false,

Copy link

sonarqubecloud bot commented Jan 8, 2025

@basseche basseche self-requested a review January 8, 2025 11:37
getBaseName(currentCaseFileName)
.then((response) => {
setValue(name, response, {
shouldValidate: true,
Copy link
Contributor

@basseche basseche Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should not use shouldValidate : true, it will removes check on duplicate name

Copy link
Contributor

@basseche basseche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldValidate: true will remove check on file name unicity and should not be used

const selectedDirectory = useSelector((state: AppState) => state.selectedDirectory);
const userId = useSelector((state: AppState) => state.user?.profile.sub);

const [modifiedByUser, setModifiedByUser] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not a good thing to put the state of the child here, you render the whole form when the state of the child changes !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants