Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
Prevent users from accidentally updated other participants (#199)
Luke Vellac4cbf2f6bb5f
diff --git a/src/components/poll/mobile-poll.tsx b/src/components/poll/mobile-poll.tsxindex 02f82b474..7a45562e2 100644--- a/src/components/poll/mobile-poll.tsx+++ b/src/components/poll/mobile-poll.tsx@@ -199,64 +199,79 @@ const MobilePoll: React.VoidFunctionComponent = () => {</Listbox.Options></div></Listbox>- {!poll.closed && !isEditing ? (- selectedParticipant &&- (role === "admin" ||- session.ownsObject(selectedParticipant) ||- isUnclaimed(selectedParticipant)) ? (- <div className="flex space-x-3">- <Button- icon={<Pencil />}- onClick={() => {- setIsEditing(true);- reset({- name: selectedParticipant.name,- votes: optionIds.map((optionId) => ({- optionId,- type: getVote(selectedParticipant.id, optionId),- })),- });- }}- >- Edit- </Button>- <Button- icon={<Trash />}- data-testid="delete-participant-button"- type="danger"- onClick={() => {- if (selectedParticipant) {- confirmDeleteParticipant(selectedParticipant.id);- }- }}- />- </div>- ) : (+ {isEditing ? (+ <Button+ onClick={() => {+ setIsEditing(false);+ reset();+ }}+ >+ Cancel+ </Button>+ ) : selectedParticipant ? (+ <div className="flex space-x-3"><Button- type="primary"- icon={<PlusCircle />}+ icon={<Pencil />}+ disabled={+ poll.closed ||+ // if user is participant (not admin)+ (role === "participant" &&+ // and does not own this participant+ !session.ownsObject(selectedParticipant) &&+ // and the participant has been claimed by a different user+ !isUnclaimed(selectedParticipant))+ // not allowed to edit+ }onClick={() => {+ setIsEditing(true);reset({- name: "",- votes: [],+ name: selectedParticipant.name,+ votes: optionIds.map((optionId) => ({+ optionId,+ type: getVote(selectedParticipant.id, optionId),+ })),});- setIsEditing(true);}}>- New+ Edit</Button>- )- ) : null}- {isEditing ? (+ <Button+ icon={<Trash />}+ disabled={+ poll.closed ||+ // if user is participant (not admin)+ (role === "participant" &&+ // and does not own this participant+ !session.ownsObject(selectedParticipant) &&+ // or the participant has been claimed by a different user+ !isUnclaimed(selectedParticipant))+ // not allowed to edit+ }+ data-testid="delete-participant-button"+ type="danger"+ onClick={() => {+ if (selectedParticipant) {+ confirmDeleteParticipant(selectedParticipant.id);+ }+ }}+ />+ </div>+ ) : (<Button+ type="primary"+ icon={<PlusCircle />}+ disabled={poll.closed}onClick={() => {- setIsEditing(false);- reset();+ reset({+ name: "",+ votes: [],+ });+ setIsEditing(true);}}>- Cancel+ New</Button>- ) : null}+ )}</div>{timeZone ? (<TimeZonePicker