Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
tobifra committed Mar 18, 2024
1 parent e8a6398 commit ff766e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 8 additions & 1 deletion api/app/Http/Controllers/CampController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public function syncExternalCamps()
{
$setting = Setting::find(1);
$token = $setting->midata_api_key;
if(!$token) {
return response()->json(['message' => 'MiData API key not found'], 404);
}
$midataId = $setting->midata_id;
$midataBaseUrl = config('services.midata.base_url');
$response = Http::get("{$midataBaseUrl}/de/groups/{$midataId}/events/camp.json?token={$token}");
Expand All @@ -78,12 +81,16 @@ public function syncExternalCamps()
foreach ($externalCamps['events'] as $externalCamp) {
$eventDateIds = $externalCamp['links']['dates'] ?? [];
$eventDate = collect($eventDateIds)->map(fn($id) => $eventDatesMap->get($id))->first();

$cost = $externalCamp['cost'];
$numericCost = preg_replace('/[^0-9.]+/', '', $cost);
$floatCost = $cost === '' ? null : floatval($numericCost);
Camp::updateOrCreate(
['midata_id' => $externalCamp['id']],
[
'name' => $externalCamp['name'],
'description' => $externalCamp['description'],
'cost' => $externalCamp['cost'] == '' ? null : $externalCamp['cost'],
'cost' => $floatCost,
'maximum_participants' => $externalCamp['maximum_participants'],
'participant_count' => $externalCamp['participant_count'],
'location' => $externalCamp['location'],
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/views/Dashboard/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
>
<font-awesome-icon :icon="icons.faCircle" />
<TextInput
:id="`selectFieldOption-${field.id}-${i}`"
:id="`selectFieldOption-${field.sort}-${i}`"
class="w-full"
type="text"
v-model="option.name"
Expand Down Expand Up @@ -198,11 +198,14 @@ export default {
},
methods: {
async addOption(event, field) {
if (!field.optionFields) {
field.optionFields = [];
}
field.optionFields.push({ name: event.target.value });
event.target.value = "";
await new Promise((resolve) => setTimeout(resolve, 10));
const textFieldToFocus = document.getElementById(
`selectFieldOption-${field.id}-${field.optionFields.length - 1}`,
`selectFieldOption-${field.sort}-${field.optionFields.length - 1}`,
);
textFieldToFocus.childNodes[1].focus();
},
Expand All @@ -215,7 +218,9 @@ export default {
},
addField(field) {
this.content.fields.push(field);
this.updateForm();
this.content.fields = this.content.fields.sort((a, b) => a.sort - b.sort);
this.content.fields.forEach((f, i) => (f.sort = i));
//this.updateForm();
},
deleteField(idAndType) {
this.content.fields = this.content.fields.filter(
Expand Down

0 comments on commit ff766e0

Please sign in to comment.