Skip to content

Commit 017faf3

Browse files
Merge pull request #4101 from beckn/bugfix/kundan/3685/dsep-scholarship-flow
fix(DSEP): fixed dsep scholarship flow
2 parents c450b29 + 54199dd commit 017faf3

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

apps/dsep/components/jobSearch/JobSearch.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
import React from 'react'
1+
import React, { useState } from 'react'
22
import SearchBar from '../header/SearchBar'
33
import { Box } from '@chakra-ui/react'
44
import { JobsSearchPropsModel } from './JobsSearch.types'
55
import { ProductCard } from '@beckn-ui/becknified-components'
66
import JobCardRenderer from './job-card-renderer'
7+
import { useRouter } from 'next/router'
78

89
const JobSearch: React.FC<JobsSearchPropsModel> = props => {
10+
const router = useRouter()
911
const { jobs, handleChange, searchvalue } = props
12+
const [searchKeyword, setSearchKeyword] = useState(router.query?.searchTerm || '')
1013

1114
return (
1215
<div>
1316
<Box className="job-search-bar">
1417
<SearchBar
15-
handleChange={() => {}}
18+
handleChange={(text: string) => {
19+
setSearchKeyword(text)
20+
localStorage.removeItem('optionTags')
21+
localStorage.setItem(
22+
'optionTags',
23+
JSON.stringify({
24+
name: text
25+
})
26+
)
27+
window.dispatchEvent(new Event('storage-optiontags'))
28+
}}
1629
searchString={searchvalue}
1730
/>
1831
</Box>

apps/dsep/components/landingPage/LandingPage.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,26 @@ const LandingPage: React.FC = () => {
3232
localStorage.setItem('optionTags', JSON.stringify({ name: searchTerm }))
3333
Router.push(`/search?searchTerm=${searchTerm}`)
3434
}
35+
const navigateToScholarship = () => {
36+
localStorage.setItem('optionTags', JSON.stringify({ name: searchTerm }))
37+
Router.push(`/scholarshipSearchPage?searchTerm=${searchTerm}`)
38+
}
39+
const navigateToJob = () => {
40+
localStorage.setItem('optionTags', JSON.stringify({ name: searchTerm }))
41+
Router.push(`/jobSearch?searchTerm=${searchTerm}`)
42+
}
3543

3644
const handleClick = (type: string) => {
3745
setActiveCard(type)
3846
}
3947

4048
const searchIconClickHandler = (e: any) => {
4149
if (searchTerm) {
42-
navigateToSearchResults()
50+
activeCard === 'course'
51+
? navigateToSearchResults()
52+
: activeCard === 'jobs'
53+
? navigateToJob()
54+
: navigateToScholarship()
4355
}
4456
e.preventDefault()
4557
}

apps/dsep/components/scholarship/scholarshipCard/ScholarshipCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface ScholarshipCardProps {
1414
}
1515

1616
const ScholarshipCard: FC<ScholarshipCardProps> = props => {
17+
console.log(props)
1718
const { t } = useLanguage()
1819
return (
1920
<DetailCard>
@@ -62,7 +63,7 @@ const ScholarshipCard: FC<ScholarshipCardProps> = props => {
6263
<Typography text={props.scholarshipStatus} />
6364
</Flex>
6465
</Flex>
65-
{props.scholarshipStatus === 'Approved' ? (
66+
{props.scholarshipStatus === 'Approved' || props.scholarshipStatus === null ? (
6667
<>
6768
<Divider
6869
mt={'15px'}

apps/dsep/pages/jobSearch.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import LoaderWithMessage from '@beckn-ui/molecules/src/components/LoaderWithMessage/loader-with-message'
22
import { Box } from '@chakra-ui/react'
33
import Cookies from 'js-cookie'
4+
import { useRouter } from 'next/router'
45
import React, { useEffect, useState } from 'react'
56
import JobSearch from '../components/jobSearch/JobSearch'
67
import { useLanguage } from '../hooks/useLanguage'
@@ -9,17 +10,18 @@ import { ParsedItemModel, SearchResponseModel } from '../types/search.types'
910
import { getParsedSearchlist } from '../utilities/search-utils'
1011

1112
const jobSearch = () => {
13+
const router = useRouter()
1214
const [jobs, setJobs] = useState<ParsedItemModel[]>([])
1315
const [isLoading, setIsLoading] = useState<boolean>(true)
14-
16+
const [searchKeyword, setSearchKeyword] = useState(router.query?.searchTerm || '')
1517
const apiUrl = process.env.NEXT_PUBLIC_API_URL
1618
const { t } = useLanguage()
1719

1820
const searchPayload = {
1921
context: {
2022
domain: 'dsep:jobs'
2123
},
22-
searchString: ''
24+
searchString: searchKeyword
2325
}
2426

2527
const fetchJobs = () => {

apps/dsep/pages/scholarshipSearchPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ import { ParsedItemModel } from '../types/search.types'
88
import { getParsedSearchlist } from '../utilities/search-utils'
99
import axios from '../services/axios'
1010
import { testIds } from '@shared/dataTestIds'
11+
import { useRouter } from 'next/router'
1112

1213
const ScholarshipCard = () => {
14+
const router = useRouter()
1315
const [isLoading, setIsLoading] = useState(true)
1416
const [scholarShips, setScholarships] = useState<ParsedItemModel[]>([])
1517
const [isError, setIsError] = useState(false)
1618
const dsepScholarshipUrl = process.env.NEXT_PUBLIC_API_URL
19+
const [searchKeyword, setSearchKeyword] = useState(router.query?.searchTerm || '')
1720

1821
const { t } = useLanguage()
1922

@@ -23,7 +26,7 @@ const ScholarshipCard = () => {
2326
context: {
2427
domain: 'dsep:scholarships'
2528
},
26-
searchString: ''
29+
searchString: searchKeyword
2730
})
2831
const searchData = getParsedSearchlist(scholarshipSearchResponse.data.data)
2932
setScholarships(searchData)

0 commit comments

Comments
 (0)