Skip to content

Commit

Permalink
Merge pull request #140 from suvarnakale/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #PS-1704 bug: credentials corrected for facilitator
  • Loading branch information
itsvick authored Aug 13, 2024
2 parents 5b88fbb + 2c19f0f commit 9c81d41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/AddFacilitator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ const AddFacilitatorModal: React.FC<AddFacilitatorModalprops> = ({
if (typeof window !== 'undefined' && window.localStorage) {
fieldData = JSON.parse(localStorage.getItem('fieldData') || '');
}
const yearOfJoining = formData['year of joining scp'];
const { username, password } = generateUsernameAndPassword(
fieldData?.state?.stateCode,
'F'
'F',
yearOfJoining
);
setUsername(username);
setPassword(password);
Expand Down
1 change: 1 addition & 0 deletions src/components/AddLeanerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
}
const { username, password } = generateUsernameAndPassword(
fieldData?.state?.stateCode,
'',
''
);
const apiBody: any = {
Expand Down
8 changes: 5 additions & 3 deletions src/utils/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,16 @@ export const accessGranted = (

export const generateUsernameAndPassword = (
stateCode: string,
role: string
role: string,
yearOfJoining: string
) => {
const currentYear = new Date().getFullYear().toString().slice(-2);
const randomNum = Math.floor(10000 + Math.random() * 90000).toString();

const yearSuffix =
yearOfJoining !== '' ? yearOfJoining.slice(-2) : currentYear;
const username =
role === 'F'
? `FSC${stateCode}${currentYear}${randomNum}`
? `FSC${stateCode}${yearSuffix}${randomNum}`
: `SC${stateCode}${currentYear}${randomNum}`;
const password = randomNum;

Expand Down

0 comments on commit 9c81d41

Please sign in to comment.