Skip to content

Add option to save on localstorage#14

Merged
jpedroschmitz merged 1 commit intojpedroschmitz:mainfrom
willianjusten:add-support-localstorage
Mar 24, 2026
Merged

Add option to save on localstorage#14
jpedroschmitz merged 1 commit intojpedroschmitz:mainfrom
willianjusten:add-support-localstorage

Conversation

@willianjusten
Copy link
Copy Markdown
Contributor

@willianjusten willianjusten commented Mar 21, 2026

Description

The idea is to keep the privacy of the data, so it's going to be store only on localstorage.
Another detail, is that we don't load the data directly, only if they want and also add an option to clear the data, keeping a bit more safe to the customer as well.

  • Add an option to save the filled information to the localstorage
  • Add an option to load the information from localstorage if exists
  • Add an option to clear the localstorage if exists

Video

Screen.Recording.2026-03-21.at.20.01.35.mov

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 21, 2026

@willianjusten is attempting to deploy a commit to the João Pedro Team on Vercel.

A member of the Team first needs to authorize it.

Comment on lines -264 to +279
<button
type="submit"
className="rounded-md bg-indigo-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 mt-10"
disabled={isGenerating}
>
Download PDF
</button>
<div className="flex flex-wrap gap-4 mt-10">
<Button type="submit" color="indigo" disabled={isGenerating}>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know the styles are a little bit different, but as to me, it makes more sense to use the buttons defined in the UI, so they're all cohesive.

try {
const data = getValues();
localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
setHasSavedData(true);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't add any posthog event, but if you want, we can add it.

@willianjusten willianjusten force-pushed the add-support-localstorage branch from 1577f3f to a016588 Compare March 21, 2026 23:00
Comment on lines +189 to +193
<Controller
control={control}
name={`services.${index}.amount`}
render={({ field: { onChange, value, name } }) => (
<CurrencyInput
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I needed to change to a controlled input, so it can be reset/loaded with different values, also in order to save only the numbers instead of the full string with currency code

Copy link
Copy Markdown
Owner

@jpedroschmitz jpedroschmitz left a comment

Choose a reason for hiding this comment

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

There you go, loved it

@jpedroschmitz jpedroschmitz merged commit 7a925b5 into jpedroschmitz:main Mar 24, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants