Files
Compass/web/components/connection-preferences-settings.tsx
Okechi Jones-Williams d2c9d12b39 test(e2e): add auth, settings, social and organization page coverage
* Added Database checks to the onboarding flow

* Added compatibility page setup
Added more compatibility questions

* Finished up the onboarding flow suite
Added compatibility question tests and verifications
Updated tests to cover Keywords and Headline changes recently made
Updated tests to cover all of the big5 personality traits

* .

* Fix: Merge conflict

* .

* Fix: Added fix for None discriptive error issue #36
Updated signUp.spec.ts to use new fixture
Updated Account information variable names
Deleted "deleteUserFixture.ts" as it was incorporated into the "base.ts" file

* Linting and Prettier

* Minor cleaning

* Organizing helper func

* Added Google account to the Onboarding flow

* .

* Added account cleanup for google accounts

* Started work on Sign-in tests
Updated seedDatabase.ts to throw an error if the user already exists, to also add display names and usernames so they seedUser func acts like a normal basic user
Some organising of the google auth code

* Linting and Prettier

* Added checks to the deleteUser func to check if the accout exists
Added account deletion checks

* Linting and Prettier

* Added POM's for social and organisation page
Updated settings POM

* Formatting update, fixed homePage locator for signin

* .

* .

* .

* Coderabbitai fix's

* Fix

* Improve test utilities and stabilize onboarding flow tests

* Changes requested

* Seperated deletion tests from onboarding

* Update `.coderabbit.yaml` with improved internationalization guidance and formatting adjustments

* Clean up `.vscode/settings.json` and add it to `.gitignore`

* Add Playwright E2E test guidelines to `.coderabbit.yaml`

* Standardize and improve formatting in `TESTING.md` for better readability and consistency.

* Refactor onboarding flow tests and related utilities; improve formatting and remove redundant tests.

---------

Co-authored-by: MartinBraquet <martin.braquet@gmail.com>
2026-04-04 14:21:40 +02:00

101 lines
3.3 KiB
TypeScript

import {useState} from 'react'
import toast from 'react-hot-toast'
import {Col} from 'web/components/layout/col'
import {Row} from 'web/components/layout/row'
import {SwitchSetting} from 'web/components/switch-setting'
import {useProfile} from 'web/hooks/use-profile'
import {updateProfile} from 'web/lib/api'
import {useT} from 'web/lib/locale'
export function ConnectionPreferencesSettings() {
const t = useT()
const profile = useProfile()
const [allowDirectMessaging, setAllowDirectMessaging] = useState(
profile?.allow_direct_messaging !== false,
)
const [allowInterestIndicating, setAllowInterestIndicating] = useState(
profile?.allow_interest_indicating !== false,
)
const [isUpdating, setIsUpdating] = useState(false)
const handleUpdate = async (field: string, value: boolean) => {
setIsUpdating(true)
try {
await updateProfile({[field]: value})
// toast.success(t('settings.connection_preferences.updated', 'Preferences updated'))
} catch (error) {
console.error('Error updating preferences:', error)
toast.error(
t('settings.connection_preferences.update_failed', 'Failed to update preferences'),
)
} finally {
setIsUpdating(false)
}
}
const handleDirectMessagingChange = (checked: boolean) => {
setAllowDirectMessaging(checked)
handleUpdate('allow_direct_messaging', checked)
}
const handleInterestIndicatingChange = (checked: boolean) => {
setAllowInterestIndicating(checked)
handleUpdate('allow_interest_indicating', checked)
}
return (
<Col className="gap-4">
<div className="text-sm text-ink-500">
{t(
'settings.connection_preferences.description',
'Control how others can connect with you.',
)}
</div>
<Row className="items-center justify-between gap-4">
<div className="flex-1">
<div className="font-medium">
{t('settings.connection_preferences.direct_messaging', 'Direct Messaging')}
</div>
<div className="text-ink-500 text-sm">
{t(
'settings.connection_preferences.dm_description',
'Let anyone start a conversation with you immediately.',
)}
</div>
</div>
<SwitchSetting
testId="settings-direct-message-toggle"
checked={allowDirectMessaging}
onChange={handleDirectMessagingChange}
disabled={isUpdating}
colorMode={'primary'}
/>
</Row>
<Row className="items-center justify-between gap-4">
<div className="flex-1">
<div className="font-medium">
{t('settings.connection_preferences.interest_indicator', 'Private interest signals')}
</div>
<div className="text-ink-500 text-sm">
{t(
'settings.connection_preferences.indicator_description',
'Allow people to privately signal interest. You are only notified if the interest is mutual.',
)}
</div>
</div>
<SwitchSetting
testId="settings-private-interest-signal-toggle"
checked={allowInterestIndicating}
onChange={handleInterestIndicatingChange}
disabled={isUpdating}
colorMode={'primary'}
/>
</Row>
</Col>
)
}