Skip to content

Commit b5fc691

Browse files
committed
Disable button
1 parent 96f2fbb commit b5fc691

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

app/Http/Controllers/CommentController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public function store(StoreCommentRequest $request)
6262
} catch (Throwable $e) {
6363
DB::rollBack();
6464
Log::critical('Failed to save comment', [
65-
'error' => $e->getMessage(),
66-
'trace' => $e->getTraceAsString(),
6765
'validated_data' => $validatedData,
6866
'user_id' => Auth::id(),
67+
'error' => $e->getMessage(),
68+
'trace' => $e->getTraceAsString(),
6969
]);
7070

7171
return response()->json(['message' => 'Failed to save comment'], 500);

app/Http/Controllers/UpvoteController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function downvote($typeKey, $id)
2929
{
3030
$result = $this->upvoteService->downvote($typeKey, $id);
3131

32+
// TODO: REFACTOR TO EXCEPTIONS
3233
if (isset($result['error'])) {
3334
return response()->json(['message' => $result['error']], $result['status']);
3435
}

resources/js/Pages/Resources/Create.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const { isSavedToLocalStorage, hasFormContent, clearLocalStorage } =
4646
const showReset = ref(false);
4747
const stepperValue = ref("1");
4848
const formRef = ref(null);
49+
const isLoading = ref(false);
4950
const toast = useToast();
5051
5152
const scrollToForm = () => {
@@ -70,13 +71,15 @@ const resetForm = () => {
7071
};
7172
7273
const submitForm = async () => {
74+
isLoading.value = true;
7375
try {
7476
const response = await axios.postForm(
7577
route("resources.store"),
7678
formData
7779
);
78-
clearLocalStorage();
7980
81+
clearLocalStorage();
82+
isLoading.value = false;
8083
router.visit(route("resources.show", { slug: response.data.slug }));
8184
} catch (err) {
8285
toast.add({
@@ -89,6 +92,7 @@ const submitForm = async () => {
8992
: "An error occurred while creating the resource. Please try again."),
9093
life: 10000,
9194
});
95+
isLoading.value = false;
9296
console.error(err);
9397
}
9498
};
@@ -161,6 +165,7 @@ const handleFormChange = (newFormData) => {
161165
@change="handleFormChange"
162166
@back="() => navigateToStep('1')"
163167
@next="submitForm"
168+
:is-loading="isLoading"
164169
/>
165170
</StepPanel>
166171
</StepPanels>

resources/js/Pages/Resources/Form/TagsFields.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const props = defineProps({
1414
type: Object,
1515
required: true,
1616
},
17+
isLoading: {
18+
type: Boolean,
19+
required: true,
20+
}
1721
});
1822
1923
const emit = defineEmits(["change", "next", "back"]);
@@ -97,7 +101,7 @@ const validateAndNext = async () => {
97101
<Icon class="mr-2" icon="mdi:arrow-back" />
98102
Back
99103
</SecondaryButton>
100-
<PrimaryButton @click="validateAndNext">
104+
<PrimaryButton @click="validateAndNext" :disabled="props.isLoading">
101105
Submit
102106
<Icon class="ml-2" icon="mdi:send" />
103107
</PrimaryButton>

0 commit comments

Comments
 (0)