diff --git a/CHANGELOG.md b/CHANGELOG.md index 67c5a44..05ed2be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # @ln-dev7/sharuco +## 1.0.1 + +### Patch Changes + +- Thanks [@ln-dev7](https://github.com/ln-dev7)! + +**Full Changelog**: https://github.com/ln-dev7/sharuco/compare/v1.0.0...v1.0.1 + ## 1.0.0 ### Major Changes diff --git a/components/avatar-user.tsx b/components/avatar-user.tsx index 7ba1038..f715517 100644 --- a/components/avatar-user.tsx +++ b/components/avatar-user.tsx @@ -50,8 +50,8 @@ export function AvatarUser() {
{data && data.exists && data.data.premium && ( -
- +
+
)} View form -

- {dataForm.published - ? "Your form is currently online and can be viewed and answered by anyone at the link" - : "Your form is not published so can only be seen by you alone"} -

- {isLoadingUpdateForm ? ( - - ) : ( -

changeStatutOfForm()} - > - {!dataForm?.published ? "Publish" : "Unpublish"} your form -

+ {dataForm.idAuthor === userPseudo && ( + <> +

+ {dataForm.published + ? "Your form is currently online and can be viewed and answered by anyone at the link" + : "Your form is not published so can only be seen by you alone"} +

+ <> + {isLoadingUpdateForm ? ( + + ) : ( +

changeStatutOfForm()} + > + {!dataForm?.published ? "Publish" : "Unpublish"} your form +

+ )} + + )} {isSuccessUpdateForm && (
-
- - - - - - - - - - -
- + {dataForm.idAuthor === userPseudo && ( + <> +
+ + + + + + + + + + +
+ + + )}
{errors.questions[index].text.message}

)} */} - + {dataForm.idAuthor === userPseudo && ( + + )}
) })} @@ -390,18 +399,20 @@ export default function QuestionsForms({ dataForm }: { dataForm: any }) {
)} - + {dataForm.idAuthor === userPseudo && ( + + )}
) diff --git a/components/form/responses.tsx b/components/form/responses.tsx index be016ae..525639c 100644 --- a/components/form/responses.tsx +++ b/components/form/responses.tsx @@ -243,7 +243,7 @@ export default function ResponsesForms({ dataForm }: { dataForm: any }) { ? "border-2 border-solid border-emerald-500 dark:border-emerald-900" : "" )} - key={index} + key={response.idResponse} > { + setCheckIfUsernameExist(true) + checkIdAvailability("users", pseudo) + .then((isAvailable) => { + if (isAvailable) { + let updatedFormData = { + collaborators: [ + ...dataForm.collaborators, + { + pseudo: pseudo, + }, + ], + } + + updateFormDocument({ id, updatedFormData }) + } else { + toast({ + variant: "destructive", + title: "This user not exist on Sharuco", + description: "Make sure you have entered the correct user name.", + action: Okay, + }) + return + } + }) + .catch((error) => console.error("Error : ", error)) + .finally(() => { + setCheckIfUsernameExist(false) + }) + } + const removeCollaborator = async (pseudo: string) => { + let updatedFormData = { + collaborators: dataForm.collaborators.filter( + (item) => item.pseudo !== pseudo + ), + } + + updateFormDocument({ id, updatedFormData }) + } + const onSubmit = async (data) => { const { name: nameUpdate, @@ -343,6 +386,74 @@ export default function SettingsForms({ dataForm }: { dataForm: any }) { )}

+
+

Team

+
+ +
+
+ +

+ The added persons will be able to consult the answers to your + form. +

+
+
+ { + setUsernamePeopleToAdd(e.target.value) + }} + value={usernamePeopleToAdd} + /> + +
+ {dataForm.collaborators.length !== 0 && ( +
+ {dataForm.collaborators.map((collaborator, index) => ( +
+ + { + isLoadingUpdateForm + ? undefined + : removeCollaborator(collaborator.pseudo) + }} + > + Remove + +
+ ))} +
+ )} +
{/*

Payment

@@ -423,11 +534,11 @@ export default function SettingsForms({ dataForm }: { dataForm: any }) {
*/} -
-
+
+