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

project enhancements #22

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

project enhancements #22

wants to merge 8 commits into from

Conversation

Jood80
Copy link
Collaborator

@Jood80 Jood80 commented Apr 19, 2023

In this PR:

  • split small parts of the code onto dedicated files/folders:
    • Forms Validation onto utils/validation.util.ts
    • Mui theme & fonts onto assets/fonts & assets/theme
    • examplePlaylistSearch data onto utils/constants/playlistSearch.constant.ts
    • separated createAsyncThunk and extraReducers from the slice files, and moved each one onto a standalone file.
  • created a MaterialUI component and moved the imports there.
  • rearranged the order of imports statements.
  • moved the backend API endpoints to endpoints.constants.ts file instead of writing it directly wihtin createThunkAsync functions

@Jood80 Jood80 changed the title project enhancments project enhancements Apr 19, 2023
@Jood80 Jood80 requested a review from Amoodaa April 19, 2023 23:28
client/src/App.tsx Show resolved Hide resolved
Comment on lines +1 to +6
/**
* --------------------------------
* Import Material UI Components
* --------------------------------
*/
// Style Components
Copy link
Owner

Choose a reason for hiding this comment

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

whats the motivation behind this file?
Why not import directly from mui?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Amoodaa Nothing special, just thought of it in case any of these components might need some customization later, that was my only concern.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah! Mui allows for insane customizability using the theme, so i wouldnt reexport it for that reason
also its better to remove the customizability so you can force the team to not override the styles, unless agreed on case by case basis

@@ -0,0 +1,11 @@
export const BASE_URL = 'http://localhost:8080';
Copy link
Owner

Choose a reason for hiding this comment

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

base url isnt just the localhost, how are we dealing with that on front end, also i thought you were trying to unify front and back routes definition into 1 file

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 thought you were trying to unify front and back routes definition into 1 file.

  • yes, that was my intention, as I thought it might be easier to track the modifications of endpoints on both sides.

Copy link
Owner

Choose a reason for hiding this comment

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

ah, can we use the .env though?

Comment on lines +1 to +14
import { ActionReducerMapBuilder } from '@reduxjs/toolkit';
import { searchYoutube } from './thunk';
import { SearchState } from './types';

export const extraReducers = (builder: ActionReducerMapBuilder<SearchState>) => {
builder
.addCase(searchYoutube.pending, state => {
state.state = 'loading';
})
.addCase(searchYoutube.fulfilled, (state, action) => {
state.state = 'idle';
state.youtubeSearchResult = action.payload.data;
});
};
Copy link
Owner

Choose a reason for hiding this comment

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

Imho this is an overkill extraction, the slice file is supposed to be logic heavy, i agree with taking out the thunks from same file, but the slice will have its own simpler reducers, just add these extra ones there as well i think

but you know whats amazing here? nice work on the typing! i hate when people extract and dont type!! this is amazing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Roger that! will reunion the reducers family then.

client/src/slices/search/slice.ts Show resolved Hide resolved
Comment on lines +1 to +8
import { YoutubePlaylistSearch, YoutubeVideoSearch } from 'youtube.ts';

export interface SearchState {
youtubeSearchResult: YoutubeVideoSearch | YoutubePlaylistSearch | null;
state: 'idle' | 'loading' | 'failed';
}

export type YoutubeSearchForm = { searchTerm: string; type: 'playlists' | 'videos' };
Copy link
Owner

Choose a reason for hiding this comment

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

me wouldnt have extracted that, but it's ok, keep it!
for me, sometimes it's not worth the mental overhead of extracting stuff, you know switching files and looking here and there to make 1 small change
I try to make all my changes be nice and friendly for developers (caring for DX)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You got a very legitimate point!
But here I might have a question; when it comes to refactor your code, how would you distinguish between an overkill cleanup/premature optimization and a separation of concerns?

client/src/utils/validation.util.ts Show resolved Hide resolved
@RandSohail RandSohail self-requested a review April 28, 2023 11:31
},
);
},
extraReducers: builder => extraReducers(builder),
Copy link
Owner

Choose a reason for hiding this comment

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

bring this back in, because the extra reducers for this slice wont increase nor the core reducers

the slice is good enough to have all the reducers in them as you'd have a big "reducer.ts" when using plain redux

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.

2 participants