Improve colors buttons connect-actions.tsx

This commit is contained in:
MartinBraquet
2026-02-24 18:31:10 +01:00
parent 2b31ed3164
commit 1dbe4ecdef
6 changed files with 35 additions and 12 deletions

View File

@@ -58,7 +58,7 @@ import {deleteBookmarkedSearch} from './delete-bookmarked-search'
import {deleteCompatibilityAnswer} from './delete-compatibility-answer'
import {deleteMe} from './delete-me'
import {getCompatibilityQuestions} from './get-compatibililty-questions'
import {getConnectionInterests} from './get-connection-interests'
import {getConnectionInterestsEndpoint} from './get-connection-interests'
import {getCurrentPrivateUser} from './get-current-private-user'
import {getEvents} from './get-events'
import {getLikesAndShips} from './get-likes-and-ships'
@@ -377,7 +377,7 @@ const handlers: {[k in APIPath]: APIHandler<k>} = {
'update-user-locale': updateUserLocale,
'update-private-user-message-channel': updatePrivateUserMessageChannel,
'update-profile': updateProfile,
'get-connection-interests': getConnectionInterests,
'get-connection-interests': getConnectionInterestsEndpoint,
'update-connection-interest': updateConnectionInterests,
'user/by-id/:id': getUser,
'user/by-id/:id/block': blockUser,

View File

@@ -1,8 +1,10 @@
import {getConnectionInterests} from 'api/get-connection-interests'
import {APIError, APIHandler} from 'api/helpers/endpoint'
import {addUsersToPrivateMessageChannel} from 'api/helpers/private-messages'
import {filterDefined} from 'common/util/array'
import * as admin from 'firebase-admin'
import {uniq} from 'lodash'
import {getProfile} from 'shared/profiles/supabase'
import {createSupabaseDirectClient} from 'shared/supabase/init'
import {getPrivateUser, getUser} from 'shared/utils'
@@ -39,7 +41,21 @@ export const createPrivateUserMessageChannel: APIHandler<
user.blockedUserIds.some((blockedId: string) => userIds.includes(blockedId)),
)
) {
throw new APIError(403, 'One of the users has blocked another user in the list')
throw new APIError(403, `One of the users has blocked another user in the list`)
}
for (const u of toPrivateUsers) {
const p = await getProfile(u.id)
if (p && !p.allow_direct_messaging) {
const {interests, targetInterests} = await getConnectionInterests(
{targetUserId: u.id},
auth.uid,
)
const matches = interests.filter((interest: string[]) => targetInterests.includes(interest))
if (matches.length > 0) continue
const failedUser = await getUser(u.id)
throw new APIError(403, `${failedUser?.username} has disabled direct messaging`)
}
}
const currentChannel = await pg.oneOrNone(

View File

@@ -1,12 +1,15 @@
import {APIHandler} from 'api/helpers/endpoint'
import {createSupabaseDirectClient} from 'shared/supabase/init'
export const getConnectionInterests: APIHandler<'get-connection-interests'> = async (
export const getConnectionInterestsEndpoint: APIHandler<'get-connection-interests'> = async (
props,
auth,
) => {
return getConnectionInterests(props, auth.uid)
}
export const getConnectionInterests = async (props: any, userId: string) => {
const {targetUserId} = props
const userId = auth.uid
if (!targetUserId) {
throw new Error('Missing target user ID')

View File

@@ -1,6 +1,7 @@
import {PlusIcon} from '@heroicons/react/solid'
import clsx from 'clsx'
import {DisplayUser} from 'common/api/user-types'
import {APIError} from 'common/api/utils'
import {buildArray} from 'common/util/array'
import {useRouter} from 'next/router'
import {useState} from 'react'
@@ -33,13 +34,15 @@ function MessageModal(props: {open: boolean; setOpen: (open: boolean) => void})
const privateUser = usePrivateUser()
const router = useRouter()
const t = useT()
const [errorText, setErrorText] = useState<string>('')
const [users, setUsers] = useState<DisplayUser[]>([])
const createChannel = async () => {
const res = await api('create-private-user-message-channel', {
userIds: users.map((user) => user.id),
}).catch((e) => {
}).catch((e: APIError) => {
console.error(e)
setErrorText(String(e))
return
})
if (!res) {
@@ -61,6 +64,7 @@ function MessageModal(props: {open: boolean; setOpen: (open: boolean) => void})
.concat(buildArray(privateUser?.id))}
/>
</Col>
{errorText && <p className={'bg-canvas-0 text-red-500 px-5'}>{errorText}</p>}
<Row className={'bg-canvas-0 justify-end rounded-b-md p-2'}>
<Button disabled={users.length === 0} onClick={createChannel}>
{t('messages.create', 'Create')}

View File

@@ -154,12 +154,12 @@ export function ConnectActions(props: {profile: Profile; user: User}) {
border
${
isMutual
? 'bg-primary-500 text-white border-primary-500'
? 'bg-primary-200 border-primary-500'
: isSelected
? 'bg-primary-100 text-primary-800 border-primary-300'
: 'bg-canvas-50 text-ink-700 border-ink-300 hover:border-primary-400'
? 'bg-primary-100 border-primary-300'
: 'bg-canvas-50 text-ink-700 border-ink-300'
}
${isDisabled ? 'opacity-40 cursor-not-allowed' : ''}
${isDisabled ? 'opacity-30 cursor-not-allowed' : 'hover:border-primary-400'}
`}
>
{t(`profile.relationship.${type}`, label)}

View File

@@ -252,8 +252,8 @@
--color-primary-500: 59 130 246; /* standard blue */
--color-primary-400: 37 99 235;
--color-primary-300: 29 78 216;
--color-primary-200: 30 64 175;
--color-primary-100: 30 58 138;
--color-primary-200: 60 60 60;
--color-primary-100: 30 30 30;
--color-primary-50: 23 37 84; /* very dark navy */
--color-no-950: 255 255 255; /* white */