-
Notifications
You must be signed in to change notification settings - Fork 0
divie between register to sort day and regesteration to the website #47
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 = [ | ||
| { | ||
|
|
@@ -23,13 +22,13 @@ export const labels = [ | |
| key: 'id', | ||
| validator: idValidation, | ||
| }, | ||
| // { | ||
| // label: "Password", | ||
| // type: "TextField", | ||
| // showInput: "false", | ||
| // key: "password", | ||
| // validator: passwordValidation, | ||
| // }, | ||
| { | ||
| label: "Password", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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', | ||
|
|
@@ -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.", | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The magic number should be saved inside a const variable For example:
And so on |
||
| }); | ||
| }; | ||
|
|
||
| export default useGoogleSheetsData; | ||
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.
Try to convert this code into async await just like we are doing inside the entire code base