Sort socials option in form

This commit is contained in:
Ahmed Al-Taiar
2024-10-06 18:58:05 -04:00
parent 49c943c9f3
commit 73ec75c167

View File

@@ -16,7 +16,7 @@ import type { EditSocialById, UpdateSocialInput } from 'types/graphql'
import type { RWGqlError } from '@redwoodjs/forms' import type { RWGqlError } from '@redwoodjs/forms'
import { Form, FieldError, Label, TextField, Submit } from '@redwoodjs/forms' import { Form, FieldError, Label, TextField, Submit } from '@redwoodjs/forms'
import { baseUrls, getLogoComponent } from 'src/lib/handle' import { baseUrls, getLogoComponent, sortOrder } from 'src/lib/handle'
type FormSocial = NonNullable<EditSocialById['social']> type FormSocial = NonNullable<EditSocialById['social']>
@@ -233,7 +233,9 @@ const SocialForm = (props: SocialFormProps) => {
tabIndex={0} tabIndex={0}
className="menu dropdown-content z-10 mt-2 grid w-72 grid-cols-5 grid-rows-2 gap-2 rounded-box bg-base-100 shadow-xl" className="menu dropdown-content z-10 mt-2 grid w-72 grid-cols-5 grid-rows-2 gap-2 rounded-box bg-base-100 shadow-xl"
> >
{types.map((type, i) => ( {types
.sort((a, b) => sortOrder.indexOf(a) - sortOrder.indexOf(b))
.map((type, i) => (
<li key={i}> <li key={i}>
<button <button
className="btn btn-square btn-ghost" className="btn btn-square btn-ghost"