From 2e9b1e28d13d487a8613cca0d79849431ff4ce7e Mon Sep 17 00:00:00 2001 From: wlren Date: Fri, 21 Oct 2022 16:45:48 +0800 Subject: [PATCH] [questions][ui] list page --- apps/portal/src/pages/questions/lists.tsx | 183 ++++++++++++++++--- apps/portal/src/utils/questions/constants.ts | 6 +- 2 files changed, 157 insertions(+), 32 deletions(-) diff --git a/apps/portal/src/pages/questions/lists.tsx b/apps/portal/src/pages/questions/lists.tsx index bd0e9898..f64f1014 100644 --- a/apps/portal/src/pages/questions/lists.tsx +++ b/apps/portal/src/pages/questions/lists.tsx @@ -1,43 +1,168 @@ -import { NoSymbolIcon } from '@heroicons/react/24/outline'; +import { useState } from 'react'; +import { Menu } from '@headlessui/react'; +import { + EllipsisVerticalIcon, + NoSymbolIcon, + PlusIcon, +} from '@heroicons/react/24/outline'; import QuestionListCard from '~/components/questions/card/question/QuestionListCard'; +import { Button } from '~/../../../packages/ui/dist'; import { SAMPLE_QUESTION } from '~/utils/questions/constants'; import createSlug from '~/utils/questions/createSlug'; export default function ListPage() { - const questions = [SAMPLE_QUESTION, SAMPLE_QUESTION, SAMPLE_QUESTION]; + const questions = [ + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + SAMPLE_QUESTION, + ]; + const lists = [ + { id: 1, name: 'list 1', questions }, + { id: 2, name: 'list 2', questions }, + { id: 3, name: 'list 3', questions }, + { id: 4, name: 'list 4', questions }, + { id: 5, name: 'list 5', questions }, + ]; + + const [selectedList, setSelectedList] = useState( + (lists ?? []).length > 0 ? lists[0].id : '', + ); + const listOptions = ( + <> + + {lists?.length === 0 && ( +
+

You have yet to create a list

+
+ )} + + ); return (
-
- {(questions ?? []).map((question) => ( - { - // eslint-disable-next-line no-console - console.log('delete'); - }} - /> - ))} - {questions?.length === 0 && ( -
- -

Your list is empty.

+
+ +
+
+
+ {selectedList && ( +
+ {(questions ?? []).map((question) => ( + { + // eslint-disable-next-line no-console + console.log('delete'); + }} + /> + ))} + {questions?.length === 0 && ( +
+ +

You have no added any questions to your list yet.

+
+ )} +
+ )} +
- )} +
); diff --git a/apps/portal/src/utils/questions/constants.ts b/apps/portal/src/utils/questions/constants.ts index 2c19219f..fac5ea4c 100644 --- a/apps/portal/src/utils/questions/constants.ts +++ b/apps/portal/src/utils/questions/constants.ts @@ -103,14 +103,14 @@ export const ROLES: FilterChoices = [ export const SAMPLE_QUESTION = { answerCount: 10, commentCount: 10, - company: 'Google', + companies: { Google: 1 }, content: 'Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums andiven an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums andiven an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums andiven an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums andiven an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums andiven an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums andiven an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums andiven an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up. Given an array of integers nums and', createdAt: new Date(2014, 8, 1, 11, 30, 40), id: '1', - location: 'Menlo Park, CA', + locations: { 'Menlo Park, CA': 1 }, receivedCount: 12, - role: 'Software Engineer', + roles: { 'Software Engineer': 1 }, seenAt: new Date(2014, 8, 1, 11, 30, 40), timestamp: 'Last month',