[question][fix] fix startDate default value

pull/411/head
Jeff Sieu 3 years ago
parent 8aeb86ef00
commit abef3d4c85

@ -418,7 +418,8 @@ export default function QuestionsBrowsePage() {
{questions?.length === 0 && ( {questions?.length === 0 && (
<div className="flex w-full items-center justify-center gap-2 rounded-md border border-slate-300 bg-slate-200 p-4 text-slate-600"> <div className="flex w-full items-center justify-center gap-2 rounded-md border border-slate-300 bg-slate-200 p-4 text-slate-600">
<NoSymbolIcon className="h-6 w-6" /> <NoSymbolIcon className="h-6 w-6" />
<p>Nothing found. Try changing your search filters.</p> <p>Nothing found.</p>
{hasFilters && <p>Try changing your search criteria.</p>}
</div> </div>
)} )}
</div> </div>

@ -7,8 +7,6 @@ import { createProtectedRouter } from './context';
import type { Question } from '~/types/questions'; import type { Question } from '~/types/questions';
import { SortOrder, SortType } from '~/types/questions.d'; import { SortOrder, SortType } from '~/types/questions.d';
const TWO_WEEK_IN_MS = 12096e5;
export const questionsQuestionRouter = createProtectedRouter() export const questionsQuestionRouter = createProtectedRouter()
.query('getQuestionsByFilter', { .query('getQuestionsByFilter', {
input: z.object({ input: z.object({
@ -20,7 +18,7 @@ export const questionsQuestionRouter = createProtectedRouter()
roles: z.string().array(), roles: z.string().array(),
sortOrder: z.nativeEnum(SortOrder), sortOrder: z.nativeEnum(SortOrder),
sortType: z.nativeEnum(SortType), sortType: z.nativeEnum(SortType),
startDate: z.date().default(new Date(Date.now() - TWO_WEEK_IN_MS)), startDate: z.date().optional(),
}), }),
async resolve({ ctx, input }) { async resolve({ ctx, input }) {
const sortCondition = const sortCondition =

Loading…
Cancel
Save