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

feat(ONYX-986): support save and exit in new submission flow #10281

Merged
merged 4 commits into from
May 27, 2024

Conversation

MounirDhahri
Copy link
Member

@MounirDhahri MounirDhahri commented May 23, 2024

⟥⸻PR Description Up To Date [Friday 24th May 10:47 CEST] ⸻⟤

This PR resolves ONYX-986

Description

This PR makes the Save & Exit button in the new submission flow functional.

What we currently have:

  • The Save & Exit Button simply closes the modal or navigates you to the next screen
    Expected behaviour:
  • When the user taps on Save & Exit, we should save their progress, and allow them to continue from where they left when they tap on Continue Previous Submission

Main challenges:

1. What data to save when the user taps on Save & Exit?

  • Data to inject for the submission
    • Currently, I am saving the entire formik state and injecting it as it is, However, we can soon move toward saving only the submission id and querying for the data on screen mount. I didn't do that initially because we are going to get rid of this logic once we back up submissions with my collection artworks and have cross platform save and exit experience.
    • Currently, we only store the submissionID and the last active step. We use the submissionID to query for the data
  • Navigation progress 👇 [see question 2]

2. How to restore the previous navigation state and get the user to continue from where they left

  • For that, we are leveraging initialState prop to inject the a partial navigation state. We are rebuilding it on mount and validating that the routes exist

Downsides of this approach

This works only for App. This is fine though since we want to first see how it performs when it comes to clicks before investing more effort.

Screen.Recording.2024-05-23.at.13.05.32.mov

PR Checklist

  • I have tested my changes on iOS and Android.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos, or I have not changed the UI.
  • I have added tests, or my changes don't require any.
  • I added an app state migration, or my changes do not require one.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added a changelog entry below, or my changes do not require one.

To the reviewers 👀

  • I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates

Changelog updates

Cross-platform user-facing changes

  • support save and exit in new submission flow - mounir

iOS user-facing changes

Android user-facing changes

Dev changes

Need help with something? Have a look at our docs, or get in touch with us.

@ArtsyOpenSource
Copy link
Contributor

ArtsyOpenSource commented May 23, 2024

This PR contains the following changes:

  • Cross-platform user-facing changes (support save and exit in new submission flow - mounir)

Generated by 🚫 dangerJS against 51c046b

Comment on lines 7 to 10
draft: {
values: ArtworkDetailsFormModel
currentStep: string
navigationState: any
} | null
setDraft: Action<this, this["draft"]>
Copy link
Member Author

Choose a reason for hiding this comment

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

Since we want to back the submission with my collection's artwork model, this should be a fine place to add it. We have a submission model that is powering the existing model, but it's currently so full of other stuff that doesn't make sense here and I couldn't use it just in case we roll back the FF.

@MounirDhahri MounirDhahri force-pushed the chore/add-save-and-exit-to-submissions branch 2 times, most recently from 69e805d to 17c3dad Compare May 23, 2024 11:08
Copy link
Contributor

@olerichter00 olerichter00 left a comment

Choose a reason for hiding this comment

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

I don't really understand what this PR is doing. Could you elaborate a bit on what "Save and Exit" means and how you've implemented it, please? The feature flag description says "Enable save and continue submission flow." which sounds more like what I understand from reading the code and looking at the screen recording.

@MounirDhahri
Copy link
Member Author

Fair enough - I will add more details

@olerichter00
Copy link
Contributor

Fair enough - I will add more details

I just saw that you've added a description to the ticket. Now I understand what this PR is doing 💡

@MounirDhahri
Copy link
Member Author

I just updated the description of the PR as well, I apologize again 🙏

Copy link
Contributor

@olerichter00 olerichter00 left a comment

Choose a reason for hiding this comment

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

Although this solution works, intuitively, I would say that this feature should rather be built on a RESTful edit route: /sell/submissions/:submissionID/edit. This URL could then accept a parameter to define the initial step the screen opens, such as ?initialStep=artworkDetails.

For the "Continue previous submission" button to work, the "Save and Exit" button could store the current step and submission ID on the device and make it accessible to link to /sell/submissions/:submissionID/edit?initialStep=:initialStep.

I'm happy to jump on a call to discuss these solutions 🤙

@MounirDhahri
Copy link
Member Author

Your comment makes total sense - I think I can get to support that with not much effort. Let's do it together

@MounirDhahri MounirDhahri force-pushed the chore/add-save-and-exit-to-submissions branch 2 times, most recently from de72c62 to ea8241f Compare May 24, 2024 08:17
@MounirDhahri
Copy link
Member Author

@olerichter00 I continued on our progress yesterday, please let me know if there is something else to change.
Also, btw, we tested today's PR on today's build and it's working well

olerichter00
olerichter00 previously approved these changes May 24, 2024
Copy link
Contributor

@olerichter00 olerichter00 left a comment

Choose a reason for hiding this comment

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

Looks great! 🌟

I've added a few comments here and there ✍️

Comment on lines 6 to 10
draft: {
submissionID: string
currentStep: string
} | null
setDraft: Action<this, this["draft"]>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move this state somewhere else? It does not seem to be related directly to My Collection.

Copy link
Member Author

Choose a reason for hiding this comment

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

makes sense

Comment on lines 21 to 24
// Reset form if user is on the last step
// This is to ensure that the user can start a new submission
// This is not required but is a nice to have as a second layer of protection
GlobalStore.actions.myCollection.setDraft(null)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is when the user has finished the submission, right? And in this case, we don't want to show the button anymore because there is no submission to continue...

Copy link
Member Author

Choose a reason for hiding this comment

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

yes exactly

Comment on lines 64 to 71
// TODO: Better error handling
if (!data?.submission) {
return (
<Flex flex={1} alignItems="center" justifyContent="center">
<Text variant="sm-display">Submission not found</Text>
</Flex>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use the "Unable to load" screen here?

export const LoadFailureView: React.FC<LoadFailureViewProps & BoxProps> = ({

@@ -45,6 +52,34 @@ export type SubmitArtworkStackNavigation = {
ArtistRejected: undefined
}

export const SubmitArtworkFormEdit: React.FC<SubmitArtworkProps> = withSuspense((props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about moving this into its own file? This file now exports two components.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure - makes sense


const showContinueSubmission = !!enableSaveAndContinue && !!draft?.submissionID
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 showContinueSubmission = !!enableSaveAndContinue && !!draft?.submissionID
const showContinueSubmission = !!enableSaveAndContinue && !!draft?.submissionID

Comment on lines +21 to +24
/**
* @deprecated
* Please use ArtworkDetailsFormModel from app/Scenes/SellWithArtsy/ArtworkForm/Utils/validation.ts
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

@@ -184,3 +272,17 @@ export const getCurrentRoute = () =>
__unsafe__SubmissionArtworkFormNavigationRef.current?.getCurrentRoute()?.name as
| keyof SubmitArtworkStackNavigation
| undefined

const getInitialNavigationState = (initialStep: SubmitArtworkScreen) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: This could get into a helper or util file to keep this file a bit smaller and clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@MounirDhahri MounirDhahri merged commit 34077fd into main May 27, 2024
7 checks passed
@MounirDhahri MounirDhahri deleted the chore/add-save-and-exit-to-submissions branch May 27, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants