Skip to content

Commit

Permalink
fix: remove unwanted unsaved change modal
Browse files Browse the repository at this point in the history
  • Loading branch information
RRanath committed Jan 8, 2025
1 parent 837ce06 commit c661e0c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const ClosePendingRequestModal: React.FC<Props> = ({
schema={pendingChangeRequestCancel}
uiSchema={pendingChangeRequestCancelUiSchema}
formData={formData}
formContext={{ skipUnsavedWarning: true }}
onChange={(e) => setFormData(e.formData)}
// Pass children to hide submit button
// eslint-disable-next-line react/no-children-prop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const PendingChangeRequest = ({
orderBy: CREATED_AT_DESC
first: 1
) {
__id
nodes {
comment
isPending
Expand All @@ -49,6 +50,7 @@ const PendingChangeRequest = ({
orderBy: CREATED_AT_DESC
first: 1
) {
__id
nodes {
comment
isPending
Expand All @@ -68,7 +70,7 @@ const PendingChangeRequest = ({
const [isPending, setIsPending] = useState(
pendingRequests?.nodes?.[0]?.isPending || false
);

const connectionId = pendingRequests?.__id;
const [comment, setComment] = useState(
isPending ? pendingRequests?.nodes?.[0]?.comment : null
);
Expand Down Expand Up @@ -105,6 +107,18 @@ const PendingChangeRequest = ({
input: input as CreateCbcPendingChangeRequestInput &
CreatePendingChangeRequestInput,
},
updater: (store) => {
const payload = store.getRootField(
isCbc ? 'createCbcPendingChangeRequest' : 'createPendingChangeRequest'
);
const newEdge = payload.getLinkedRecord(
isCbc
? 'cbcApplicationPendingChangeRequest'
: 'applicationPendingChangeRequest'
);
const connection = store.get(connectionId);
if (connection) connection.setLinkedRecords([newEdge], 'nodes');
},
onCompleted: () => {
setIsPending(isPendingRequest);
setComment(isPendingRequest ? reasonForChange : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const PendingChangeRequestModal: React.FC<Props> = ({
schema={pendingChangeRequestComment}
uiSchema={pendingChangeRequestCommentUiSchema}
formData={formData}
formContext={{ skipUnsavedWarning: true }}
onChange={(e) => setFormData(e.formData)}
disabled={!isHeaderEditable}
// Pass children to hide submit button
Expand Down

0 comments on commit c661e0c

Please sign in to comment.