Skip to content

Commit

Permalink
feat(envited.ascs.digital): Add LoadingIndicator on server actions
Browse files Browse the repository at this point in the history
Signed-off-by: Jeroen Branje <[email protected]>
  • Loading branch information
jeroenbranje committed Feb 27, 2024
1 parent 7b860ba commit 5ad0f82
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/envited.ascs.digital/modules/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Checkboxes,
DragAndDropField,
Heading,
LoadingIndicator,
TextField,
TextareaField,
} from '@envited-marketplace/design-system'
Expand Down Expand Up @@ -51,7 +52,7 @@ export const Profile: FC<ProfileProps> = ({ profile, memberCategories }) => {
control,
handleSubmit,
getValues,
formState: { errors },
formState: { errors, isSubmitting },
} = useForm<ProfileInputs>({
resolver: zodResolver(ProfileSchema),
defaultValues: {
Expand Down Expand Up @@ -81,6 +82,8 @@ export const Profile: FC<ProfileProps> = ({ profile, memberCategories }) => {
}

const updateProfileAction: SubmitHandler<ProfileInputs> = async data => {
// return new Promise(resolve => setTimeout(resolve, 2000))

try {
await updateProfileForm(data)
success('Profile is updated')
Expand Down Expand Up @@ -375,8 +378,9 @@ export const Profile: FC<ProfileProps> = ({ profile, memberCategories }) => {
<button
type="submit"
className="bg-blue hover:bg-blue-900 text-white transition rounded-full font-bold py-2 px-4"
disabled={isSubmitting}
>
{t('[Button] update profile')}
{isSubmitting ? <LoadingIndicator /> : t('[Button] update profile')}
</button>
</div>
</form>
Expand Down

0 comments on commit 5ad0f82

Please sign in to comment.