Skip to content

Commit

Permalink
Merge branch 'main' into order-collection
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric authored Sep 5, 2023
2 parents 422711c + 347a0a6 commit d5dba1b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 18 deletions.
24 changes: 15 additions & 9 deletions frontend/src/views/Collection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
v-if="collection.length"
class="grid grid-cols-1 gap-y-12 sm:grid-cols-2 sm:gap-x-6 lg:grid-cols-4 xl:gap-x-8 mb-32"
>
<div v-for="(item, index) in collection">
<div
v-for="(item, index) in collection"
class="h-full flex flex-col"
>
<div
:index="index"
class="relative"
Expand All @@ -14,16 +17,19 @@
<div class="relative mt-4">
<h3 class="text-sm font-medium">{{ item.name }}</h3>
<p class="mt-1 text-sm text-zinc-500">{{ item.description }}</p>
<p class="mt-3 text-xs text-zinc-500">
<template v-if="item.presentee_id === user.id">
Received {{ new Date(item.created).toLocaleDateString('en-us', { year:"numeric", month:"short", day:"numeric"}) }}
</template>
<template v-else>
Purchased {{ new Date(item.created).toLocaleDateString('en-us', { year:"numeric", month:"short", day:"numeric"}) }}
</template>
</p>

</div>
</div>
<div class="mt-auto">
<p class="mt-3 text-xs text-zinc-500">
<template v-if="item.presentee_id === user.id">
Received {{ new Date(item.created).toLocaleDateString('en-us', { year:"numeric", month:"short", day:"numeric"}) }}
</template>
<template v-else>
Purchased {{ new Date(item.created).toLocaleDateString('en-us', { year:"numeric", month:"short", day:"numeric"}) }}
</template>
</p>
</div>
</div>
</div>
<div
Expand Down
55 changes: 46 additions & 9 deletions src/Controller/Api/ShopController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,55 @@ public function purchase()
$productsTable->saveOrFail($product);

if ($presentee !== null) {
$message = '<@' . $user->slack_user_id . '> did buy a nice little present for '
. '<@' . $presentee->slack_user_id . '> 🎁😊' . PHP_EOL;
$message .= PHP_EOL;
$message .= 'They got them *<' . Router::url(str_replace('.svg', '.png', $product->image_link), true)
. '|' . $product->name . '. >* πŸš€' . PHP_EOL;
$message .= PHP_EOL;
$message .= '_"' . $this->request->getData('message') . '"_' . PHP_EOL;
$blocks = [
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => "<@{$user->slack_user_id}> did buy a nice little present for "
. "<@{$presentee->slack_user_id}> 🎁😊",
],
],
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => "They got them *{$product->name}* πŸš€",
],
],
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => "_{$this->request->getData('message')}_",
],
],
[
'type' => 'divider',
],
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => '<' . Router::url('/shop', true) . '|Gib a present to a fellow Sentaur yourself!>',
],
],
[
'type' => 'image',
'image_url' => Router::url(str_replace('.svg', '.png', $product->image_link), true),
'alt_text' => $product->name,
'title' => [
'type' => 'plain_text',
'text' => $product->name,
],
],

];

$slackClient = new SlackClient();
$slackClient->postMessage(
$slackClient->postBlocks(
channel: env('POTATO_CHANNEL'),
text: $message,
blocks: json_encode($blocks),
);
}

Expand Down

0 comments on commit d5dba1b

Please sign in to comment.