Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(condo): DOMA-10739 get contact from ssr #5534

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/callcenter
16 changes: 8 additions & 8 deletions apps/condo/pages/contact/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import get from 'lodash/get'
import Head from 'next/head'
import Link from 'next/link'
import { useRouter } from 'next/router'
import React, { CSSProperties, useCallback } from 'react'
import React, { CSSProperties, useCallback, useMemo } from 'react'

import { useCachePersistor } from '@open-condo/apollo'
import { getClientSideSenderInfo } from '@open-condo/codegen/utils/userId'
Expand Down Expand Up @@ -211,14 +211,15 @@ export const ContactPageContent = ({ contact, isContactEditable, softDeleteActio
)
}

const ContactInfoPage: PageComponentType<{ id: string }> = ({ id: contactId }) => {
const ContactInfoPage: PageComponentType = () => {
const intl = useIntl()
const ErrorMessage = intl.formatMessage({ id: 'errors.LoadingError' })
const LoadingMessage = intl.formatMessage({ id: 'Loading' })
const ContactNotFoundTitle = intl.formatMessage({ id: 'Contact.NotFound.Title' })
const ContactNotFoundMessage = intl.formatMessage({ id: 'Contact.NotFound.Message' })

const { push } = useRouter()
const { push, query } = useRouter()
const { id: contactId } = query as { id: string }
const { role } = useOrganization()
const { persistor } = useCachePersistor()

Expand All @@ -232,6 +233,7 @@ const ContactInfoPage: PageComponentType<{ id: string }> = ({ id: contactId }) =
})
const filteredContacts = data?.contacts?.filter(Boolean)
const contact = Array.isArray(filteredContacts) && filteredContacts.length > 0 ? filteredContacts[0] : null
const contactLoading = useMemo(() => loading || !persistor, [loading, persistor])

const [updateContactMutation] = useUpdateContactMutation({
variables: {
Expand All @@ -249,8 +251,8 @@ const ContactInfoPage: PageComponentType<{ id: string }> = ({ id: contactId }) =
await push('/contact')
}, [push, updateContactMutation])

if (error || loading) {
return <LoadingOrErrorPage title={LoadingMessage} loading={loading} error={error ? ErrorMessage : null}/>
if (error || contactLoading) {
return <LoadingOrErrorPage title={LoadingMessage} loading={contactLoading} error={error ? ErrorMessage : null}/>
}
if (!contact) {
return <LoadingOrErrorPage title={ContactNotFoundTitle} loading={false} error={ContactNotFoundMessage}/>
Expand All @@ -276,9 +278,7 @@ ContactInfoPage.getPrefetchedData = async ({ context, apolloClient }) => {
await prefetchContact({ client: apolloClient, contactId })

return {
props: {
id: contactId,
},
props: {},
}
}

Expand Down
9 changes: 5 additions & 4 deletions apps/condo/pages/ticket/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import isEmpty from 'lodash/isEmpty'
import map from 'lodash/map'
import Head from 'next/head'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { CSSProperties, useCallback, useEffect, useMemo, useState } from 'react'

import { useCachePersistor } from '@open-condo/apollo'
Expand Down Expand Up @@ -797,12 +798,14 @@ export const TicketPageContent = ({ ticket, pollCommentsQuery, refetchTicket, or
)
}

const TicketIdPage: PageComponentType<{ id: string }> = ({ id }) => {
const TicketIdPage: PageComponentType = () => {
const intl = useIntl()
const ServerErrorMessage = intl.formatMessage({ id: 'ServerError' })

const { user } = useAuth()
const { link, organization, selectEmployee } = useOrganization()
const { query } = useRouter()
const { id } = query as { id: string }

const { persistor } = useCachePersistor()

Expand Down Expand Up @@ -898,9 +901,7 @@ TicketIdPage.getPrefetchedData = async ({ context, apolloClient }) => {
await prefetchTicket({ client: apolloClient, ticketId })

return {
props: {
id: ticketId,
},
props: {},
}
}

Expand Down
11 changes: 7 additions & 4 deletions apps/condo/pages/ticket/[id]/update.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Typography, Row, Col } from 'antd'
import Head from 'next/head'
import { useRouter } from 'next/router'
import React from 'react'

import { useIntl } from '@open-condo/next/intl'
Expand All @@ -11,10 +12,14 @@ import { TicketForm } from '@condo/domains/ticket/components/TicketForm'
import { prefetchTicket } from '@condo/domains/ticket/utils/next/Ticket'


const TicketUpdatePage: PageComponentType<{ id: string }> = ({ id }) => {
const TicketUpdatePage: PageComponentType = () => {
const intl = useIntl()
const PageTitleMsg = intl.formatMessage({ id:'pages.condo.ticket.index.EditTicketModalTitle' })

const router = useRouter()
const { query } = router
const { id } = query as { id: string }

return (
<>
<Head>
Expand Down Expand Up @@ -43,9 +48,7 @@ TicketUpdatePage.getPrefetchedData = async ({ context, apolloClient }) => {
await prefetchTicket({ client: apolloClient, ticketId })

return {
props: {
id: ticketId,
},
props: {},
}
}

Expand Down
Loading