Skip to content

Commit

Permalink
Merge pull request #241 from ln-dev7/feat/add-collaborators-on-form
Browse files Browse the repository at this point in the history
Feat/add collaborators on form
  • Loading branch information
ln-dev7 authored Nov 28, 2023
2 parents 2188464 + 0ef054a commit d1c24a0
Show file tree
Hide file tree
Showing 13 changed files with 346 additions and 150 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/avatar-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export function AvatarUser() {
<SheetTrigger asChild>
<div className="relative">
{data && data.exists && data.data.premium && (
<div className="absolute z-10 rounded-full -bottom-1 -right-1 flex items-center justify-center border-2 border-yellow-500 bg-white dark:bg-slate-800">
<Verified className="shrink-0 h-5 w-5 text-yellow-500 p-1" />
<div className="absolute -bottom-1 -right-1 z-10 flex items-center justify-center rounded-full border-2 border-yellow-500 bg-white dark:bg-slate-800">
<Verified className="h-5 w-5 shrink-0 p-1 text-yellow-500" />
</div>
)}
<Avatar
Expand Down
34 changes: 20 additions & 14 deletions components/form/publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,26 @@ export default function PublishForms({ dataForm }: { dataForm: any }) {
<Eye className="mr-2 h-4 w-4" />
View form
</Link>
<h3 className="text-md mt-4 font-semibold">
{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"}
</h3>
{isLoadingUpdateForm ? (
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
) : (
<p
className="mb-4 mt-2 cursor-pointer text-sm font-semibold uppercase text-muted-foreground underline underline-offset-4"
onClick={() => changeStatutOfForm()}
>
{!dataForm?.published ? "Publish" : "Unpublish"} your form
</p>
{dataForm.idAuthor === userPseudo && (
<>
<h3 className="text-md mt-4 font-semibold">
{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"}
</h3>
<>
{isLoadingUpdateForm ? (
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
) : (
<p
className="mb-4 mt-2 cursor-pointer text-sm font-semibold uppercase text-muted-foreground underline underline-offset-4"
onClick={() => changeStatutOfForm()}
>
{!dataForm?.published ? "Publish" : "Unpublish"} your form
</p>
)}
</>
</>
)}
{isSuccessUpdateForm && (
<div
Expand Down
195 changes: 103 additions & 92 deletions components/form/questions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default function QuestionsForms({ dataForm }: { dataForm: any }) {
updateFormDocument,
isLoading: isLoadingUpdateForm,
isError: isErrorUpdateForm,
error: errorUpdateForm,
isSuccess: isSuccessUpdateForm,
reset: resetUpdateForm,
}: any = useUpdateFormDocument("forms")
Expand Down Expand Up @@ -213,79 +214,85 @@ export default function QuestionsForms({ dataForm }: { dataForm: any }) {

return (
<div className="flex w-full flex-col items-start gap-4 sm:flex-row">
<div className="flex w-full shrink-0 flex-col items-start gap-2 rounded-md sm:sticky sm:top-20 sm:w-[250px]">
<button
onClick={() => handleAddField("heading")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<Heading className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Heading</span>
</button>
<button
onClick={() => handleAddField("text")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<Minus className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Short answer</span>
</button>
<button
onClick={() => handleAddField("longtext")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<AlignJustify className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Long answer</span>
</button>
<button
//onClick={() => handleAddField("link")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<LinkIcon className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Link</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button
//onClick={() => handleAddField("email")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<Mail className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">E-mail</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button className="flex w-full cursor-default items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800">
<CircleDot className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Unique choice</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button className="flex w-full cursor-default items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800">
<ListChecks className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Multi choice</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button className="flex w-full cursor-default items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800">
<List className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">List of choices</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button className="flex w-full cursor-default items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800">
<Calendar className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Date</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<Separator className="my-2 hidden w-full sm:block" />
</div>
<Separator className="my-2 block w-full sm:hidden" />
{dataForm.idAuthor === userPseudo && (
<>
<div className="flex w-full shrink-0 flex-col items-start gap-2 rounded-md sm:sticky sm:top-20 sm:w-[250px]">
<button
onClick={() => handleAddField("heading")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<Heading className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Heading</span>
</button>
<button
onClick={() => handleAddField("text")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<Minus className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Short answer</span>
</button>
<button
onClick={() => handleAddField("longtext")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<AlignJustify className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Long answer</span>
</button>
<button
//onClick={() => handleAddField("link")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<LinkIcon className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Link</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button
//onClick={() => handleAddField("email")}
className="flex w-full items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800"
>
<Mail className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">E-mail</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button className="flex w-full cursor-default items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800">
<CircleDot className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Unique choice</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button className="flex w-full cursor-default items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800">
<ListChecks className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Multi choice</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button className="flex w-full cursor-default items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800">
<List className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">
List of choices
</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<button className="flex w-full cursor-default items-center justify-start gap-1 rounded-md px-4 py-2 hover:bg-slate-100 hover:dark:bg-slate-800">
<Calendar className="h-5 w-5" />
<span className="ml-2 text-sm font-semibold">Date</span>
<span className="mr-2 rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs font-medium text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300">
soon
</span>
</button>
<Separator className="my-2 hidden w-full sm:block" />
</div>
<Separator className="my-2 block w-full sm:hidden" />
</>
)}
<div
id="questions"
className="relative flex w-full flex-col items-start gap-4 overflow-hidden rounded-md border px-4 pb-4 pt-7"
Expand Down Expand Up @@ -350,13 +357,15 @@ export default function QuestionsForms({ dataForm }: { dataForm: any }) {
{/* {errors?.questions?.[index]?.text && (
<p>{errors.questions[index].text.message}</p>
)} */}
<Button
variant="destructive"
className="absolute -top-2 right-2 flex h-10 w-10 items-center justify-center rounded-full p-2"
onClick={() => handleRemoveField(index)}
>
<Trash className="h-4 w-4" />
</Button>
{dataForm.idAuthor === userPseudo && (
<Button
variant="destructive"
className="absolute -top-2 right-2 flex h-10 w-10 items-center justify-center rounded-full p-2"
onClick={() => handleRemoveField(index)}
>
<Trash className="h-4 w-4" />
</Button>
)}
</div>
)
})}
Expand Down Expand Up @@ -390,18 +399,20 @@ export default function QuestionsForms({ dataForm }: { dataForm: any }) {
</button>
</div>
)}
<Button
variant="outline"
disabled={isLoadingUpdateForm}
onClick={isLoadingUpdateForm ? undefined : handleSubmit(onSubmit)}
>
{isLoadingUpdateForm ? (
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
) : (
<Save className="mr-2 h-4 w-4" />
)}
Save questions
</Button>
{dataForm.idAuthor === userPseudo && (
<Button
variant="outline"
disabled={isLoadingUpdateForm}
onClick={isLoadingUpdateForm ? undefined : handleSubmit(onSubmit)}
>
{isLoadingUpdateForm ? (
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
) : (
<Save className="mr-2 h-4 w-4" />
)}
Save questions
</Button>
)}
</div>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion components/form/responses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
>
<Accordion
type="single"
Expand Down
Loading

1 comment on commit d1c24a0

@vercel
Copy link

@vercel vercel bot commented on d1c24a0 Nov 28, 2023

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:

sharuco – ./

sharuco-ln-dev7.vercel.app
shruco.vercel.app
sharuco-git-master-ln-dev7.vercel.app
sharuco.lndev.me

Please sign in to comment.