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

Resume processing #36

Closed
jiin-kim109 opened this issue Nov 8, 2023 · 0 comments · Fixed by #58
Closed

Resume processing #36

jiin-kim109 opened this issue Nov 8, 2023 · 0 comments · Fixed by #58
Assignees
Labels
Module Core module design Report Page

Comments

@jiin-kim109
Copy link
Member

jiin-kim109 commented Nov 8, 2023

Description:
Now that we have our backend Resume API (ticket #30), it's time to build communication between our frontend and backend.

When a user uploads a resume PDF file to the drop zone, it should initiate an API call to the resume API. As implemented in #19, this action should promptly display the ProgressText component while awaiting the API response. Once the frontend receives the API response, it should navigate the user to the reporting page. Plus, the API response data should be dispatched to a React context so that it can be shared with the reporting page.

To summarize,

  1. Modify the Dropzone and DragNDrop components so that they initiate an API call when a user uploads an appropriate PDF file. Instead of directly implementing the API invocation logic in the Dropzone or MainPage, it is recommended to separate it to a custom hook (you may create a "hooks/" directory). Pass the hook's high-level function from the page to the component as a callback.

https://medium.com/@nelson_examiner/building-custom-react-hooks-for-calling-apis-ab82a6b45ff
e.g.

// useEmployees.ts

import { useCallback, useState } from "react"
import { Employee } from "../utils/types"
import { useCustomFetch } from "./useCustomFetch"
import { EmployeeResult } from "./types"

export function useEmployees(): EmployeeResult {
  const { fetchWithCache, loading } = useCustomFetch()
  const [employees, setEmployees] = useState<Employee[] | null>(null)

  const fetchAll = useCallback(async () => {
    const employeesData = await fetchWithCache<Employee[]>("employees")
    setEmployees(employeesData)
  }, [fetchWithCache])

  const invalidateData = useCallback(() => {
    setEmployees(null)
  }, [])

  return { data: employees, loading, fetchAll, invalidateData }
}
  1. Create a React Context
    Create a React context so that the reporting page can subscribe to the API response.

  2. Navigates to the reporting page after the dispatch

  3. Unit testing

Testing this API call should be conducted using MSW. You won't be testing the real backend API every time you run the test suites. Instead, you will set up a mock API response server called MSW and test them out.

Unit testing with MSW:
https://jskim1991.medium.com/react-unit-testing-apis-with-mock-service-works-msw-ca112ceddde9

Acceptance Criteria:

1 API call made after a file upload on the dropzone
2. page transition to the reporting page
3. reporting page can subscribe the response data via React Context
4. Write a custom hook implementing API invocation logic.

@jiin-kim109 jiin-kim109 changed the title user upload resume processing TBD by Jin::user upload resume processing Nov 8, 2023
@jiin-kim109 jiin-kim109 changed the title TBD by Jin::user upload resume processing Resume processing Nov 9, 2023
@jiin-kim109 jiin-kim109 added Module Core module design Report Page labels Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module Core module design Report Page
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants