Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
eaf22a1
feat: translations & check design stock for cart
nvnt122 Oct 22, 2025
2127737
feat: add currentScope state and setCurrentScope reducer to KCSlice
nvnt122 Oct 24, 2025
9cc3e76
Merge branch 'develop' of https://github.com/summit-webapp/summit int…
nvnt122 Oct 27, 2025
0885860
feat: transaltions for additional inputs
nvnt122 Nov 20, 2025
7166493
feat: add grade change param list api
nvnt122 Nov 21, 2025
75d7d8d
feat: add grade change param list api
nvnt122 Nov 21, 2025
00d4593
Merge branch 'emr-api' of https://github.com/nvnt122/summit into emr-api
nvnt122 Nov 21, 2025
5b72554
Merge branch 'emr-api' of https://github.com/nvnt122/summit into emr-api
nvnt122 Nov 21, 2025
77c31f3
Merge branch 'emr-api' of https://github.com/nvnt122/summit into emr-api
nvnt122 Nov 21, 2025
e18c3be
feat: update translations
nvnt122 Nov 27, 2025
6495b48
feat: add diamond change parameters list API
nvnt122 Nov 28, 2025
fb7bbe9
feat: integrate user default data handling and update API endpoints
nvnt122 Dec 1, 2025
b1d592e
feat: refactor user default data handling and update state management
nvnt122 Dec 2, 2025
c69a26a
feat: add design bank count to login hook and update API registry
nvnt122 Dec 3, 2025
bf7da6a
fix: langauge & currency value
nvnt122 Dec 4, 2025
02c2206
feat: add color stone change parameters list and update API endpoints
nvnt122 Dec 5, 2025
3b9e04c
feat: update gradeChange option listing api
nvnt122 Dec 5, 2025
d91e4a0
feat: default voucherMode in userdata
nvnt122 Dec 9, 2025
a47e3d0
feat: store filters based on users, metal, diamond, colorstone list f…
nvnt122 Dec 11, 2025
599f623
feat: update instructions api & translations
nvnt122 Dec 12, 2025
78b46d4
feat: fix current scope
nvnt122 Dec 12, 2025
c47b3fb
feat: translations for KC
nvnt122 Dec 15, 2025
22e2f89
feat: product card detail toggle in kc slice
nvnt122 Dec 15, 2025
5cc06c1
feat: translations
nvnt122 Dec 22, 2025
55bbf39
feat: select all variable
nvnt122 Dec 23, 2025
5bd1855
fix: remove order listing & details page comp for KC
nvnt122 Dec 23, 2025
5a403bd
feat: add translation for new input labels
nvnt122 Jan 29, 2026
edbcdae
feat: enhance product listing and state management with new scope and…
nvnt122 Feb 3, 2026
626210b
fix: set default language & currency
nvnt122 Feb 4, 2026
5702733
feat: update EMR API handler to support blob responses and enhance SD…
nvnt122 Feb 6, 2026
8488e5a
feat: enhance API SDK integration by adding type safety for EMR API keys
nvnt122 Feb 9, 2026
500296b
feat: add translations for stock synchronization and client selection…
nvnt122 Feb 12, 2026
c37171d
fix: update default currentScope to 'Database'
nvnt122 Feb 12, 2026
a1ca628
fix: update login hook to use dispatch for setting customer and scope
nvnt122 Feb 13, 2026
d89a505
feat: integrate @tanstack/react-query for improved data fetching and …
nvnt122 Feb 16, 2026
dd3743b
fix: add resetStore dispatch after successful login to clear authenti…
nvnt122 Feb 19, 2026
f3b88ec
feat: update localization strings for stock filtering in multiple lan…
nvnt122 Feb 20, 2026
d9ef5ec
feat: add stock cart slice for managing stock cart state and actions
nvnt122 Feb 25, 2026
dcbd28a
feat: add redirects in next.config.js and update dependencies for @ta…
nvnt122 Feb 26, 2026
ef214cf
feat: add designSizes and attributesData to FiltersState in KCSlice
nvnt122 Mar 2, 2026
5f87bed
fix: add optional chaining to prevent errors when accessing filters
nvnt122 Mar 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ next-env.d.ts
/pages/support
/pages/support/*
/pages/warranty
/services/config/theme-config.ts
/services/config/theme-config.ts

kc.code-workspace
74 changes: 44 additions & 30 deletions hooks/AuthHooks/useLoginHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ import { Option } from '../../store/slices/general_slices/multilingual-slice';
import i18n from '../../i18n/i18n';
import useCurrencyLanguageHandler from '../GeneralHooks/LanguageHandler';
import { currencyOptions } from '../../utils/addon-utils/currency-map';
import useUserDefaultData from '../addon-hooks/kc-hooks/useUserData';
import { setCustomer, setDesignBankCount, setScope } from '../../store/slices/general_slices/kc-slice';
import { resetStore } from '../../store/slices/auth/logout-slice';

const useLoginHook = () => {
const { AFTER_LOGIN_REDIRECT_URL } = CONSTANTS;
const dispatch = useDispatch();
const router = useRouter();
const { t } = useTranslation('common');
const { handleCurrencyShallowUpdate, handleLanguageShallowUpdate } = useCurrencyLanguageHandler();
const { fetchUserDefaultData } = useUserDefaultData();
const [loginForm, setLoginForm] = useState<TypeLoginForm>({ usr: '', pwd: '' });
const [passwordHidden, setPasswordHidden] = useState(true);
const [isLoginThroughOTP, setIsLoginThroughOTP] = useState<boolean>(false);
Expand All @@ -33,48 +37,58 @@ const useLoginHook = () => {

const fetchToken = async (values: TypeLoginForm) => {
setLoginBtnLoader(true);

try {
const userParams: TypeLoginAPIParams = {
values: { ...values },
isGuest: false,
loginViaOTP: false,
LoginViaGoogle: false,
};

// const tokenData = await getTokenFromLoginAPI(SUMMIT_APP_CONFIG, userParams);
// Need to check below login api logic. Need to make generic.

const tokenData = await emrLogin(userParams);

if (tokenData?.success === true && tokenData?.msg === 'success' && tokenData?.data?.hasOwnProperty('access_token')) {
localStorage.setItem('isLoggedIn', 'true');
localStorage.setItem('user', values.usr);
localStorage.setItem('party_name', tokenData?.data?.full_name);

if (tokenData?.data?.isPwdChg !== 0) {
dispatch(storeToken(tokenData?.data));
}

handleLanguageShallowUpdate(languageDisplayOptions.find((opt: Option) => opt?.label === tokenData?.data?.language)!);
handleCurrencyShallowUpdate(currencyOptions.find((opt: Option) => opt?.value === tokenData?.data?.currency)!);

localStorage.setItem('selected_language', tokenData?.data?.language);
localStorage.setItem('selected_currency', tokenData?.data?.currency);
// Redirect to the home page or any other page after successful login
if (tokenData?.data?.isPwdChg === 0) {
router.push('/forgot_password');
} else {
if (AFTER_LOGIN_REDIRECT_URL) {
router.push(AFTER_LOGIN_REDIRECT_URL);
} else {
router.push('/')
}

if (
tokenData?.success === true &&
tokenData?.msg === 'success' &&
tokenData?.data?.access_token
) {
const { access_token, isPwdChg, count, full_name } = tokenData.data;

if (isPwdChg !== 0) {
dispatch(storeToken(tokenData.data));
}
// toast.success('Login Successfully');

const redirectUrl =
isPwdChg === 0
? '/forgot_password'
: AFTER_LOGIN_REDIRECT_URL || '/';

router.replace(redirectUrl);

setTimeout(() => {
dispatch(setDesignBankCount(count));
dispatch(setCustomer(null));
dispatch(
setScope({
label: 'New Session (PDCM Design Bank)',
value: 'Database',
})
);

fetchUserDefaultData(access_token);

localStorage.setItem('isLoggedIn', 'true');
localStorage.setItem('user', values.usr);
localStorage.setItem('party_name', full_name);
}, 0);
}
} catch (error: any) {
if (error?.status === 400 && error?.response?.data?.error === "Invalid username or password") {
if (
error?.status === 400 &&
error?.response?.data?.error === 'Invalid username or password'
) {
toast.error(t('invalid_credentials'));
return;
} else {
toast.error(t('error_while_login'));
}
Expand Down
20 changes: 11 additions & 9 deletions hooks/GeneralHooks/KCLanguageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { Option } from '../../store/slices/general_slices/multilingual-slice';
import { currencyOptions } from '../../utils/addon-utils/currency-map';
import { useEffect } from 'react';

const useCurrencyLanguageHandler = () => {
const useCurrencyLanguageHandler = (postUserDefaultData?: (token: string, DefCurrency: string, DefLang: string, RefreshRt: string, LabRt: string, RMCtg: string, voucherModeType: string ) => void, userDefaultData?: any) => {
const dispatch = useDispatch();
const languageState = useSelector(SelectedLangFromStore)?.selectedLanguage;
const languageState = useSelector(SelectedLangFromStore)?.selectedLanguage?.trim();
const TokenFromStore: any = useSelector(get_access_token);
const currencyState = useSelector(currency_selector_state)?.selected_currency_value;
const currencyState = useSelector(currency_selector_state)?.selected_currency_value?.trim();
const handleAuthError = useAuthErrorHandler();
const selectedCurrency = currencyOptions.find((opt) => opt?.value === (currencyState))!;
const selectedLanguage = languageDisplayOptions.find((opt) => opt?.value === languageState)!;
const selectedCurrency = currencyOptions.find((opt) => opt?.value === currencyState || 'INR')!;
const selectedLanguage = languageDisplayOptions.find((opt) => opt?.value === languageState || 'en')!;

const updateUserPreference = async (language: Option, currency: Option) => {
const languageCode = language?.value.toString();
Expand All @@ -42,7 +42,8 @@ const useCurrencyLanguageHandler = () => {

const handleLanguageChange = (value: Option) => {
dispatch(setLanguage(value?.value));
updateUserPreference(value, selectedCurrency);
// updateUserPreference(value, selectedCurrency);
postUserDefaultData && postUserDefaultData(TokenFromStore?.token, languageDisplayOptions.find((opt: Option) => opt?.value === value?.value?.toString())?.label!?.trim(), userDefaultData?.DefCurrency, userDefaultData?.RefreshRt, userDefaultData?.LabRt, userDefaultData?.RMCtg, userDefaultData?.voucherModeType);
};

const handleLanguageShallowUpdate = (value: Option) => {
Expand All @@ -52,16 +53,17 @@ const useCurrencyLanguageHandler = () => {

const handleCurrencyChange = (value: Option) => {
dispatch(setCurrencyValue(value?.value));
updateUserPreference(selectedLanguage, value);
// updateUserPreference(selectedLanguage, value);
postUserDefaultData && postUserDefaultData(TokenFromStore?.token, userDefaultData?.DefLang, value?.value.toString().trim(), userDefaultData?.RefreshRt, userDefaultData?.LabRt, userDefaultData?.RMCtg, userDefaultData?.voucherModeType);
};

const handleCurrencyShallowUpdate = (value: Option) => {
dispatch(setCurrencyValue(value?.value));
}

useEffect(() => {
handleLanguageShallowUpdate(languageDisplayOptions.find((opt) => opt?.value === 'en')!);
handleCurrencyShallowUpdate(currencyOptions.find((opt) => opt?.value === 'RS')!);
handleLanguageShallowUpdate(selectedLanguage);
handleCurrencyShallowUpdate(selectedCurrency);
},[selectedCurrency, selectedLanguage]);

return {
Expand Down
3 changes: 3 additions & 0 deletions hooks/ProductDetailPageHooks/useProductDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import fetchPinCodesListAPI from '../../services/api/general-apis/get-pin-code-l
import debounce from 'debounce';
import useAuthErrorHandler from '../AuthHooks/handleAuthError';
import useCurrencyLanguageHandler from '../GeneralHooks/KCLanguageHandler';

type PinCodeTypes = {
name: string;
};
Expand Down Expand Up @@ -40,6 +41,7 @@ const useProductDetail = () => {
quantity: productDetailData?.min_order_qty || 1,
},
]);

const handleMultipleQtyChange = (index: number, itemCode: string, value: string) => {
setItemList((prevItemList: any) => {
if (!Array.isArray(prevItemList)) {
Expand Down Expand Up @@ -164,6 +166,7 @@ const useProductDetail = () => {
}
}
};

const debouncedSetValue = debounce((pinCode: string) => {
const found = pinCodeData.some((pin) => pin.name === pinCode);
setValidPinCode(found);
Expand Down
10 changes: 5 additions & 5 deletions hooks/ProductListPageHooks/useProductListFilterHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ const useProductListingFilterHook = () => {

if (existingSectionIndex !== -1) {
if (isChecked) {
if (!updatedFilters[existingSectionIndex].value.includes(filterValue)) {
updatedFilters[existingSectionIndex].value.push(filterValue);
if (!updatedFilters?.[existingSectionIndex].value.includes(filterValue)) {
updatedFilters?.[existingSectionIndex].value.push(filterValue);
}
} else {
updatedFilters[existingSectionIndex].value = updatedFilters[existingSectionIndex].value.filter((val: any) => val !== filterValue);
if (updatedFilters[existingSectionIndex].value.length === 0) {
updatedFilters = updatedFilters.filter((filter) => filter.name !== section);
if (updatedFilters?.[existingSectionIndex].value.length === 0) {
updatedFilters = updatedFilters?.filter((filter) => filter?.name !== section);
}
}
} else if (isChecked) {
updatedFilters.push({ name: section, value: [filterValue] });
updatedFilters?.push({ name: section, value: [filterValue] });
}

duplicateFilters = [...updatedFilters];
Expand Down
1 change: 1 addition & 0 deletions hooks/ProductListPageHooks/useProductsDataHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const useProductListing = () => {
page: '1',
currency: 'INR',
sort_by: sortBy,
scope: 'Database'
},
});
}
Expand Down
21 changes: 21 additions & 0 deletions lib/query-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { QueryClient } from '@tanstack/react-query';

const KC_LISTING_STALE_MS = 5 * 60 * 1000; // 5 minutes – same scope+cmcd won't refetch when navigating back
const KC_SESSION_FILTERS_STALE_MS = 5 * 60 * 1000;

export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: KC_LISTING_STALE_MS,
gcTime: 10 * 60 * 1000, // 10 min (formerly cacheTime)
},
},
});

export const KC_QUERY_KEYS = {
products: (cmcd: string, scope: string, filtersSignature: string) =>
['kc-products', cmcd, scope, filtersSignature] as const,
cart: (cmcd: string, odChr: string) => ['kc-cart', cmcd, odChr] as const,
voucher: (cmcd: string, voucherNoKey: string) => ['kc-voucher', cmcd, voucherNoKey] as const,
sessionFilters: (cmcd: string) => ['kc-session-filters', cmcd] as const,
};
11 changes: 10 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ const nextConfig = {
images: {
domains: ['summit.8848digitalerp.com', 'staging-twinkle.8848digitalerp.com', 'emr-euro-shine.8848digitalerp.com', 'backend.atelier-reya.com', 'kc-backend.8848digitalcloud.com'],
},
reactStrictMode: false,
reactStrictMode: false,
swcMinify: true,
async redirects() {
return [
{
source: '/',
destination: '/product-category',
permanent: false,
},
]
},
};

module.exports = withBundleAnalyzer(nextConfig);
Expand Down
Loading