-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: 🔖 release new app version
- Loading branch information
Showing
28 changed files
with
834 additions
and
93 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...a/migrations/20230317171159_adds_possiblity_of_multiple_answers_to_one_card/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `answer` on the `Card` table. All the data in the column will be lost. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "Card" DROP COLUMN "answer", | ||
ADD COLUMN "validAnswers" TEXT[]; |
17 changes: 17 additions & 0 deletions
17
prisma/migrations/20230317201422_adds_answer_validation_report_model/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- CreateTable | ||
CREATE TABLE "AnswerValidationReport" ( | ||
"id" TEXT NOT NULL, | ||
"cardId" TEXT NOT NULL, | ||
"userId" TEXT, | ||
"answer" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "AnswerValidationReport_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "AnswerValidationReport" ADD CONSTRAINT "AnswerValidationReport_cardId_fkey" FOREIGN KEY ("cardId") REFERENCES "Card"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "AnswerValidationReport" ADD CONSTRAINT "AnswerValidationReport_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
5 changes: 5 additions & 0 deletions
5
prisma/migrations/20230318184925_adds_answer_validation_status_field/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- CreateEnum | ||
CREATE TYPE "AnswerValidationReportStatus" AS ENUM ('Pending', 'Accepted', 'Rejected'); | ||
|
||
-- AlterTable | ||
ALTER TABLE "AnswerValidationReport" ADD COLUMN "status" "AnswerValidationReportStatus" NOT NULL DEFAULT 'Pending'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { BaseModal } from './base/base-modal.component' | ||
import { NewCardModal } from './new-card/new-card-modal.component' | ||
import { NewTopicModal } from './new-topic/new-topic-modal.component' | ||
import { ReportAnswerValidationModal } from './report-answer-validation/report-answer-validation.component' | ||
|
||
export const Modal = { | ||
Base: BaseModal, | ||
NewTopic: NewTopicModal, | ||
NewCard: NewCardModal, | ||
ReportAnswerValidation: ReportAnswerValidationModal, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/components/modal/report-answer-validation/report-answer-validation.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { useEffect, useMemo } from 'react' | ||
import { useForm } from 'react-hook-form' | ||
|
||
import { Button } from '~/components/button' | ||
import { TextArea } from '~/components/text-area' | ||
import { api } from '~/utils/api' | ||
import { withoutPropagation } from '~/utils/forms' | ||
import { notify } from '~/utils/toast' | ||
|
||
import { BaseModal } from '../base/base-modal.component' | ||
import type { ReportAnswerValidationModalProps } from './report-answer-validation.types' | ||
|
||
export function ReportAnswerValidationModal( | ||
props: ReportAnswerValidationModalProps, | ||
) { | ||
const { isOpen, setIsOpen, answer, cardId } = props | ||
|
||
const { mutate: sendReport } = | ||
api.answerValidationReports.reportAnswerValidation.useMutation() | ||
|
||
const { handleSubmit, reset, register } = useForm({ | ||
defaultValues: useMemo(() => ({ answer }), [answer]), | ||
}) | ||
|
||
useEffect(() => { | ||
reset({ answer }) | ||
}, [reset, answer]) | ||
|
||
const close = () => { | ||
setIsOpen(false) | ||
reset() | ||
} | ||
|
||
const handleSubmitWithoutPropagation = withoutPropagation( | ||
handleSubmit(values => { | ||
sendReport({ | ||
...values, | ||
cardId, | ||
}) | ||
close() | ||
|
||
setTimeout(() => { | ||
notify.success('Solicitação enviada com sucesso!') | ||
}, 500) | ||
}), | ||
) | ||
|
||
return ( | ||
<BaseModal isOpen={isOpen} setIsOpen={setIsOpen} title='Solicitar revisão'> | ||
<span> | ||
Caso você acredite que sua resposta deveria ter sido considerada | ||
correta, é possÃvel enviar uma solicitação de revisão para o criador do | ||
Deck submetendo este formulário. Dessa forma, caso a solicitação seja | ||
aceita, futuras respostas como a sua serão consideradas corretas. | ||
</span> | ||
<form | ||
className='mt-5 flex flex-col' | ||
onSubmit={handleSubmitWithoutPropagation} | ||
> | ||
<TextArea id='answer' label='Resposta' {...register('answer')} /> | ||
<div className='mt-2 flex flex-col justify-end gap-5 md:flex-row'> | ||
<Button fullWidth type='button' variant='bad' onClick={close}> | ||
Cancelar | ||
</Button> | ||
<Button fullWidth>Enviar Solicitação</Button> | ||
</div> | ||
</form> | ||
</BaseModal> | ||
) | ||
} |
6 changes: 6 additions & 0 deletions
6
src/components/modal/report-answer-validation/report-answer-validation.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { BaseModalProps } from '../base/base-modal.types' | ||
|
||
export type ReportAnswerValidationModalProps = { | ||
answer: string | ||
cardId: string | ||
} & Pick<BaseModalProps, 'isOpen' | 'setIsOpen'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/modules/decks/components/answer-validation-report-card.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { BoltIcon } from '@heroicons/react/24/outline' | ||
import { useRouter } from 'next/router' | ||
|
||
import { Button } from '~/components/button' | ||
import { api } from '~/utils/api' | ||
import { routes } from '~/utils/navigation' | ||
|
||
type AnswerValidationReportsCardProps = { | ||
deckId: string | ||
} | ||
|
||
export function AnswerValidationReportsCard( | ||
props: AnswerValidationReportsCardProps, | ||
) { | ||
const { deckId } = props | ||
|
||
const router = useRouter() | ||
|
||
const { | ||
isError, | ||
isLoading, | ||
data: hasDeckPendingAnswerValidationReports, | ||
} = api.answerValidationReports.hasDeckPendingAnswerValidationReports.useQuery( | ||
{ deckId }, | ||
) | ||
|
||
if (isLoading) { | ||
return ( | ||
<div className='flex animate-pulse rounded-md bg-primary-200 p-20 sm:p-16'> | ||
<span className='sr-only'>Loading...</span> | ||
</div> | ||
) | ||
} | ||
|
||
if (isError || !hasDeckPendingAnswerValidationReports) return null | ||
|
||
const goToAnswerValidationReports = () => { | ||
router.push(routes.answerValidationReports(deckId)) | ||
} | ||
|
||
return ( | ||
<div className='relative flex flex-col gap-5 rounded-md bg-primary-50 p-5 shadow-md shadow-primary-200 ring-1 ring-primary-900 sm:flex-row'> | ||
<div className='flex flex-1 items-center gap-5'> | ||
<BoltIcon className='h-16 w-16 text-primary-900' /> | ||
<div className='flex flex-col text-primary-900'> | ||
<p className='text-lg sm:text-xl'>Melhore o seu Deck agora mesmo!</p> | ||
<p className='max-w-2xl text-base'> | ||
Usuários solicitaram revisão das respostas de alguns dos cards do | ||
seu Deck. Acesse a seção de solicitações para fazer a revisão 🤗 | ||
</p> | ||
</div> | ||
</div> | ||
<div className='flex items-end'> | ||
<div className='hidden h-0 sm:flex sm:h-auto sm:items-end'> | ||
<Button onClick={goToAnswerValidationReports}> | ||
Acessar solicitações | ||
</Button> | ||
</div> | ||
<div className='block w-full sm:hidden sm:w-0'> | ||
<Button fullWidth onClick={goToAnswerValidationReports}> | ||
Acessar solicitações | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
614a2f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
briskly – ./
briskly-emiliosheinz.vercel.app
briskly.app
briskly-git-main-emiliosheinz.vercel.app