-
Notifications
You must be signed in to change notification settings - Fork 1
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
Coding Dojo : Create custom hooks for presentation logic, modularise large functions <DO NOT MERGE> #245
base: development
Are you sure you want to change the base?
Conversation
@@ -31,3 +33,15 @@ export type NonBlockingError = { | |||
type: "non-blocking"; | |||
error: ConsistencyError; | |||
}; | |||
|
|||
export interface ImportOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to usecase
orgUnitName: string; | ||
countryCode: string; | ||
dryRun: boolean; | ||
eventListId: string | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Id wherever applicable. use Maybe<>
dryRun: boolean, | ||
eventListId: string | undefined | ||
): FutureData<ImportSummary> { | ||
public execute(inputFile: File, options: ImportOptions): FutureData<ImportSummary> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for future projects : do not pass file to domain, as it is not a domain entity
orgUnitName: currentOrgUnitAccess.orgUnitName, | ||
countryCode: currentOrgUnitAccess.orgUnitCode, | ||
dryRun: false, | ||
eventListId: "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so not pass empty string
}; | ||
const secondaryUploadId = localStorage.getItem("secondaryUploadId"); | ||
const params = { | ||
primaryUploadId: "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we should not pass empty strings
} | ||
}, [batchId, isPrimaryFileValid, isSecondaryFileValid, moduleName]); | ||
|
||
const changeBatchId = async (event: React.ChangeEvent<{ value: unknown }>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useCallback
} | ||
); | ||
}, [compositionRoot.fileSubmission, snackbar, orgUnitId, moduleName, orgUnitCode, uploadFileType, setLoading]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usecallbackeffect
const primaryUploadId = localStorage.getItem("primaryUploadId"); | ||
const secondaryUploadId = localStorage.getItem("secondaryUploadId"); | ||
if (secondaryUploadId && primaryUploadId) | ||
compositionRoot.glassDocuments.updateSecondaryFileWithPrimaryId(secondaryUploadId, primaryUploadId).run( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usecallbackeffect in all functions
if (secondaryFile) { | ||
validate(true); | ||
} else { | ||
validate(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate(Boolean(secondaryFile))
|
||
export function useSecondaryFile( | ||
secondaryFile: File | null, | ||
setSecondaryFile: React.Dispatch<React.SetStateAction<File | null>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chaneg null to undefined
📌 References
📝 Implementation
📹 Screenshots/Screen capture
🔥 Testing