-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CPF-144] Project scope - select bucket (#151)
* feat: fetch data for select bucket - project scope step * feat: select bucket - project scope step * feat: fix profile notification checkboxes
- Loading branch information
Showing
31 changed files
with
407 additions
and
98 deletions.
There are no files selected for viewing
82 changes: 80 additions & 2 deletions
82
frontend/src/app/(app)/(addProject)/my-space/add-new/project-scope/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,81 @@ | ||
export default function Score() { | ||
return <div>Project Scope Page</div>; | ||
import { ProjectScope } from '@app/components/pages/mySpace/addProject/ProjectScope'; | ||
import { BandWithBuckets } from '@app/types/library'; | ||
import { UserLadder } from '@app/types/user'; | ||
import { mapKeysToCamelCase } from '@app/utils'; | ||
import { createClient } from '@app/utils/supabase/server'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default async function Score() { | ||
const supabase = createClient(); | ||
const { | ||
data: { user }, | ||
error, | ||
} = await supabase.auth.getUser(); | ||
|
||
if (error || !user) { | ||
redirect('/auth'); | ||
} | ||
|
||
const { data: ladders } = await supabase | ||
.from('user_ladder') | ||
.select( | ||
` | ||
ladder( | ||
ladder_slug | ||
), | ||
is_main_ladder | ||
`, | ||
) | ||
.eq('user_id', user.id); | ||
|
||
const laddersData = mapKeysToCamelCase<UserLadder[]>(ladders); | ||
|
||
if (!laddersData) { | ||
return <div>No ladders assigned to a user</div>; | ||
} | ||
|
||
const mainLadder = laddersData?.length > 1 ? laddersData.find((ladder) => ladder.isMainLadder) : laddersData[0]; | ||
|
||
const { data: bands } = await supabase | ||
.from('band') | ||
.select( | ||
` | ||
band_id, | ||
ladder_slug, | ||
threshold, | ||
salary_range, | ||
band_number, | ||
buckets:bucket( | ||
bucket_slug, | ||
bucket_name, | ||
description, | ||
bucket_type, | ||
advancement_levels:advancement_level( | ||
advancement_level, | ||
description, | ||
bucket_slug, | ||
skills:atomic_skill( | ||
skill_id, | ||
name, | ||
description, | ||
category | ||
), | ||
projects:example_project( | ||
project_id, | ||
level_id, | ||
title, | ||
overview | ||
) | ||
) | ||
), | ||
ladder:ladder_slug( | ||
ladder_name | ||
) | ||
`, | ||
) | ||
.eq('ladder_slug', mainLadder?.ladder?.ladderSlug); | ||
|
||
const bandsData = mapKeysToCamelCase<BandWithBuckets[]>(bands); | ||
|
||
return <ProjectScope bands={bandsData} />; | ||
} |
4 changes: 4 additions & 0 deletions
4
frontend/src/components/common/AccordionCard/AccordionCard.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { AtomicSkill } from '@app/types/library'; | ||
|
||
export interface AccordionCardProps extends React.HTMLAttributes<HTMLDivElement> { | ||
title: string; | ||
expandedByDefault?: boolean; | ||
small?: boolean; | ||
checkboxName?: string; | ||
handleSelectAll?: (name: string, selected: boolean, skills?: AtomicSkill[]) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
frontend/src/components/common/AccordionList/AccordionList.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 12 additions & 11 deletions
23
frontend/src/components/common/AccordionList/AccordionList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import { AccordionListProps } from './AccordionList.interface'; | ||
import { AccordionListItem } from './AccordionListItem'; | ||
import { Checkbox } from '../Checkbox'; | ||
|
||
export const AccordionList = ({ items }: PropsWithChildren<AccordionListProps>) => { | ||
export const AccordionList = ({ items, checkboxName }: PropsWithChildren<AccordionListProps>) => { | ||
return ( | ||
<div className="flex flex-col"> | ||
{items.map(({ title, children, key, icon }) => ( | ||
<AccordionListItem | ||
key={key} | ||
title={title} | ||
noContentTooltipText="There's no description for this skill." | ||
icon={icon} | ||
> | ||
{children} | ||
</AccordionListItem> | ||
))} | ||
{items.map(({ title, children, key, icon }) => { | ||
return ( | ||
<div key={key} className="flex items-center"> | ||
{checkboxName && <Checkbox name={`${checkboxName}.${key}`} id={key.toString()} />} | ||
<AccordionListItem title={title} noContentTooltipText="There's no description for this skill." icon={icon}> | ||
{children} | ||
</AccordionListItem> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
frontend/src/components/common/Checkbox/Checkbox.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface CheckboxProps { | ||
name: string; | ||
id?: string; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
defaultChecked?: boolean; | ||
handleChange?: (name: string, selected: boolean) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 16 additions & 9 deletions
25
frontend/src/components/common/Combobox/Combobox.hooks.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import { useMemo, useState } from 'react'; | ||
import { ComboboxProps } from './Combobox.interface'; | ||
|
||
export const useCombobox = (options: ComboboxProps['options'], selectedOptions: ComboboxProps['selectedOptions']) => { | ||
export const useCombobox = ( | ||
options: ComboboxProps['options'], | ||
selectedOptions: ComboboxProps['selectedOptions'], | ||
sort: ComboboxProps['sort'], | ||
) => { | ||
const [query, setQuery] = useState(''); | ||
|
||
const uniqOptions = | ||
Array.isArray(selectedOptions) && selectedOptions.length > 0 | ||
? options.filter((option) => !selectedOptions?.find((selectedOption) => selectedOption?.id === option.id)) | ||
: options; | ||
|
||
const filteredOptions = useMemo( | ||
() => | ||
uniqOptions | ||
.sort((a, b) => a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase())) | ||
.filter((option) => option.name.toLowerCase().includes(query.toLowerCase())), | ||
[uniqOptions, query], | ||
); | ||
const filteredOptions = useMemo(() => { | ||
if (uniqOptions) { | ||
const filtered = uniqOptions.filter((option) => option.name.toLowerCase().includes(query.toLowerCase())); | ||
if (sort) { | ||
return filtered.sort((a, b) => a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase())); | ||
} | ||
return filtered; | ||
} | ||
return uniqOptions; | ||
}, [uniqOptions, sort, query]); | ||
|
||
return { filteredOptions, setQuery }; | ||
return { filteredOptions: filteredOptions, setQuery }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.