Skip to content

Commit

Permalink
Feature/Greater and less than logic paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryczko committed May 21, 2024
1 parent 04d3bdf commit 2243a9b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions locales/en/surveyCreate.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"surveyCreationSucessCopiedCorrectly": "and link copied to clipboard",
"signInToCreateSurvey": "Sign in to create survey",
"options": "Display options",
"GREATER_THAN": "Greater than",
"LESS_THAN": "Less than",
"GREATER_THAN": "greater than",
"LESS_THAN": "less than",
"EQUAL": "equals",
"SUBMITTED": "is submitted"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ export default function ActionButtons() {
<AddQuestionButton onClick={addQuestion} />
)}

<hr className="my-3" />
{user ? (
<div className="flex flex-col gap-2 sm:flex-row">
{isEditMode && (
<Button
onClick={discardChanges}
className="z-0 w-full"
className="z-0 h-[50px] w-full"
variant={ButtonVariant.OUTLINE}
disabled={isCreating}
>
Expand All @@ -43,7 +44,7 @@ export default function ActionButtons() {
<Button
name="create-survey"
onClick={isEditMode ? confirmEditSurvey : createSurvey}
className="z-0 w-full"
className="z-0 h-[50px] w-full"
variant={ButtonVariant.PRIMARY}
isLoading={isCreating}
disabled={questions.length === 0}
Expand All @@ -55,7 +56,7 @@ export default function ActionButtons() {
<Button
onClick={signInToCreateSurvey}
variant={ButtonVariant.PRIMARY}
className="z-0 mt-2 w-full"
className="z-0 mt-2 h-[50px] w-full"
>
{t('signInToCreateSurvey')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const AddQuestionButton = ({ onClick }: AddQuestionButtonProps) => {
<Button
onClick={openModal}
sizeType={ButtonSize.FULL}
icon={<PlusCircleIcon className="h-5 w-5" />}
className="h-[50px]"
icon={<PlusCircleIcon className="h-5 w-5" />}
>
Add new block
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export default function RateAdvancedSettings({
questionData.logicPaths?.map(() => ({
comparisons: getAvailableComparisons(
[
// ComparisonType.LESS_THAN,
ComparisonType.LESS_THAN,
ComparisonType.GREATER_THAN,
ComparisonType.EQUAL,
// ComparisonType.GREATER_THAN,
],
t
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function QuestionBlockWrapper({

return (
<div className="relative rounded-md border border-l-4 border-secondary-200 border-l-secondary-300 bg-white shadow-sm">
<div className="flex flex-col items-start gap-1 pe-2 ps-2 pt-2 sm:flex-row sm:gap-2">
<div className="flex flex-col items-start gap-0 pe-2 ps-2 pt-2 sm:flex-row sm:gap-2">
<div className="flex w-full items-start gap-2">
<Button
onClick={onExpand}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export const useCreateSurveyManager = (initialData?: SurveyWithQuestions) => {
}

return () => {
console.log('clean');
setActivePage(undefined);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,24 @@ export const useSurveyAnswerManager = (
const submitCondition =
path.comparisonType === ComparisonType.SUBMITTED;

if (equalCondition || submitCondition) {
const greatThanCondition =
path.comparisonType === ComparisonType.GREATER_THAN &&
activeQuestion.answer &&
path.selectedOption &&
Number(activeQuestion.answer) > Number(path.selectedOption);

const lessThanCondition =
path.comparisonType === ComparisonType.LESS_THAN &&
activeQuestion.answer &&
path.selectedOption &&
Number(activeQuestion.answer) < Number(path.selectedOption);

if (
equalCondition ||
submitCondition ||
greatThanCondition ||
lessThanCondition
) {
if (path.endSurvey) {
handleSave(false);
return;
Expand Down

0 comments on commit 2243a9b

Please sign in to comment.