11import clsx from 'clsx'
2- import { useState } from 'react'
32import { AiFillMobile , AiFillSecurityScan } from 'react-icons/ai'
43import { BsArrowRight , BsFillGearFill } from 'react-icons/bs'
54import { FaDatabase , FaPaintBrush , FaRobot , FaServer } from 'react-icons/fa'
65import { RiDeviceFill } from 'react-icons/ri'
76import { TbDots } from 'react-icons/tb'
8- import { StepProps } from 'src/components/Elements'
7+ import { Tag , useRemoteConfigStore } from 'src/features/remoteConfig'
8+ import { useUserPreferences } from 'src/stores/preferences'
99import { Occupation } from '../../types'
1010
1111const OCCUPATIONS : Occupation [ ] = [
1212 {
1313 title : 'Front-End Engineer' ,
1414 icon : FaPaintBrush ,
1515 sources : [ 'devto' , 'github' , 'medium' , 'hashnode' ] ,
16- tags : [ 'javascript' , 'typescript' ] ,
16+ tags : [ 'frontend' , ' javascript', 'typescript' , 'css' , 'react' , 'vue' , 'angular '] ,
1717 } ,
1818 {
1919 title : 'Back-End Engineer' ,
2020 icon : BsFillGearFill ,
2121 sources : [ 'devto' , 'github' , 'medium' , 'hashnode' ] ,
22- tags : [ 'go' , 'php' , 'ruby' , 'rust' , 'r' ] ,
22+ tags : [ 'backend' , ' go', 'php' , 'ruby' , 'rust' , 'r' ] ,
2323 } ,
2424 {
2525 title : 'Full Stack Engineer' ,
@@ -31,74 +31,92 @@ const OCCUPATIONS: Occupation[] = [
3131 title : 'Mobile' ,
3232 icon : AiFillMobile ,
3333 sources : [ 'reddit' , 'github' , 'medium' , 'hashnode' ] ,
34- tags : [ 'android' , 'kotlin' , 'java' , 'swift' , 'objective-c' ] ,
34+ tags : [
35+ 'android' ,
36+ 'mobile' ,
37+ 'kotlin' ,
38+ 'java' ,
39+ 'ios' ,
40+ 'swift' ,
41+ 'objectivec' ,
42+ 'react native' ,
43+ 'flutter' ,
44+ ] ,
3545 } ,
3646 {
3747 title : 'Devops Engineer' ,
3848 icon : FaServer ,
3949 sources : [ 'freecodecamp' , 'github' , 'reddit' , 'devto' ] ,
40- tags : [ 'devops' , 'bash' ] ,
50+ tags : [ 'devops' , 'kubernetes' , 'docker' , ' bash'] ,
4151 } ,
4252 {
4353 title : 'Data Engineer' ,
4454 icon : FaDatabase ,
4555 sources : [ 'freecodecamp' , 'github' , 'reddit' , 'devto' ] ,
46- tags : [ 'data- science' , 'python' , 'artificial- intelligence' , 'machine- learning' ] ,
56+ tags : [ 'data science' , 'python' , 'artificial intelligence' , 'machine learning' ] ,
4757 } ,
4858 {
4959 title : 'Security Engineer' ,
5060 icon : AiFillSecurityScan ,
5161 sources : [ 'freecodecamp' , 'github' , 'reddit' , 'devto' ] ,
52- tags : [ 'c++ ' , 'bash' , 'python' ] ,
62+ tags : [ 'security' , 'cpp ', 'bash' , 'python' ] ,
5363 } ,
5464 {
5565 title : 'ML Engineer' ,
5666 icon : FaRobot ,
5767 sources : [ 'github' , 'freecodecamp' , 'hackernews' , 'devto' ] ,
58- tags : [ 'machine- learning' , 'artificial- intelligence' , 'python' ] ,
68+ tags : [ 'machine learning' , 'artificial intelligence' , 'python' ] ,
5969 } ,
6070 {
6171 title : 'Other' ,
6272 icon : TbDots ,
6373 sources : [ 'hackernews' , 'github' , 'producthunt' , 'devto' ] ,
64- tags : [ ] ,
74+ tags : [ 'webdev' , 'mobile' ] ,
6575 } ,
6676]
6777
68- export const HelloTab = ( {
69- moveToNext,
70- moveToPrevious,
71- setTabsData,
72- tabsData,
73- } : StepProps < Occupation > ) => {
74- const [ selectedOccupation , setSelectedOccupation ] = useState < Occupation | undefined > (
75- tabsData || OCCUPATIONS [ 0 ]
76- )
77- const onOccupationClicked = ( occupation : Occupation ) => {
78- setSelectedOccupation ( occupation )
79- }
78+ export const HelloTab = ( ) => {
79+ const { markOnboardingAsCompleted, setCards, setTags, setOccupation, occupation } =
80+ useUserPreferences ( )
81+
82+ const { tags } = useRemoteConfigStore ( )
8083
81- const onClickNext = ( ) => {
82- if ( selectedOccupation === undefined ) {
83- return
84+ const onStartClicked = ( ) => {
85+ const selectedOccupation = OCCUPATIONS . find ( ( occ ) => occ . title === occupation )
86+ if ( selectedOccupation ) {
87+ setOccupation ( selectedOccupation . title )
88+ setCards (
89+ selectedOccupation . sources . map ( ( source , index ) => ( {
90+ id : index ,
91+ name : source ,
92+ type : 'supported' ,
93+ } ) )
94+ )
95+ const userTags = selectedOccupation . tags
96+ . map ( ( tag ) => {
97+ return tags . find ( ( t ) => t . value === tag )
98+ } )
99+ . filter ( Boolean ) as Array < Tag >
100+
101+ setTags ( userTags )
84102 }
85103
86- setTabsData ( selectedOccupation )
87- moveToNext && moveToNext ( )
104+ markOnboardingAsCompleted ( )
88105 }
106+
89107 return (
90108 < div >
91109 < div className = "tabHeader" >
92- < h1 className = "tabTitle" > Hi, 👋 Welcome to Hackertab</ h1 >
93- < p className = "tabBody" > Let's customize your Hackertab experience! </ p >
110+ < h1 className = "tabTitle" > 👋 Let’s set up your Hackertab</ h1 >
111+ < p className = "tabBody" > Select your developer role 👨🏻💻 to personalize your Hackertab. </ p >
94112 </ div >
95113 < div className = "occupations" >
96114 { OCCUPATIONS . map ( ( occ ) => {
97115 return (
98116 < button
99117 key = { occ . title }
100- onClick = { ( ) => onOccupationClicked ( occ ) }
101- className = { clsx ( 'occupation' , selectedOccupation ?. title === occ . title && 'active' ) } >
118+ onClick = { ( ) => setOccupation ( occ . title ) }
119+ className = { clsx ( 'occupation' , occupation === occ . title && 'active' ) } >
102120 < span >
103121 < occ . icon className = "occupationIcon" />
104122 </ span >
@@ -108,10 +126,11 @@ export const HelloTab = ({
108126 } ) }
109127 </ div >
110128 < div className = "tabFooter" >
111- < button onClick = { ( ) => moveToPrevious && moveToPrevious ( ) } > Skip</ button >
112- < button className = "positiveButton" onClick = { ( ) => onClickNext ( ) } >
113- < BsArrowRight /> Next
114- </ button >
129+ { occupation && (
130+ < button className = "positiveButton" onClick = { onStartClicked } >
131+ < BsArrowRight /> Start now
132+ </ button >
133+ ) }
115134 </ div >
116135 </ div >
117136 )
0 commit comments