Skip to content

Commit

Permalink
date -> string for timestamp columns in CommunityAlerts
Browse files Browse the repository at this point in the history
  • Loading branch information
timolegros committed Sep 4, 2024
1 parent f4a1660 commit 7f4ada6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 10 additions & 0 deletions libs/model/src/models/community_alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions libs/schemas/src/entities/notification.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CommunityAlert } from '@hicommonwealth/schemas';
import 'components/sidebar/CommunitySection/CommunitySection.scss';
import { findDenominationString } from 'helpers/findDenomination';
import React from 'react';
Expand All @@ -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';
Expand Down Expand Up @@ -59,11 +57,9 @@ export const CommunitySection = ({ showSkeleton }: CommunitySectionProps) => {
const topicIdsIncludedInContest =
getUniqueTopicIdsIncludedInActiveContest(contestsData);

const communityAlerts:
| ReadonlyArray<z.infer<typeof CommunityAlert>>
| undefined = useCommunityAlertsQuery({
const communityAlerts = useCommunityAlertsQuery({
enabled: user.isLoggedIn && !!app.chain,
}).data as unknown as ReadonlyArray<z.infer<typeof CommunityAlert>>;
}).data;

if (showSkeleton || isLoading || isContestDataLoading)
return <CommunitySectionSkeleton />;
Expand Down

0 comments on commit 7f4ada6

Please sign in to comment.