Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
reenable ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
NextFire committed Jan 11, 2024
1 parent c40b12b commit c8d8c04
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 176 deletions.
2 changes: 1 addition & 1 deletion components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const submit = async () => {
<p
class="font-semibold text-ellipsis whitespace-nowrap overflow-hidden"
>
{{ count?.members.map((m) => m.name).join(", ") }}
{{ count.members.map((m) => m.name).join(", ") }}
</p>
</div>
<p v-if="count?.description">{{ count.description }}</p>
Expand Down
10 changes: 3 additions & 7 deletions components/balances/View.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
<script setup lang="ts">
const props = defineProps<{ count: CountData; currentMember?: number }>();
const sortedMembers = computed(
() => props.count?.members.sort((a, b) => a.name.localeCompare(b.name)) ?? []
);
const balances = computed(() =>
props.count ? computeBalances(props.count.expenses, sortedMembers.value) : []
props.count ? computeBalances(props.count.expenses, props.count.members) : []
);
</script>

<template>
<main class="space-y-2">
<BalancesChart
:members="sortedMembers"
:members="count.members"
:balances="balances"
:current-member="currentMember"
/>
<BalancesReimbursementsTable
:count="count"
:members="sortedMembers"
:members="count.members"
:balances="balances"
:current-member="currentMember"
/>
Expand Down
8 changes: 2 additions & 6 deletions components/new-expense/Infos.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<script setup lang="ts">
const props = defineProps<{ count: CountData }>();
const sortedMembers = computed(
() => props.count?.members.sort((a, b) => a.name.localeCompare(b.name)) ?? []
);
defineProps<{ count: CountData }>();
const title = defineModel<string>("title");
const amount = defineModel<number>("amount");
Expand Down Expand Up @@ -40,7 +36,7 @@ const author = defineModel<number>("author");
</div>
<select class="select select-bordered" v-model.number="author">
<option disabled selected value="undefined">Who paid?</option>
<option v-for="m in sortedMembers" :key="m.id" :value="m.id">
<option v-for="m in count.members" :key="m.id" :value="m.id">
{{ m.name }}
</option>
</select>
Expand Down
2 changes: 0 additions & 2 deletions components/new-expense/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ const submit = async () => {
@click="
() => {
expenseStore.$reset();
console.log(expenseStore.shares);
for (const m of count?.members ?? []) {
expenseStore.shares[m.id] = { fraction: 1, amount: '' };
}
Expand Down
16 changes: 6 additions & 10 deletions components/new-expense/Participants.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
const props = defineProps<{ count: CountData; expenseAmount: number }>();
const model = defineModel<ExpenseShares>({ default: {} });
const sortedMembers = computed(
() => props.count?.members.sort((a, b) => a.name.localeCompare(b.name)) ?? []
);
const updateSharesAmount = () => {
const formattedShares: { fraction?: number; amount?: number }[] = [];
const mIds = sortedMembers.value.map((m) => m.id);
const mIds = props.count.members.map((m) => m.id);
for (const id of mIds) {
const share = model.value[id];
if (share.amount !== "" && share.fraction === "") {
Expand Down Expand Up @@ -41,22 +37,22 @@ updateSharesAmount();
type="checkbox"
class="checkbox"
:checked="
sortedMembers.every(
count.members.every(
(m) => model[m.id].fraction || model[m.id].amount
)
"
@click="
() => {
if (
sortedMembers.every(
count.members.every(
(m) => model[m.id].fraction || model[m.id].amount
)
) {
for (const m of sortedMembers) {
for (const m of count.members) {
model[m.id] = { fraction: 0, amount: '' };
}
} else {
for (const m of sortedMembers) {
for (const m of count.members) {
if (!(model[m.id].fraction || model[m.id].amount))
model[m.id] = { fraction: 1, amount: '' };
}
Expand All @@ -73,7 +69,7 @@ updateSharesAmount();
</tr>
</thead>
<tbody>
<tr v-for="m in sortedMembers" :key="m.id">
<tr v-for="m in count.members" :key="m.id">
<th>
<label>
<input
Expand Down
3 changes: 1 addition & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
ssr: false,
modules: ["@nuxtjs/tailwindcss", "@pinia/nuxt", "@vueuse/nuxt"],
modules: ["@nuxtjs/tailwindcss", "@pinia/nuxt"],
app: {
head: {
viewport: "width=device-width, initial-scale=1, viewport-fit=cover", // https://github.com/saadeghi/daisyui/issues/1732
Expand Down
141 changes: 0 additions & 141 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@pinia/nuxt": "^0.5.1",
"@prisma/client": "^5.7.1",
"@tailwindcss/typography": "^0.5.10",
"@vueuse/nuxt": "^10.7.1",
"chart.js": "^4.4.1",
"daisyui": "^4.5.0",
"nuxt": "^3.9.0",
Expand Down
13 changes: 8 additions & 5 deletions pages/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ useHead({
titleTemplate: `${data.value?.title} | %s`,
});
const sortedMembers = computed(
() => data.value?.members.sort((a, b) => a.name.localeCompare(b.name)) ?? []
);
watchEffect(() => {
if (data.value) {
data.value.members.sort((a, b) => a.name.localeCompare(b.name));
}
});
const tabId = ref(0);
const currentMemberStr = useLocalStorage(`${countId}_currentMember`, "");
const currentMemberStr = useCookie(`${countId}_currentMember`);
currentMemberStr.value = currentMemberStr.value ?? "";
const currentMember = computed(() => {
const id = currentMemberStr.value;
return id ? parseInt(id) : undefined;
Expand All @@ -47,7 +50,7 @@ const currentMember = computed(() => {
v-model="currentMemberStr"
>
<option disabled selected value="">Identify as…</option>
<option v-for="m in sortedMembers" :value="m.id">{{ m.name }}</option>
<option v-for="m in data.members" :value="m.id">{{ m.name }}</option>
</select>
<button class="btn btn-sm btn-success" @click="refreshNuxtData()">
<ArrowPathIcon class="h-4 w-4" />
Expand Down
1 change: 0 additions & 1 deletion utils/shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export function computeReimbursments(
});
}
}
console.log(balances);

return reimb;
}

0 comments on commit c8d8c04

Please sign in to comment.