Skip to content

Commit

Permalink
display states
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiritin committed Jul 21, 2024
1 parent dd96e84 commit 2c98cb1
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 5 deletions.
3 changes: 3 additions & 0 deletions app/Console/Commands/CreateOrUpdateEventForStateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ private function createOrUpdateEvent($event, $startsAt, $preorderStartsAt, $preo
if ($event) {
$event->update([
'starts_at' => $startsAt,
'ends_at' => now()->addDays(30),
'preorder_starts_at' => $preorderStartsAt,
'preorder_ends_at' => $preorderEndsAt,
'order_ends_at' => $orderEndsAt,
]);
} else {
Event::create([
'name' => 'Test Event',
'starts_at' => $startsAt,
'ends_at' => now()->addDays(30),
'preorder_starts_at' => $preorderStartsAt,
'preorder_ends_at' => $preorderEndsAt,
'order_ends_at' => $orderEndsAt,
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/BadgeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public function destroy(Request $request, Badge $badge)
// Refund Badge
$request->user()->refund($badge);
$badge->delete();
// Delete Fursuit if no badges left
if ($badge->fursuit->badges()->count() === 0) {
$badge->fursuit->delete();
}
});
// if user has no badges left redirect to welcome
if ($request->user()->badges()->count() === 0) {
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Fursuit/Fursuit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Storage;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\ModelStates\HasStates;

class Fursuit extends Model
{
use HasStates, LogsActivity, HasFactory;
use HasStates, LogsActivity, HasFactory, SoftDeletes;
protected $guarded = [];

protected $casts = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
public function up(): void
{
Schema::table('fursuits', function (Blueprint $table) {
$table->after('rejected_at', fn($table) => $table->softDeletes());
});
}
};
59 changes: 55 additions & 4 deletions resources/js/Components/BadgeListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const props = defineProps({
badge: Object
});
function getStatusName(status) {
function getFursuitStatusName(status) {
switch (status) {
case 'pending':
return 'Pending Review';
Expand All @@ -17,7 +17,7 @@ function getStatusName(status) {
}
}
function getSeverity(status) {
function getFursuitSeverity(status) {
switch (status) {
case 'pending':
return 'warning';
Expand All @@ -28,7 +28,7 @@ function getSeverity(status) {
}
}
function getTooltipText(status) {
function getFursuitTooltipText(status) {
switch (status) {
case 'pending':
return 'This badge is pending review. We will notify you once it has been approved or rejected.';
Expand All @@ -38,6 +38,46 @@ function getTooltipText(status) {
return 'This badge has been rejected, we have emailed you the reason.';
}
}
function getBadgeStatusName(status) {
switch (status) {
case 'pending':
return 'Pending Printing';
case 'printed':
return 'Printed';
case 'ready_for_pickup':
return 'Ready for Pickup';
case 'picked_up':
return 'Picked Up';
}
}
function getBadgeSeverity(status) {
switch (status) {
case 'pending':
return 'warning';
case 'printed':
return 'info';
case 'ready_for_pickup':
return 'success';
case 'picked_up':
return 'success';
}
}
function getBadgeTooltipText(status) {
switch (status) {
case 'pending':
return 'This badge is pending printing. We will notify you once it is ready for pickup.';
case 'printed':
return 'This badge has been printed. No further changes can be made.';
case 'ready_for_pickup':
return 'This badge is ready for pickup.';
case 'picked_up':
return 'This badge has been picked up.';
}
}
</script>

<template>
Expand All @@ -50,7 +90,18 @@ function getTooltipText(status) {
<h2 class="text-lg font-semibold font-main">{{ badge.fursuit.name }}</h2>
<p>{{ badge.fursuit.species.name }}</p>
<div class="py-1">
<Tag v-tooltip.bottom="getTooltipText(badge.fursuit.status)" :severity="getSeverity(badge.fursuit.status)" :value="getStatusName(badge.fursuit.status)"/>
<Tag
v-if="badge.status === 'pending'"
v-tooltip.bottom="getFursuitTooltipText(badge.fursuit.status)"
:severity="getFursuitSeverity(badge.fursuit.status)"
:value="getFursuitStatusName(badge.fursuit.status)"
/>
<Tag
v-if="badge.fursuit.status === 'approved' && badge.status !== 'pending'"
v-tooltip.bottom="getBadgeTooltipText(badge.status)"
:severity="getBadgeSeverity(badge.status)"
:value="getBadgeStatusName(badge.status)"
/>
</div>
</div>
<div v-if="badge.extra_copy" class="flex flex-col justify-center px-4 pb-1 md:p-4 gap-2">
Expand Down

0 comments on commit 2c98cb1

Please sign in to comment.