Skip to content

Commit

Permalink
[Refactor]: Rename zustand_store into store. (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
onemanfighter committed May 7, 2024
1 parent c656689 commit 13b5fcb
Show file tree
Hide file tree
Showing 69 changed files with 49 additions and 55 deletions.
12 changes: 3 additions & 9 deletions craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@ module.exports = {
'@screens/*': path.resolve(__dirname, './src/screens/*'),
'@service': path.resolve(__dirname, './src/service'),
'@service/*': path.resolve(__dirname, './src/service/*'),
'@zustand_store': path.resolve(__dirname, './src/zustand_store'),
'@zustand_store/slice': path.resolve(
__dirname,
'./src/zustand_store/slice'
),
'@selectors': path.resolve(
__dirname,
'./src/zustand_store/selectors'
),
'@store': path.resolve(__dirname, './src/store'),
'@store/slice': path.resolve(__dirname, './src/store/slice'),
'@selectors': path.resolve(__dirname, './src/store/selectors'),
},
},
};
2 changes: 1 addition & 1 deletion src/components/navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { NavigationComponentProps } from './types';

import { profileSelector, themeSelector, useShallow } from '@selectors';
import { Theme, appStore } from '@zustand_store';
import { Theme, appStore } from '@store';

/**
* Navigation component.
Expand Down
2 changes: 1 addition & 1 deletion src/components/notification/NotificationComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NOTIFICATION_MODAL_ID } from './constants';
import { useTranslation } from 'react-i18next';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { notificationSelector, useShallow } from '@selectors';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/provider/alert_toast_provider/AlertToastProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ToastAlertComponent } from '@dash-ui';
import { ToastAlertProviderProps } from './types';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { alertSelector, useShallow } from '@selectors';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/provider/already_login/AlreadyLoginServiceProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';
import { alreadySignedIn } from '@service/supabase/supa_auth/AuthApi';
import { AlreadyLoginServiceProviderProps } from './types';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { authSelector, useShallow } from '@selectors';

const AlreadyLoginServiceProvider = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ImagePreviewModal } from '@dash-ui';
import { ImagePreviewModalProviderProps } from './types';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { imageModalSelector, useShallow } from '@selectors';

const ImagePreviewModalProvider = (props: ImagePreviewModalProviderProps) => {
Expand Down
2 changes: 1 addition & 1 deletion src/provider/router_provider/RouterProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RouterProvider } from 'react-router-dom';
import { privateRouter, publicRouter } from '@router';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { authSelector, useShallow } from '@selectors';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/provider/theme_provider/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { themeSelector, useShallow } from '@selectors';
import { ThemeProviderProps } from './types';

Expand Down
2 changes: 1 addition & 1 deletion src/screens/private/MainRootScreen/MainRootScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Outlet } from 'react-router-dom';
import { signOut } from '@service/supabase/supa_auth/AuthApi';
import { useEffect, useState } from 'react';
import { NavigationComponent, SidebarComponent } from '@dash-ui';
import { appStore, syncForTheFirstTime } from '@zustand_store';
import { appStore, syncForTheFirstTime } from '@store';
import { authSelector, profileSelector, useShallow } from '@selectors';

const MainRootScreen = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NotificationButton, NotificationButtonType } from '@dash-ui';
import { getErrorAlertData } from '@provider';
import { NotificationData, appStore } from '@zustand_store';
import { NotificationData, appStore } from '@store';
import { alertSelector, notificationSelector, useShallow } from '@selectors';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@assets';
import { TitleCard, TooltipComponent } from '@dash-ui';
import { profileSelector, useShallow } from '@selectors';
import { appStore } from '@zustand_store';
import { appStore } from '@store';

/**
* The text style for the profile preview screen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
WebsiteIcon,
} from '@assets';
import { InputText, InputType } from '@dash-ui';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import {
alertSelector,
authSelector,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/private/screens/projects/ProjectScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NavLink, Outlet, useLocation } from 'react-router-dom';
import { TooltipComponent } from '@dash-ui';
import { getAllProjects } from '@service/supabase/supastore/projects/ProjectsStoreApi';
import { AddIcon, DeleteIcon, EditIcon, PreviewIcon } from '@assets';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { authSelector, projectsSelector, useShallow } from '@selectors';

import getSubNavTitle from '../../../../util/nav/NavTitle';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';

import { ProjectCard, getProjectCardData } from '@dash-ui';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { projectsSelector, useShallow } from '@selectors';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import { ProjectCard, getProjectCardData } from '@dash-ui';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { projectsSelector, useShallow } from '@selectors';

type IProjectDeleteScreenProps = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import { ProjectCard, getProjectCardData } from '@dash-ui';
import { projectsSelector, useShallow } from '@selectors';
import { appStore } from '@zustand_store';
import { appStore } from '@store';

type IProjectEditScreenProps = {};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ProjectCard, getProjectCardData } from '@dash-ui';
import { projectsSelector, useShallow } from '@selectors';
import { appStore } from '@zustand_store';
import { appStore } from '@store';

const ProjectMainScreen = () => {
const { projectData } = appStore(useShallow(projectsSelector));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ImagePreviewModalButton } from '@dash-ui';
import { ProjectData } from '@service/supabase/supastore/projects/ProjectsCollection';
import { WebsiteIcon, GithubIcon, HostingerIcon } from '@assets';
import { imageModalSelector, useShallow } from '@selectors';
import { appStore } from '@zustand_store';
import { appStore } from '@store';

export type IProjectPreviewComponentProps = {
project: ProjectData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useParams } from 'react-router-dom';
import { useEffect, useState } from 'react';
import ProjectPreviewComponent from './ProjectPreviewComponent';
import { projectsSelector, useShallow } from '@selectors';
import { appStore } from '@zustand_store';
import { appStore } from '@store';

type ProjectSelectData = {
projectId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/public/login_screen/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LoginCred } from '@service/supabase/supa_auth/actions/AuthSignIn';
import { signIn } from '@service/supabase/supa_auth/AuthApi';
import { validatePassword } from '../../../util/input/Input';
import { useTranslation } from 'react-i18next';
import { AuthDataState, appStore } from '@zustand_store';
import { AuthDataState, appStore } from '@store';
import { authSelector, useShallow } from '@selectors';

interface UpdateProps {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/public/signup_screen/SignupScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SignUpCred } from '@service/supabase/supa_auth/actions/AuthSignUp';
import { signUp } from '@service/supabase/supa_auth/AuthApi';
import { getSuccessAlertData } from '@provider';
import { useTranslation } from 'react-i18next';
import { appStore } from '@zustand_store';
import { appStore } from '@store';
import { alertSelector, useShallow } from '@selectors';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/service/local_storage/auth/AuthStorageApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthDataState } from '@zustand_store';
import { AuthDataState } from '@store';
import { AuthTokenKey } from '../token_constants/StorageConstant';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/service/local_storage/theme/ThemeStorageApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Theme } from '@zustand_store';
import { Theme } from '@store';
import { themeKey } from '../token_constants/StorageConstant';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/service/supabase/supa_auth/AuthApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthDataState } from '@zustand_store';
import { AuthDataState } from '@store';
import { AuthTokenKey } from '../../local_storage/token_constants/StorageConstant';
import { firebaseForgotPassword } from './actions/AuthForgotPassword';
import { LoginCred, firebaseSingIn } from './actions/AuthSignIn';
Expand Down
2 changes: 1 addition & 1 deletion src/service/supabase/supa_auth/actions/AuthSignIn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthDataState } from '@zustand_store';
import { AuthDataState } from '@store';
import { SupabaseAuth } from '../../supabase_main/Supabase';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ToastAlertData } from '@provider';
import { UserProfileData } from './UserCollection';
import { getUserUsingId } from './actions/UserDataRead';
import { updateUserData } from './actions/UserDataWrite';
import { UserData } from '@zustand_store';
import { UserData } from '@store';

/**
* Method to get the user profileData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserData } from '@zustand_store';
import { UserData } from '@store';
import { SupabaseUsersDB } from '../../../supabase_main/Supabase';
import { SocialLink, SocialType, UserProfileData } from '../UserCollection';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ToastAlertData } from '@zustand_store/slice';
import { AppStoreState } from '@zustand_store';
import { ToastAlertData } from 'src/store/slice';
import { AppStoreState } from '@store';

export const alertSelector = (state: AppStoreState) => ({
alertData: state.Alert.alertData,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreState } from '@zustand_store';
import { AppStoreState } from '@store';
import { getAuthKeyData } from '@service/local_storage/auth/AuthStorageApi';

export const authSelector = (state: AppStoreState) => ({
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreState } from '@zustand_store';
import { AppStoreState } from '@store';

export const imageModalSelector = (state: AppStoreState) => ({
imageString: state.ImageModal.imageString,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreState } from 'src/zustand_store/store';
import { AppStoreState } from 'src/store/store';

export const notificationSelector = (state: AppStoreState) => ({
notificationData: state.Notification.data,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreState } from 'src/zustand_store/store';
import { AppStoreState } from 'src/store/store';

export const profileSelector = (state: AppStoreState) => ({
profileData: state.Profile.data,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreState } from '@zustand_store';
import { AppStoreState } from '@store';

export const projectsSelector = (state: AppStoreState) => ({
projectData: state.Projects.projects,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreState } from '@zustand_store';
import { AppStoreState } from '@store';

export const themeSelector = (state: AppStoreState) => ({
themeValue: state.Theme.themeValue,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreSlice } from '@zustand_store';
import { AppStoreSlice } from '@store';
import {
AlertState,
AlertStateSlice,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreSlice } from '@zustand_store';
import { AppStoreSlice } from '@store';
import { AuthDataState, AuthStateSlice } from './types';
import { getAuthKeyData } from '@service/local_storage/auth/AuthStorageApi';

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreSlice } from '@zustand_store';
import { AppStoreSlice } from '@store';
import { ImageModalState, ImageModalStateSlice } from './types';

const initialState: ImageModalState = {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreSlice } from '@zustand_store';
import { AppStoreSlice } from '@store';
import { NotificationState, NotificationStateSlice } from './types';

const initialState: NotificationState = {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
SocialType,
UserProfileData,
} from '@service/supabase/supastore/user_profile/UserCollection';
import { AppStoreSlice } from 'src/zustand_store/store';
import { AppStoreSlice } from 'src/store/store';
import { ProfileStateSlice, UserProfileState } from './types';
import {
getProfileKeyData,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreSlice } from '@zustand_store';
import { AppStoreSlice } from '@store';
import { ProjectDataState, ProjectStateSlice, ProjectData } from './types';

const initialState: ProjectDataState = {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppStoreSlice } from '@zustand_store';
import { AppStoreSlice } from '@store';
import { Theme, ThemeState, ThemeStateSlice } from './types';

const THEME = 'theme';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
createProjectsSlice,
createImageModalSlice,
createNotificationSlice,
} from '@zustand_store/slice';
} from '@store/slice';
import { AppStoreState } from './types';
import { createProfileSlice } from '../slice/Profile';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ImageModalStateSlice,
NotificationStateSlice,
ProfileStateSlice,
} from '@zustand_store/slice';
} from '@store/slice';
import {} from '../slice/Profile/types';

export interface AppStoreState {
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.path.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"@screens/*": ["src/screens/*"],
"@service": ["src/service"],
"@service/*": ["src/service/*"],
"@zustand_store": ["src/zustand_store/index"],
"@zustand_store/slice": ["src/zustand_store/slice"],
"@selectors": ["src/zustand_store/selectors"]
"@store": ["src/store/index"],
"@store/slice": ["src/store/slice"],
"@selectors": ["src/store/selectors"]
}
}
}

0 comments on commit 13b5fcb

Please sign in to comment.