diff --git a/libs/model/src/models/community_alerts.ts b/libs/model/src/models/community_alerts.ts index 4daeb3be204..dab5c9d8394 100644 --- a/libs/model/src/models/community_alerts.ts +++ b/libs/model/src/models/community_alerts.ts @@ -25,11 +25,21 @@ export default ( type: Sequelize.DATE, allowNull: false, defaultValue: sequelize.literal('CURRENT_TIMESTAMP'), + get() { + return (this.getDataValue( + 'created_at', + ) as unknown as Date)!.toISOString(); + }, }, updated_at: { type: Sequelize.DATE, allowNull: false, defaultValue: sequelize.literal('CURRENT_TIMESTAMP'), + get() { + return (this.getDataValue( + 'updated_at', + ) as unknown as Date)!.toISOString(); + }, }, }, { diff --git a/libs/schemas/src/entities/notification.schemas.ts b/libs/schemas/src/entities/notification.schemas.ts index 2d9acbde5da..6ad18a4f48c 100644 --- a/libs/schemas/src/entities/notification.schemas.ts +++ b/libs/schemas/src/entities/notification.schemas.ts @@ -120,8 +120,8 @@ export const CommunityAlert = z .object({ user_id: PG_INT, community_id: z.string(), - created_at: z.coerce.date().optional(), - updated_at: z.coerce.date().optional(), + created_at: z.string().optional(), + updated_at: z.string().optional(), }) .merge( z.object({ diff --git a/packages/commonwealth/client/scripts/views/components/sidebar/CommunitySection/CommunitySection.tsx b/packages/commonwealth/client/scripts/views/components/sidebar/CommunitySection/CommunitySection.tsx index e459099d932..704d3a0fa4e 100644 --- a/packages/commonwealth/client/scripts/views/components/sidebar/CommunitySection/CommunitySection.tsx +++ b/packages/commonwealth/client/scripts/views/components/sidebar/CommunitySection/CommunitySection.tsx @@ -1,4 +1,3 @@ -import { CommunityAlert } from '@hicommonwealth/schemas'; import 'components/sidebar/CommunitySection/CommunitySection.scss'; import { findDenominationString } from 'helpers/findDenomination'; import React from 'react'; @@ -16,7 +15,6 @@ import { getUniqueTopicIdsIncludedInActiveContest } from 'views/components/sideb import { SubscriptionButton } from 'views/components/subscription_button'; import ManageCommunityStakeModal from 'views/modals/ManageCommunityStakeModal/ManageCommunityStakeModal'; import useCommunityContests from 'views/pages/CommunityManagement/Contests/useCommunityContests'; -import { z } from 'zod'; import useManageCommunityStakeModalStore from '../../../../state/ui/modals/manageCommunityStakeModal'; import Permissions from '../../../../utils/Permissions'; import AccountConnectionIndicator from '../AccountConnectionIndicator'; @@ -59,11 +57,9 @@ export const CommunitySection = ({ showSkeleton }: CommunitySectionProps) => { const topicIdsIncludedInContest = getUniqueTopicIdsIncludedInActiveContest(contestsData); - const communityAlerts: - | ReadonlyArray> - | undefined = useCommunityAlertsQuery({ + const communityAlerts = useCommunityAlertsQuery({ enabled: user.isLoggedIn && !!app.chain, - }).data as unknown as ReadonlyArray>; + }).data; if (showSkeleton || isLoading || isContestDataLoading) return ;