-
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: restyle reply * feat: can reply a form --------- Co-authored-by: sanda03 <[email protected]>
- Loading branch information
1 parent
94cbcfd
commit 052966b
Showing
18 changed files
with
876 additions
and
183 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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,19 @@ | ||
import { Button, Typography } from "@material-tailwind/react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
import errorImage from "../../assets/images/private.png"; | ||
|
||
export function AlreadyRespond() { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<div className="w-[800px] mx-auto flex-col min-h-[500px] gap-5 flex items-center justify-center"> | ||
<img src={errorImage} className="w-[350px]" /> | ||
<Typography className="text-bgray text-[30px] text-center"> | ||
Form not found or Multiple responses are not allowed for the form, so | ||
you no longer have access to respond. | ||
</Typography> | ||
<Button onClick={() => navigate("/dashboard")}>Go to Dashboard</Button> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Button, Typography } from "@material-tailwind/react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
import errorImage from "../../assets/images/error_multiple.png"; | ||
|
||
export function PrivateForm() { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<div className="w-[500px] mx-auto flex-col min-h-[500px] gap-5 flex items-center justify-center"> | ||
<img src={errorImage} className="w-[350px]" /> | ||
<Typography className="text-bgray text-[30px] text-center"> | ||
Only the form owner can view the results as the form is set to private | ||
</Typography> | ||
<Button onClick={() => navigate("/dashboard")}>Go to Dashboard</Button> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./AlreadyRespond"; | ||
export * from "./PrivateForm"; |
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
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,10 +1,63 @@ | ||
import { useNavigate, useParams } from "react-router-dom"; | ||
import { useEffect, useState } from "react"; | ||
import { ReplyFormHeader, ReplyFormBody } from "./components"; | ||
import { useNotify } from "../../../hooks"; | ||
import { useDashboardState } from "../../../stores"; | ||
import { formsProvider } from "../../../providers"; | ||
import { dumbLoading } from "../../utils"; | ||
|
||
/*eslint-disable*/ | ||
export function FormReply() { | ||
const [form, setForms] = useState(null); | ||
const { formId } = useParams(); | ||
const notify = useNotify((state) => state.setNotify); | ||
const navigate = useNavigate(); | ||
const { isLoading, setIsLoading } = useDashboardState(); | ||
|
||
useEffect(() => { | ||
setIsLoading(true); | ||
|
||
const getFormById = async () => { | ||
formsProvider | ||
.getFormById(formId) | ||
.then((formResponse) => { | ||
setForms(formResponse); | ||
}) | ||
.catch(() => { | ||
notify("Oops, form not found or something went wrong", { | ||
color: "red", | ||
}); | ||
navigate("/dashboard"); | ||
}) | ||
.finally(() => dumbLoading(() => setIsLoading(false))); | ||
}; | ||
|
||
const testIfCanReply = async () => { | ||
formsProvider | ||
.canIReply(formId) | ||
.then((data) => { | ||
if (!data) { | ||
navigate("/dashboard/error/multiple"); | ||
dumbLoading(() => setIsLoading(false)); | ||
} else { | ||
getFormById(); | ||
} | ||
}) | ||
.catch(async () => { | ||
navigate("/dashboard/error/multiple"); | ||
dumbLoading(() => setIsLoading(false)); | ||
}); | ||
}; | ||
|
||
testIfCanReply(); | ||
}, [formId]); | ||
|
||
if (isLoading || form === null) return null; | ||
|
||
return ( | ||
<div className="w-full mx-auto max-w-[900px]"> | ||
<ReplyFormHeader /> | ||
<ReplyFormBody /> | ||
<ReplyFormHeader form={form} /> | ||
<ReplyFormBody questions={form.questions || []} formId={form.id} /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.