Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

const queryClient = new QueryClient();
const manage = true;
const manage = false;

const App = () => {
return (
Expand Down
16 changes: 12 additions & 4 deletions src/config/firebase-config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { initializeApp } from 'firebase/app';
import { getAnalytics } from 'firebase/analytics';
import { getFirestore } from '@firebase/firestore';
import { getAnalytics, isSupported } from 'firebase/analytics';
import { getFirestore } from 'firebase/firestore';
import { getStorage } from 'firebase/storage';
import { getAuth, FacebookAuthProvider } from 'firebase/auth';

const firebaseConfig = {
apiKey: process.env.REACT_APP_API_KEY,
authDomain: process.env.REACT_APP_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_DATABASE_URL,
databaseURL: process.env.REACT_APP_DATABASE_URL,
projectId: process.env.REACT_APP_PROJECT_ID,
storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGING_SENDERID,
Expand All @@ -16,7 +16,15 @@ const firebaseConfig = {
};

const app = initializeApp(firebaseConfig);
export const analytics = getAnalytics(app);


export let analytics;
if (typeof window !== 'undefined') {
Copy link
Member Author

Choose a reason for hiding this comment

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

Try to convert this code into async await just like we are doing inside the entire code base

isSupported().then((ok) => {
if (ok) analytics = getAnalytics(app);
});
}

export const db = getFirestore(app);
export const storage = getStorage(app);
export const auth = getAuth(app);
Expand Down
19 changes: 9 additions & 10 deletions src/data/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { emailValidation, idValidation, experienceValidation, numberValidation, selectionValidation, stringValidation } from '../utils';

import { emailValidation, idValidation, experienceValidation, numberValidation, selectionValidation, stringValidation, passwordValidation } from '../utils';

export const labels = [
{
Expand All @@ -23,13 +22,13 @@ export const labels = [
key: 'id',
validator: idValidation,
},
// {
// label: "Password",
// type: "TextField",
// showInput: "false",
// key: "password",
// validator: passwordValidation,
// },
{
label: "Password",
Copy link
Member Author

Choose a reason for hiding this comment

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

Check with one of the other mentors that this is ok to un-comment

type: "TextField",
showInput: "false",
key: "password",
validator: passwordValidation,
},
{
label: 'Phone Number',
type: 'TextField',
Expand Down Expand Up @@ -96,5 +95,5 @@ export const errorMessages = {
phoneNumber: 'Phone number must contain 10 digits',
email: 'Email is not valid',
fullName: 'Must be in English! min 3 characters',
// password: "Password must contain atleast 6 chars.",
password: "Password must contain atleast 6 chars.",
};
27 changes: 21 additions & 6 deletions src/hooks/useSheets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,36 @@ const fetchDataFromCsv = async () => {
);

if (!response.ok) {
throw new Error('Failed to fetch data from Google Sheets');
throw new Error('Failed to fetch data from Google Sheets. status=' + response.status);
}

const csvData = await response.text();
const parsedData = parseCsv(csvData);
return parsedData;
} catch (error) {}
const parsed = parseCsv(csvData);
console.log('[useSheets] parsed rows:', parsed.length, parsed.slice(0, 3));
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove the console

return parsed;
} catch (error) {
console.error('[useSheets] fetch failed:', error);
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove the console

return [];
}
};

const parseCsv = (csvData) => {
return csvData.split('\n').map((row) => row.split(/","/));
return csvData
Copy link
Member Author

Choose a reason for hiding this comment

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

Check if we can parse the file something like this :

return data.split(/n).map((row) => row.split(/","/)

.replace(/\r/g, '')
.split('\n')
.map((row) => row.replace(/^"?|"?$/g, ''))
.filter((row) => row.trim() !== '')
.map((row) => row.split(/","/).map((cell) => cell.trim()));
};


const useGoogleSheetsData = () => {
return useQuery({queryKey:'googleSheetsData',queryFn: fetchDataFromCsv});
return useQuery({
queryKey: ['googleSheetsData'],
queryFn: fetchDataFromCsv,
refetchOnWindowFocus: false,
staleTime: 5 * 60 * 1000,
Copy link
Member Author

@Tamir198 Tamir198 Oct 13, 2025

Choose a reason for hiding this comment

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

The magic number should be saved inside a const variable

For example:

const VARIABLE_NAME = 5

And so on

});
};

export default useGoogleSheetsData;
Loading