Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unwanted unsaved change modal #3775

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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
Loading