Skip to content

Commit

Permalink
fix: show defaults not suggestions (#17584)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Sep 22, 2023
1 parent a5f41a9 commit 0427aee
Showing 1 changed file with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LemonButton, LemonSnack } from '@posthog/lemon-ui'
import { LemonButton } from '@posthog/lemon-ui'
import { useActions, useValues } from 'kea'
import { PersonPropertySelect } from 'lib/components/PersonPropertySelect/PersonPropertySelect'
import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
Expand All @@ -10,19 +10,16 @@ export function PersonDisplayNameProperties(): JSX.Element {
const { currentTeam } = useValues(teamLogic)
const { updateCurrentTeam } = useActions(teamLogic)
const [value, setValue] = useState([] as string[])
const [suggestions, setSuggestions] = useState([] as string[])

useEffect(() => {
setValue(currentTeam?.person_display_name_properties || [])
setSuggestions(PERSON_DEFAULT_DISPLAY_NAME_PROPERTIES)
}, [currentTeam])
useEffect(
() => setValue(currentTeam?.person_display_name_properties || PERSON_DEFAULT_DISPLAY_NAME_PROPERTIES),
[currentTeam]
)

if (!currentTeam) {
return <LemonSkeleton className="w-1/2" />
}

const activeSuggestions = suggestions.filter((s) => !value.includes(s))

return (
<>
<p>
Expand All @@ -36,16 +33,6 @@ export function PersonDisplayNameProperties(): JSX.Element {
addText="Add"
sortable
/>
<div>
<h4>Suggestions</h4>
<div className="space-x-1">
{activeSuggestions.map((suggestion) => (
<LemonSnack key={suggestion} onClick={() => setValue([...value, suggestion])}>
{suggestion}
</LemonSnack>
))}
</div>
</div>
<LemonButton
type="primary"
onClick={() =>
Expand Down

0 comments on commit 0427aee

Please sign in to comment.