Skip to content

Conversation

@lissavxo
Copy link
Collaborator

Related to #1015

Description

Added address to organization

Test plan

Open the dashboard, go to account, check address config

@Klakurka Klakurka requested review from Klakurka and chedieck July 14, 2025 19:22
Copy link
Member

@Klakurka Klakurka left a comment

Choose a reason for hiding this comment

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

Can we apply the loading spinner to the change address/name buttons like we have across the rest of the site?

@lissavxo lissavxo requested a review from Klakurka July 15, 2025 15:46
export const parseUpdateOrganizationPUTRequest = function (params: UpdateOrganizationPUTParameters): UpdateOrganizationInput {
if (params.userId === '' || params.userId === undefined) throw new Error(RESPONSE_MESSAGES.USER_ID_NOT_PROVIDED_400.message)
if (params.name === '' || params.name === undefined) throw new Error(RESPONSE_MESSAGES.ORGANIZATION_NAME_NOT_PROVIDED_400.message)
if ((params.name === '' || params.name === undefined) && (params.address === '' || params.address === undefined)) throw new Error(RESPONSE_MESSAGES.ORGANIZATION_NAME_NOT_PROVIDED_400.message)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be in another if bracket with the appropriate error

@Klakurka
Copy link
Member

  • Let's jus keep it to a name for now on the initial creation
image - What's going on w/ this cancel button?... image

@lissavxo lissavxo force-pushed the feat/add-org-address branch from 9954feb to 7d44264 Compare July 28, 2025 21:45
@lissavxo
Copy link
Collaborator Author

  • Let's jus keep it to a name for now on the initial creation

image - What's going on w/ this cancel button?... image

Fixed

@Klakurka Klakurka added this to the Phase 3 milestone Jul 28, 2025
Copy link
Member

@Klakurka Klakurka left a comment

Choose a reason for hiding this comment

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

Did you forget to push something?

  • Still have the address input showing on the initial creation form.
  • The Cancel button is still weird. The Update and Cancel buttons should be sized and positioned like we do on the dialogs.

@Klakurka Klakurka added the enhancement (UI/UX/feature) New feature or request label Aug 6, 2025
@lissavxo
Copy link
Collaborator Author

lissavxo commented Aug 6, 2025

Did you forget to push something?

  • Still have the address input showing on the initial creation form.
  • The Cancel button is still weird. The Update and Cancel buttons should be sized and positioned like we do on the dialogs.

Yup, I am sure I addressed these in my last commit

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
creatorId String @unique
address String?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should not be nullable. We never let a string be nullable, because the empty string can fulfill that role (unless it is a foreign key, in which case we have to do that to indicate its an optional related field).

where: { id: organization.id },
data: { name }
data: {
...(name !== undefined || name === '' ? { name } : {}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very hard to read, and I think that's why it's wrong — should be name !== '', not name === ''. Same thing for the address in the line below. In any case, there are more readable ways to write this logic, such as:

const updateData: Partial<Organization> = {}

if (name !== undefined && name !== '') updateData.name = name
if (address !== undefined && address !== '') updateData.address = address

return await prisma.organization.update({
  where: { id: organization.id },
  data: updateData,
})

export const parseUpdateOrganizationPUTRequest = function (params: UpdateOrganizationPUTParameters): UpdateOrganizationInput {
if (params.userId === '' || params.userId === undefined) throw new Error(RESPONSE_MESSAGES.USER_ID_NOT_PROVIDED_400.message)
if (params.name === '' || params.name === undefined) throw new Error(RESPONSE_MESSAGES.ORGANIZATION_NAME_NOT_PROVIDED_400.message)
if ((params.name === '' || params.name === undefined) && (params.address === '' || params.address === undefined)) throw new Error(RESPONSE_MESSAGES.ORGANIZATION_MISSING_PARAMS_400.message)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a nitpick, but this error name "ORGANIZATION_MISSING_PARAMS_400" leads one to believe that the organization itself is missing these, better if it was something like MISSING_PARAMS_TO_UPDATE_ORGANIZATION_400

@chedieck chedieck self-requested a review August 6, 2025 21:33
@chedieck chedieck merged commit 19ef0ab into master Aug 6, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement (UI/UX/feature) New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants