Skip to content
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

Add seniority setting #7184

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions app/css/pages/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@
@apply leading-150 text-textColor6;
}
}

.seniority {
.c-single-select {
.c-results-zone button,
button {
@apply shadow-sm;
}
}
}
& .pronouns-section {
& .instructions {
@apply mb-24;
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/react_components/settings/profile_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def to_s
user: {
name: current_user.name,
location: current_user.location,
bio: current_user.bio
bio: current_user.bio,
seniority: current_user.seniority
},
profile:,
links: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ErrorFallback } from '@/components/common/ErrorFallback'

const DEFAULT_ERROR = new Error('Unable to save seniority level.')

const SENIORITIES: { label: string; value: SeniorityLevel }[] = [
export const SENIORITIES: { label: string; value: SeniorityLevel }[] = [
{
label: 'Absolute Beginner',
value: 'absolute_beginner',
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/components/settings/EmailForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ export default function EmailForm({
/>
</div>
<div className="field">
<label htmlFor="user_sudo_password" className="label">
<label htmlFor="user_sudo_password_email" className="label">
Confirm your password
</label>
<input
type="password"
id="user_sudo_password"
id="user_sudo_password_email"
value={state.password}
onChange={(e) => setState({ ...state, password: e.target.value })}
required
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/components/settings/HandleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ export default function HandleForm({
/>
</div>
<div className="field">
<label htmlFor="user_sudo_password" className="label">
<label htmlFor="user_sudo_password_handle" className="label">
Confirm your password
</label>
<input
type="password"
id="user_sudo_password"
id="user_sudo_password_handle"
value={state.password}
onChange={(e) => setState({ ...state, password: e.target.value })}
required
Expand Down
48 changes: 48 additions & 0 deletions app/javascript/components/settings/ProfileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import { FormMessage } from './FormMessage'
import { FauxInputWithValidation } from './inputs/FauxInputWithValidation'
import { InputWithValidation } from './inputs/InputWithValidation'
import { createMaxLengthAttributes } from './useInvalidField'
import { SeniorityLevel } from '../modals/welcome-modal/WelcomeModal'
import { SingleSelect } from '../common/SingleSelect'

type User = {
name: string
location: string
bio: string
seniority: SeniorityLevel
}

type Profile = {
Expand Down Expand Up @@ -97,6 +100,17 @@ export default function ProfileForm({
Tell the world about you 🌎. Emojis encouraged!
</div>
</div>

<div className="seniority field">
<label htmlFor="user_seniority" className="label">
Seniority
</label>
<SenioritySelect
value={user.seniority}
setValue={(value) => setUser({ ...user, seniority: value })}
/>
</div>

{profile ? (
<div className="pt-20 mt-24 border-t-1 border-borderColor6">
<h2>Your social accounts</h2>
Expand Down Expand Up @@ -168,3 +182,37 @@ const SuccessMessage = () => {
</div>
)
}

function OptionComponent({ option }: { option: SeniorityLevel }): JSX.Element {
switch (option) {
case 'absolute_beginner':
return <div>Absolute Beginner</div>
case 'beginner':
return <div>Beginner</div>
case 'junior':
return <div>Junior Developer</div>
case 'mid':
return <div>Mid-level Developer</div>
case 'senior':
return <div>Senior Developer</div>
}
}

function SenioritySelect({
value,
setValue,
}: {
value: SeniorityLevel
setValue: (value: SeniorityLevel) => void
}): JSX.Element {
return (
<SingleSelect<SeniorityLevel>
className="w-[250px]"
options={['absolute_beginner', 'beginner', 'junior', 'mid', 'senior']}
value={value}
setValue={setValue}
SelectedComponent={OptionComponent}
OptionComponent={OptionComponent}
/>
)
}
Loading