Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #273 from habralab/feat/notifications-client
Browse files Browse the repository at this point in the history
feat/notifications-client
  • Loading branch information
TorinAsakura committed Nov 30, 2023
2 parents 88559a8 + c44b526 commit 618cbd3
Show file tree
Hide file tree
Showing 60 changed files with 1,249 additions and 371 deletions.
696 changes: 358 additions & 338 deletions .pnp.cjs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions common/client/entrypoints/renderer/locales/ru.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"header.exit_message": "Вы действительно хотите выйти?",
"header.exit": "Выйти",
"header.notifications.accept": "Принять",
"header.notifications.more_detailed": "Подробнее",
"header.notifications.no_notifications_yet": "Пока нет уведомлений",
"header.notifications.notifications": "Уведомления",
"header.notifications.reject": "Отклонить",
"header.notifications.watch_all": "Смотреть все",
"header.profile": "Профиль",
"header.projects": "Проекты",
"header.teams": "Команды",
Expand Down
7 changes: 6 additions & 1 deletion common/client/fragments/header-fragment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"dependencies": {
"@shared/data": "workspace:0.0.1",
"@shared/routes": "workspace:0.0.1",
"@shared/utils": "workspace:0.0.1",
"@ui/avatar": "workspace:0.0.1",
"@ui/background": "workspace:0.0.1",
"@ui/button": "workspace:0.0.1",
"@ui/condition": "workspace:0.0.1",
Expand All @@ -13,9 +15,11 @@
"@ui/link": "workspace:0.0.1",
"@ui/logo": "workspace:0.0.1",
"@ui/modal": "workspace:0.0.1",
"@ui/text": "workspace:0.0.1"
"@ui/text": "workspace:0.0.1",
"react-laag": "2.0.5"
},
"devDependencies": {
"@apollo/client": "3.8.7",
"@atls/next-identity-integration": "0.0.17",
"@emotion/react": "11.9.3",
"@emotion/styled": "11.9.3",
Expand All @@ -30,6 +34,7 @@
},
"peerDependencies": {
"@atls/next-identity-integration": "*",
"@emotion/css": "*",
"@emotion/react": "*",
"@emotion/styled": "*",
"@stores/session": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Button } from '@ui/button'
import { Condition } from '@ui/condition'
import { LogoutIcon } from '@ui/icon'
import { Layout } from '@ui/layout'
import { Box } from '@ui/layout'
import { Modal } from '@ui/modal'
import { Text } from '@ui/text'
import { useSession } from '@stores/session'
Expand All @@ -33,32 +32,29 @@ export const ButtonExit: FC = () => {
return (
<>
<Condition match={!isLogout}>
<Box fill justifyContent='flex-end'>
<Button variant='link' onClick={toggleModalOpen}>
<Text fontSize='medium' color='currentColor'>
<FormattedMessage id='header.exit' />
</Text>
<LogoutIcon width={24} height={24} color='currentColor' />
</Button>
<Modal
theme='exit'
open={modalOpen}
confirmText={formatMessage({ id: 'header.exit' })}
onConfirm={handleExit}
onCancel={toggleModalOpen}
onClose={toggleModalOpen}
>
<Text fontSize='semiMedium' fontWeight='bold' color='text.secondary'>
{fullName}
</Text>
<Layout flexBasis={4} flexShrink={0} />
<Text fontSize='semiMedium' color='text.secondary'>
<FormattedMessage id='header.exit_message' />
</Text>
<Layout flexBasis={40} />
</Modal>
<Layout flexBasis={24} flexShrink={0} />
</Box>
<Button variant='link' size='micro' onClick={toggleModalOpen}>
<Text fontSize='medium' color='currentColor'>
<FormattedMessage id='header.exit' />
</Text>
<LogoutIcon width={24} height={24} color='currentColor' />
</Button>
<Modal
theme='exit'
open={modalOpen}
confirmText={formatMessage({ id: 'header.exit' })}
onConfirm={handleExit}
onCancel={toggleModalOpen}
onClose={toggleModalOpen}
>
<Text fontSize='semiMedium' fontWeight='bold' color='text.secondary'>
{fullName}
</Text>
<Layout flexBasis={4} flexShrink={0} />
<Text fontSize='semiMedium' color='text.secondary'>
<FormattedMessage id='header.exit_message' />
</Text>
<Layout flexBasis={40} />
</Modal>
</Condition>
<Condition match={isLogout}>
<Layout />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// eslint-disable-next-line no-shadow
export enum NotificationTypes {
ProjectEditOwner = 'ProjectEditOwner',
TeamJoinProjectRequest = 'TeamJoinProjectRequest',
TeamJoinRequestDecide = 'TeamJoinRequestDecide',
TeamLeaveProject = 'TeamLeaveProject',
TeamEditOwner = 'TeamEditOwner',
TeamInvite = 'TeamInvite',
TeamInviteDecide = 'TeamInviteDecide',
TeamParticipantLeaveTeam = 'TeamParticipantLeaveTeam',
TeamUserJoinRequest = 'TeamUserJoinRequest',
TeamUserJoinRequestDecide = 'TeamUserJoinRequestDecide',
}

export interface QuotedEntity {
id?: string
avatarUrl?: string
quote?: string
}

export interface Notification {
id?: string
userId?: string
linkedEntityId?: string
title?: string
body?: string
type?: NotificationTypes
createdAt?: string
quotedEntities: QuotedEntity[]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { gql } from '@apollo/client'

export const DECIDE_PROJECT_TEAM_JOIN_REQUEST = gql`
mutation ProjectTeamJoinRequestDecide($id: String!, $approve: Boolean!) {
projectTeamJoinRequestDecide(input: { projectTeamJoinRequestId: $id, isApproved: $approve }) {
id
teamId
teamName
projectId
}
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './use-decide-project-team-join-request.hook'
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useMutation } from '@apollo/client'

import { JoinRequest } from '@shared/data'

import { DECIDE_PROJECT_TEAM_JOIN_REQUEST } from './decide-project-team-join-request.mutation'

export interface DecideProjectTeamJoinRequestResponse {
id?: string
teamId?: string
teamName?: string
projectId?: string
}

export interface DecideProjectTeamJoinRequestInput {
id: JoinRequest['id']
approve: boolean
}

export const useDecideProjectTeamJoinRequest = () => {
const [decideProjectTeamJoinRequest, { data, loading }] = useMutation<
DecideProjectTeamJoinRequestResponse,
DecideProjectTeamJoinRequestInput
>(DECIDE_PROJECT_TEAM_JOIN_REQUEST)

return { decideProjectTeamJoinRequest, data, loading }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { gql } from '@apollo/client'

export const DECIDE_TEAM_JOIN_REQUEST = gql`
mutation TeamUserJoinRequestDecide($id: String!, $approve: Boolean!) {
teamUserJoinRequestDecide(input: { userJoinRequestId: $id, isApproved: $approve }) {
teamUserJoinRequestPayload {
id
userId
teamId
}
}
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './use-decide-team-join-request.hook'
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useMutation } from '@apollo/client'

import { JoinRequest } from '@shared/data'

import { DECIDE_TEAM_JOIN_REQUEST } from './decide-team-join-request.mutation'

export interface DecideTeamJoinRequestResponse {
teamUserJoinRequestDecide: {
teamUserJoinRequestPayload: JoinRequest
}
}

export interface DecideTeamJoinRequestInput {
id: JoinRequest['id']
approve: boolean
}

export const useDecideTeamJoinRequest = () => {
const [decideTeamJoinRequest, { data, loading }] = useMutation<
DecideTeamJoinRequestResponse,
DecideTeamJoinRequestInput
>(DECIDE_TEAM_JOIN_REQUEST)

return { decideTeamJoinRequest, data, loading }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { gql } from '@apollo/client'

export const DECIDE_USER_TEAM_JOIN_INVITE = gql`
mutation TeamJoinInvitationDecide($id: String!, $approve: Boolean!) {
teamJoinInvitationDecide(input: { joinInvitationId: $id, isApproved: $approve }) {
teamJoinInvitePayload {
id
userId
teamId
}
}
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './use-decide-user-team-join-invite.hook'
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useMutation } from '@apollo/client'

import { JoinRequest } from '@shared/data'

import { DECIDE_USER_TEAM_JOIN_INVITE } from './decide-user-team-join-invite.mutation'

export interface DecideUserTeamJoinInviteResponse {
id?: string
userId?: string
teamId?: string
}

export interface DecideUserTeamJoinInviteInput {
id: JoinRequest['id']
approve: boolean
}

export const useDecideUserTeamJoinInvite = () => {
const [decideUserTeamJoinInvite, { data, loading }] = useMutation<
DecideUserTeamJoinInviteResponse,
DecideUserTeamJoinInviteInput
>(DECIDE_USER_TEAM_JOIN_INVITE)

return { decideUserTeamJoinInvite, data, loading }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { gql } from '@apollo/client'

export const DELETE_NOTIFICATION = gql`
mutation NotificationDelete($id: String!) {
notificationDelete(input: { notificationId: $id }) {
id
}
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './use-delete-notification.hook'
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useMutation } from '@apollo/client'

import { DELETE_NOTIFICATION } from './delete-notification.mutation'

export interface DeleteNotificationResponse {
id?: string
}

export interface DeleteNotificationInput {
id?: string
}

export const useDeleteNotification = () => {
const [deleteNotification, { data, loading }] = useMutation<
DeleteNotificationResponse,
DeleteNotificationInput
>(DELETE_NOTIFICATION)

return { deleteNotification, data, loading }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { gql } from '@apollo/client'

export const GET_NOTIFICATIONS = gql`
query NotificationGet {
notificationsGetListByCurrentUser {
notifications {
id
title
body
type
userId
createdAt
linkedEntityId
}
}
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './use-get-notifications.hook'
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useQuery } from '@apollo/client'

import { Notification } from '../data.interfaces'
import { GET_NOTIFICATIONS } from './get-notifications.query'

export interface GetNotificationsResponse {
notificationsGetListByCurrentUser: {
notifications?: Notification[]
}
}

export const useGetNotifications = () => {
const { data, refetch } = useQuery<GetNotificationsResponse>(GET_NOTIFICATIONS)

return {
notifications: data?.notificationsGetListByCurrentUser?.notifications || [],
refetch,
}
}
6 changes: 6 additions & 0 deletions common/client/fragments/header-fragment/src/data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './data.interfaces'
export * from './decide-project-team-join-request'
export * from './decide-team-join-request'
export * from './decide-user-team-join-invite'
export * from './delete-notification'
export * from './get-notifications'
Loading

0 comments on commit 618cbd3

Please sign in to comment.