mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-26 09:30:09 -04:00
Add an option to disable your profile
This commit is contained in:
@@ -118,6 +118,7 @@ export const loadProfiles = async (props: profileQueryType) => {
|
||||
(has_kids == 0 && !l.has_kids) ||
|
||||
(l.has_kids && l.has_kids > 0)) &&
|
||||
(is_smoker === undefined || l.is_smoker === is_smoker) &&
|
||||
(!l.disabled) &&
|
||||
(l.id.toString() != skipId) &&
|
||||
(!geodbCityIds ||
|
||||
(l.geodb_city_id && geodbCityIds.includes(l.geodb_city_id))) &&
|
||||
@@ -149,6 +150,7 @@ export const loadProfiles = async (props: profileQueryType) => {
|
||||
join('users on users.id = profiles.user_id'),
|
||||
leftJoin(userActivityJoin),
|
||||
where('looking_for_matches = true'),
|
||||
where(`profiles.disabled != true`),
|
||||
// where(`pinned_url is not null and pinned_url != ''`),
|
||||
where(
|
||||
`(data->>'isBannedFromPosting' != 'true' or data->>'isBannedFromPosting' is null)`
|
||||
|
||||
@@ -39,6 +39,7 @@ export const sinclairProfile: ProfileRow = {
|
||||
religion: [],
|
||||
pref_relation_styles: ['friendship'],
|
||||
pref_romantic_styles: ['poly', 'open', 'mono'],
|
||||
disabled: false,
|
||||
wants_kids_strength: 3,
|
||||
looking_for_matches: true,
|
||||
visibility: 'public',
|
||||
@@ -137,6 +138,7 @@ export const jamesProfile: ProfileRow = {
|
||||
city: 'San Francisco',
|
||||
gender: 'male',
|
||||
pref_gender: ['female'],
|
||||
disabled: false,
|
||||
pref_age_min: 22,
|
||||
pref_age_max: 32,
|
||||
religion: [],
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'profile_visibility') THEN
|
||||
@@ -53,6 +52,7 @@ CREATE TABLE IF NOT EXISTS profiles (
|
||||
visibility profile_visibility DEFAULT 'member'::profile_visibility NOT NULL,
|
||||
wants_kids_strength INTEGER DEFAULT 0 NOT NULL,
|
||||
website TEXT,
|
||||
disabled BOOLEAN DEFAULT FALSE NOT NULL,
|
||||
CONSTRAINT profiles_pkey PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
@@ -82,9 +82,10 @@ const optionalProfilesSchema = z.object({
|
||||
ethnicity: z.array(z.string()).optional(),
|
||||
born_in_location: z.string().optional(),
|
||||
height_in_inches: z.number().optional(),
|
||||
has_pets: zBoolean.optional().optional(),
|
||||
has_pets: zBoolean.optional(),
|
||||
education_level: z.string().optional(),
|
||||
is_smoker: zBoolean.optional().optional(),
|
||||
is_smoker: zBoolean.optional(),
|
||||
disabled: zBoolean.optional(),
|
||||
drinks_per_month: z.number().min(0).optional(),
|
||||
diet: z.array(z.string()).optional(),
|
||||
has_kids: z.number().min(0).optional(),
|
||||
@@ -92,7 +93,7 @@ const optionalProfilesSchema = z.object({
|
||||
occupation_title: z.string().optional(),
|
||||
occupation: z.string().optional(),
|
||||
company: z.string().optional(),
|
||||
comments_enabled: zBoolean.optional().optional(),
|
||||
comments_enabled: zBoolean.optional(),
|
||||
website: z.string().optional(),
|
||||
bio: contentSchema.optional().nullable(),
|
||||
twitter: z.string().optional(),
|
||||
|
||||
@@ -541,6 +541,7 @@ export type Database = {
|
||||
country: string | null
|
||||
created_time: string
|
||||
diet: string[] | null
|
||||
disabled: boolean
|
||||
drinks_per_month: number | null
|
||||
education_level: string | null
|
||||
ethnicity: string[] | null
|
||||
@@ -591,6 +592,7 @@ export type Database = {
|
||||
country?: string | null
|
||||
created_time?: string
|
||||
diet?: string[] | null
|
||||
disabled?: boolean
|
||||
drinks_per_month?: number | null
|
||||
education_level?: string | null
|
||||
ethnicity?: string[] | null
|
||||
@@ -641,6 +643,7 @@ export type Database = {
|
||||
country?: string | null
|
||||
created_time?: string
|
||||
diet?: string[] | null
|
||||
disabled?: boolean
|
||||
drinks_per_month?: number | null
|
||||
education_level?: string | null
|
||||
ethnicity?: string[] | null
|
||||
|
||||
@@ -23,6 +23,7 @@ import {VisibilityConfirmationModal} from './visibility-confirmation-modal'
|
||||
import {deleteAccount} from "web/lib/util/delete";
|
||||
import toast from "react-hot-toast";
|
||||
import {StarButton} from "web/components/widgets/star-button";
|
||||
import {disableProfile} from "web/lib/util/disable";
|
||||
|
||||
export default function ProfileHeader(props: {
|
||||
user: User
|
||||
@@ -47,12 +48,14 @@ export default function ProfileHeader(props: {
|
||||
const currentUser = useUser()
|
||||
const isCurrentUser = currentUser?.id === user.id
|
||||
const [showVisibilityModal, setShowVisibilityModal] = useState(false)
|
||||
const disabled = profile.disabled
|
||||
|
||||
console.debug('ProfileProfileHeader', {user, profile, userActivity, currentUser})
|
||||
|
||||
return (
|
||||
<Col className="w-full">
|
||||
<Row className={clsx('flex-wrap justify-between gap-2 py-1')}>
|
||||
{currentUser && isCurrentUser && disabled && <div className="text-red-500">You disabled your profile, so no one else can access it.</div>}
|
||||
<Row className="items-center gap-1">
|
||||
<Col className="gap-1">
|
||||
<Row className="items-center gap-1 text-xl">
|
||||
@@ -135,6 +138,33 @@ export default function ProfileHeader(props: {
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: disabled ? 'Enable profile' : 'Disable profile',
|
||||
icon: null,
|
||||
onClick: async () => {
|
||||
const confirmed = true // confirm(
|
||||
// 'Are you sure you want to disable your profile? This will hide your profile from searches and listings..'
|
||||
// )
|
||||
if (confirmed) {
|
||||
toast
|
||||
.promise(disableProfile(!disabled), {
|
||||
loading: disabled ? 'Enabling profile...' : 'Disabling profile...',
|
||||
success: () => {
|
||||
return `Profile ${disabled ? 'enabled' : 'disabled'}`
|
||||
},
|
||||
error: () => {
|
||||
return `Failed to ${disabled ? 'enable' : 'disable'} profile`
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
refreshProfile()
|
||||
})
|
||||
.catch(() => {
|
||||
// return false
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Row>
|
||||
|
||||
7
web/lib/util/disable.ts
Normal file
7
web/lib/util/disable.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import {track} from "web/lib/service/analytics";
|
||||
import {updateProfile} from "web/lib/api";
|
||||
|
||||
export async function disableProfile(disabled: boolean) {
|
||||
track(`disable profile ${disabled ? 'on' : 'off'}`)
|
||||
await updateProfile({disabled: disabled})
|
||||
}
|
||||
@@ -158,19 +158,32 @@ function UserPageInner(props: ActiveUserPageProps) {
|
||||
const fromSignup = query.fromSignup === 'true'
|
||||
|
||||
const currentUser = useUser()
|
||||
// const isCurrentUser = currentUser?.id === user?.id
|
||||
const isCurrentUser = currentUser?.id === user?.id
|
||||
|
||||
useSaveReferral(currentUser, {defaultReferrerUsername: username})
|
||||
useTracking('viewprofile', {username: user?.username})
|
||||
useTracking('view profile', {username: user?.username})
|
||||
|
||||
const [staticProfile] = useState(
|
||||
props.profile && user ? {...props.profile, user: user} : null
|
||||
)
|
||||
const {profile: clientProfile, refreshProfile} = useProfileByUser(user)
|
||||
// Show previous profile while loading another one
|
||||
// Show the previous profile while loading another one
|
||||
const profile = clientProfile ?? staticProfile
|
||||
// console.debug('profile:', user?.username, profile, clientProfile, staticProfile)
|
||||
|
||||
if (!isCurrentUser && profile?.disabled) {
|
||||
return <PageBase
|
||||
trackPageView={'user page'}
|
||||
className={'relative p-2 sm:pt-0'}
|
||||
>
|
||||
<Col className="items-center justify-center h-full">
|
||||
<div className="text-xl font-semibold text-center mt-8">
|
||||
The user disabled their profile.
|
||||
</div>
|
||||
</Col>
|
||||
</PageBase>
|
||||
}
|
||||
|
||||
return (
|
||||
<PageBase
|
||||
trackPageView={'user page'}
|
||||
|
||||
Reference in New Issue
Block a user