You've already forked AstralRinth
forked from didirus/AstralRinth
Switch notifications to new route, fix normal text from being bright white
This commit is contained in:
@@ -73,8 +73,8 @@
|
|||||||
--color-icon: #acacac;
|
--color-icon: #acacac;
|
||||||
--color-text: #cecece;
|
--color-text: #cecece;
|
||||||
--color-text-medium:#e4e4e4;
|
--color-text-medium:#e4e4e4;
|
||||||
--color-text-dark:#ffffff;
|
--color-text-dark: #fbf8ec;
|
||||||
--color-heading: #ffffff;
|
--color-heading: #fbf8ec;
|
||||||
--color-heading-light: #8a8a8a;
|
--color-heading-light: #8a8a8a;
|
||||||
--color-bg: #171719;
|
--color-bg: #171719;
|
||||||
--color-raised-bg: #222224;
|
--color-raised-bg: #222224;
|
||||||
@@ -250,18 +250,12 @@ textarea {
|
|||||||
.ea-content {
|
.ea-content {
|
||||||
background: var(--color-ad) !important;
|
background: var(--color-ad) !important;
|
||||||
border-radius: var(--size-rounded-card) !important;
|
border-radius: var(--size-rounded-card) !important;
|
||||||
margin-left: 0 !important;
|
margin: 0 !important;
|
||||||
margin-right: 0 !important;
|
|
||||||
margin-bottom: 0 !important;
|
|
||||||
margin-top: 0 !important;
|
|
||||||
box-shadow: var(--shadow-faint) !important;
|
box-shadow: var(--shadow-faint) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ea-callout {
|
.ea-callout {
|
||||||
margin-top: 0.25rem !important;
|
margin: 0.25rem 0 !important;
|
||||||
margin-bottom: 0.25rem !important;
|
|
||||||
margin-left: 0 !important;
|
|
||||||
margin-right: 0 !important;
|
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,44 @@
|
|||||||
<template>
|
<template>
|
||||||
<DashboardPage>
|
<DashboardPage>
|
||||||
<div class="section-header columns">
|
<div class="section-header columns">
|
||||||
<h3 class="column-grow-1">My invites</h3>
|
<h3 class="column-grow-1">My notifications</h3>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="invite in invites" :key="invite.team_id" class="invite columns">
|
<div
|
||||||
|
v-for="notification in notifications"
|
||||||
|
:key="notification.id"
|
||||||
|
class="notification columns"
|
||||||
|
>
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<p>
|
<nuxt-link :to="'/' + notification.link" class="top-wrapper">
|
||||||
Invite to join <strong>{{ invite.username }}'s</strong> team.
|
<h3 class="title">
|
||||||
|
{{ notification.title }}
|
||||||
|
</h3>
|
||||||
|
<p
|
||||||
|
v-tooltip="
|
||||||
|
$dayjs(notification.created).format(
|
||||||
|
'[Created at] YYYY-MM-DD [at] HH:mm A'
|
||||||
|
)
|
||||||
|
"
|
||||||
|
class="date"
|
||||||
|
>
|
||||||
|
Notified {{ $dayjs(notification.created).fromNow() }}
|
||||||
|
</p>
|
||||||
|
</nuxt-link>
|
||||||
|
<p class="description">
|
||||||
|
{{ notification.text }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div v-if="notification.actions.length > 0" class="actions">
|
||||||
<button @click="declineInvite(invite.team_id)">Decline</button>
|
<button
|
||||||
<button @click="acceptInvite(invite.team_id)">Accept</button>
|
v-for="(action, index) in notification.actions"
|
||||||
|
:key="index"
|
||||||
|
@click="performAction(notification, index)"
|
||||||
|
>
|
||||||
|
{{ action.title }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div v-else class="actions">
|
||||||
|
<button @click="performAction(notification, null)">Dismiss</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DashboardPage>
|
</DashboardPage>
|
||||||
@@ -34,89 +61,51 @@ export default {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const teams = (
|
const notifications = (
|
||||||
await axios.get(
|
await axios.get(
|
||||||
`https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/teams`,
|
`https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/notifications`,
|
||||||
config
|
config
|
||||||
)
|
)
|
||||||
).data.filter((it) => !it.accepted)
|
).data
|
||||||
|
|
||||||
const members = (
|
|
||||||
await Promise.all(
|
|
||||||
teams.map((it) =>
|
|
||||||
axios.get(
|
|
||||||
`https://api.modrinth.com/api/v1/team/${it.team_id}/members`,
|
|
||||||
config
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
).map((it) => it.data)
|
|
||||||
|
|
||||||
const invites = []
|
|
||||||
|
|
||||||
for (const member of members) {
|
|
||||||
const owner = member.find((it) => it.role === 'Owner')
|
|
||||||
|
|
||||||
const ownerData = (
|
|
||||||
await axios.get(
|
|
||||||
`https://api.modrinth.com/api/v1/user/${owner.user_id}`,
|
|
||||||
config
|
|
||||||
)
|
|
||||||
).data
|
|
||||||
|
|
||||||
invites.push({
|
|
||||||
team_id: owner.team_id,
|
|
||||||
username: ownerData.username,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
invites,
|
notifications,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async acceptInvite(teamId) {
|
async performAction(notification, index) {
|
||||||
const config = {
|
|
||||||
headers: {
|
|
||||||
Authorization: this.$auth.getToken('local'),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$nuxt.$loading.start()
|
this.$nuxt.$loading.start()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios.post(
|
if (index) {
|
||||||
`https://api.modrinth.com/api/v1/team/${teamId}/join`,
|
const config = {
|
||||||
{},
|
method: Object.keys(
|
||||||
config
|
notification.actions[index].action_route
|
||||||
)
|
)[0].toLowerCase(),
|
||||||
await this.$router.go(null)
|
url: `https://api.modrinth.com/api/v1/${
|
||||||
} catch (err) {
|
Object.values(notification.actions[index].action_route)[0]
|
||||||
this.$notify({
|
}`,
|
||||||
group: 'main',
|
headers: {
|
||||||
title: 'An Error Occurred',
|
Authorization: this.$auth.getToken('local'),
|
||||||
text: err.response.data.description,
|
},
|
||||||
type: 'error',
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$nuxt.$loading.finish()
|
await axios(config)
|
||||||
},
|
}
|
||||||
async declineInvite(teamId) {
|
|
||||||
const config = {
|
|
||||||
headers: {
|
|
||||||
Authorization: this.$auth.getToken('local'),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$nuxt.$loading.start()
|
const config = {
|
||||||
|
headers: {
|
||||||
|
Authorization: this.$auth.getToken('local')
|
||||||
|
? this.$auth.getToken('local')
|
||||||
|
: '',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
await axios.delete(
|
await axios.delete(
|
||||||
`https://api.modrinth.com/api/v1/team/${teamId}/members/${this.$auth.user.id}`,
|
`https://api.modrinth.com/api/v1/notification/${notification.id}`,
|
||||||
config
|
config
|
||||||
)
|
)
|
||||||
await this.$router.go(null)
|
await this.$router.replace('/' + notification.link)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.$notify({
|
this.$notify({
|
||||||
group: 'main',
|
group: 'main',
|
||||||
@@ -133,13 +122,26 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.invite {
|
.notification {
|
||||||
@extend %card;
|
@extend %card;
|
||||||
padding: var(--spacing-card-sm) var(--spacing-card-lg);
|
padding: var(--spacing-card-sm) var(--spacing-card-lg);
|
||||||
margin-bottom: var(--spacing-card-sm);
|
margin-bottom: var(--spacing-card-sm);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
|
.text {
|
||||||
|
.top-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: baseline;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: var(--font-size-lg);
|
||||||
|
margin: 0 0.5rem 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user