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

Backmerge 1.45.3 #4478

Merged
merged 3 commits into from
Nov 5, 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "safe-wallet-web",
"homepage": "https://github.com/safe-global/safe-wallet-web",
"license": "GPL-3.0",
"version": "1.45.2",
"version": "1.45.3",
"type": "module",
"scripts": {
"dev": "next dev",
Expand Down
28 changes: 19 additions & 9 deletions src/features/targetedOutreach/components/OutreachPopup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useCreateSubmissionMutation, useGetSubmissionQuery } from '@/store/api/gateway'
import { skipToken } from '@reduxjs/toolkit/query'
import { useEffect, type ReactElement } from 'react'
import { Avatar, Box, Button, Chip, IconButton, Link, Paper, Stack, ThemeProvider, Typography } from '@mui/material'
import { Close } from '@mui/icons-material'
Expand All @@ -14,8 +16,6 @@ import SafeThemeProvider from '@/components/theme/SafeThemeProvider'
import useChainId from '@/hooks/useChainId'
import useSafeAddress from '@/hooks/useSafeAddress'
import useWallet from '@/hooks/wallets/useWallet'
import { createSubmission } from '@safe-global/safe-client-gateway-sdk'
import useSubmission from '@/features/targetedOutreach/hooks/useSubmission'

const OutreachPopup = (): ReactElement | null => {
const dispatch = useAppDispatch()
Expand All @@ -24,7 +24,17 @@ const OutreachPopup = (): ReactElement | null => {
const currentChainId = useChainId()
const safeAddress = useSafeAddress()
const wallet = useWallet()
const submission = useSubmission()
const [createSubmission] = useCreateSubmissionMutation()
const { data: submission } = useGetSubmissionQuery(
!wallet || !safeAddress
? skipToken
: {
outreachId: ACTIVE_OUTREACH.id,
chainId: currentChainId,
safeAddress,
signerAddress: wallet?.address,
},
)

const [askAgainLaterTimestamp, setAskAgainLaterTimestamp] = useSessionStorage<number>(OUTREACH_SS_KEY)

Expand Down Expand Up @@ -54,10 +64,10 @@ const OutreachPopup = (): ReactElement | null => {
const handleOpenSurvey = async () => {
if (wallet) {
await createSubmission({
params: {
path: { outreachId: ACTIVE_OUTREACH.id, chainId: currentChainId, safeAddress, signerAddress: wallet.address },
},
body: { completed: true },
outreachId: ACTIVE_OUTREACH.id,
chainId: currentChainId,
safeAddress,
signerAddress: wallet.address,
})
}
dispatch(closeOutreachBanner())
Expand All @@ -72,9 +82,9 @@ const OutreachPopup = (): ReactElement | null => {
<Paper className={css.container}>
<Stack gap={2}>
<Box display="flex">
<Avatar alt="Clem Bihorel" src="/images/common/outreach-popup-avatar.png" />
<Avatar alt="Clem, product lead" src="/images/common/outreach-popup-avatar.png" />
<Box ml={1}>
<Typography variant="body2">Clem Bihorel</Typography>
<Typography variant="body2">Clem</Typography>
<Typography variant="body2" color="primary.light">
Product Lead
</Typography>
Expand Down
2 changes: 1 addition & 1 deletion src/features/targetedOutreach/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ACTIVE_OUTREACH = { id: 1, url: 'https://wn2n6ocviur.typeform.com/to/J1OK3Ikf' }
export const ACTIVE_OUTREACH = { id: 1, url: 'https://app.opinionx.co/safe-power-user-survey/' }

export const OUTREACH_LS_KEY = 'outreachPopup'
export const OUTREACH_SS_KEY = 'outreachPopup_session'
Expand Down
27 changes: 0 additions & 27 deletions src/features/targetedOutreach/hooks/useSubmission.tsx

This file was deleted.

21 changes: 20 additions & 1 deletion src/store/api/gateway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { asError } from '@/services/exceptions/utils'
import { getDelegates } from '@safe-global/safe-gateway-typescript-sdk'
import type { DelegateResponse } from '@safe-global/safe-gateway-typescript-sdk/dist/types/delegates'
import { safeOverviewEndpoints } from './safeOverviews'
import { getSubmission } from '@safe-global/safe-client-gateway-sdk'
import { createSubmission, getSubmission } from '@safe-global/safe-client-gateway-sdk'

async function buildQueryFn<T>(fn: () => Promise<T>) {
try {
Expand All @@ -18,6 +18,7 @@ async function buildQueryFn<T>(fn: () => Promise<T>) {
export const gatewayApi = createApi({
reducerPath: 'gatewayApi',
baseQuery: fakeBaseQuery<Error>(),
tagTypes: ['Submissions'],
endpoints: (builder) => ({
getTransactionDetails: builder.query<TransactionDetails, { chainId: string; txId: string }>({
queryFn({ chainId, txId }) {
Expand All @@ -43,6 +44,23 @@ export const gatewayApi = createApi({
getSubmission({ params: { path: { outreachId, chainId, safeAddress, signerAddress } } }),
)
},
providesTags: ['Submissions'],
}),
createSubmission: builder.mutation<
createSubmission,
{ outreachId: number; chainId: string; safeAddress: string; signerAddress: string }
>({
queryFn({ outreachId, chainId, safeAddress, signerAddress }) {
return buildQueryFn(() =>
createSubmission({
params: {
path: { outreachId, chainId, safeAddress, signerAddress },
},
body: { completed: true },
}),
)
},
invalidatesTags: ['Submissions'],
}),
...safeOverviewEndpoints(builder),
}),
Expand All @@ -54,6 +72,7 @@ export const {
useLazyGetTransactionDetailsQuery,
useGetDelegatesQuery,
useGetSubmissionQuery,
useCreateSubmissionMutation,
useGetSafeOverviewQuery,
useGetMultipleSafeOverviewsQuery,
} = gatewayApi
2 changes: 1 addition & 1 deletion src/store/api/gateway/safeOverviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ type MultiOverviewQueryParams = {
safes: SafeItem[]
}

export const safeOverviewEndpoints = (builder: EndpointBuilder<any, never, 'gatewayApi'>) => ({
export const safeOverviewEndpoints = (builder: EndpointBuilder<any, 'Submissions', 'gatewayApi'>) => ({
getSafeOverview: builder.query<SafeOverview | null, { safeAddress: string; walletAddress?: string; chainId: string }>(
{
async queryFn({ safeAddress, walletAddress, chainId }, { getState }) {
Expand Down
Loading