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

Job data model change #66

Merged
merged 27 commits into from
Oct 7, 2024

Conversation

kategreenUSDS
Copy link
Collaborator

@kategreenUSDS kategreenUSDS commented Oct 2, 2024

About this pull request

Ticket: FFS-1775

Main goal: Move job, expense, and payment data model and methods to reflect a more relational state as discussed in redux documentation.

New data model structure

This will be the structure for payments and expenses as well. payments and expenses will have an index back to their associated job to allow for streamlined data storage and relational behavior.

export interface JobItem {
    description: string
    business: string
    taxesFiled: boolean
}

interface JobState {
    byId: {
        [id: string]: JobItem
    },
    allIds: Array<string>
}

What's in here

Data-model specific

  • Add user slice
  • Create payment slice
  • Move expense slice under job
  • Add all the methods for expense and payment (edit, delete, both of which aren't yet in the app, but will need to be)

Side effects

  • Split out the expense/add form into its own page like job/add+IncomeFormJob and payment/add+IncomeFormPayment
  • Move expenses pages under job in the routing/file structure to pass the correct params
  • Add explicit UUID id structure, which makes the routing look a little icky but is the standard for ids these days
  • Commented out some stuff in the statement/ section to get passing tests and created FFS-1818 for that work
  • Added a temporary flow choice to create "add expenses to a job" experience (I have some questions on how this will go in to the flow and work, but that's for later on)
  • Created test fixture generators, first pass on this notion

Copy link
Collaborator

@YvetteWhiteUSDS YvetteWhiteUSDS left a comment

Choose a reason for hiding this comment

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

fyi-- prereviewed per Kate's request. No comments; lgtm.

@kategreenUSDS kategreenUSDS changed the title [DRAFT] Job data model change Job data model change Oct 4, 2024
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file is net new and is the Form for adding and editing expenses. This is a side effect of the expenses work here

@@ -16,7 +16,7 @@ describe('Add Income To Ledger Page', async () => {
}))
mockRouter.push('/job/expense/add')
store = makeStore()
render (<Provider store={store}><Page /></Provider>)
render (<Provider store={store}><Page params={{idx: '0'}} /></Provider>)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this adds the job param. that's what idx is here

@@ -59,7 +59,7 @@ describe('Add Income To Ledger Page', async () => {

await waitFor(() => {
expect(mockRouter).toMatchObject({
asPath: "/job/expense/list"
asPath: "/job/list"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is the flow change choice i made to keep it moving

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this looks new, but it's actually moving the expense directory under the job/[idx] dir and then ripping out the <Form> to separate concerns

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for separating concerns.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is also a file move that looks net new but it's not

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this file was moved to the one below it in this list

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all of [jobSlice, expensesSlice, and paymentSlice] and their tests should look very similar. they are all using the same ideas and should be refactored to reuse logic eventually (i will make a ticket for it)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is stub page until we know what data we'll want to add

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

stub (see next file)

*/

export const createUuid = () => uuidv4()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'm not 100% sure this is the right place for this method, but here it will live until i find a better spot

Copy link
Collaborator

@YvetteWhiteUSDS YvetteWhiteUSDS left a comment

Choose a reason for hiding this comment

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

I appreciate the step by step comments-- super helpful.

control={control}
rules={{ required: {value:true, message: t('add_expense_date_required')} }}
render={({ field }) => (
<>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This empty <> is making my brain glitch. What does <></> do? Div?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'm pretty sure it's going to render the root element

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for separating concerns.

@kategreenUSDS kategreenUSDS merged commit 915bacf into main Oct 7, 2024
3 checks passed
@kategreenUSDS kategreenUSDS deleted the k8/FFS-1487/expenses-under-jobs-data-model-change branch October 7, 2024 15:01
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