Skip to content

Commit d621ddd

Browse files
committed
feat: display project rules
1 parent 171b527 commit d621ddd

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

frontend/app/api/generated.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ export type CreateProjectInput = {
248248
description?: InputMaybe<Scalars['String']['input']>;
249249
endDate: Scalars['DateTime']['input'];
250250
name: Scalars['String']['input'];
251+
rules?: InputMaybe<Scalars['String']['input']>;
251252
startDate: Scalars['DateTime']['input'];
252253
};
253254

@@ -456,6 +457,12 @@ export type ListeningAchievement = Achievement & {
456457
userHasListened: Array<Track>;
457458
};
458459

460+
export type MarkdownText = {
461+
__typename?: 'MarkdownText';
462+
html: Scalars['String']['output'];
463+
markdown: Scalars['String']['output'];
464+
};
465+
459466
export type Mutation = {
460467
__typename?: 'Mutation';
461468
_empty?: Maybe<Scalars['Boolean']['output']>;
@@ -919,6 +926,7 @@ export type Project = {
919926
leaderboard: LeaderboardConnection;
920927
myTeam?: Maybe<Team>;
921928
name: Scalars['String']['output'];
929+
rules?: Maybe<MarkdownText>;
922930
startDate: Scalars['DateTime']['output'];
923931
streaks: Array<Streak>;
924932
teams: Array<Team>;
@@ -1461,6 +1469,7 @@ export type UpdateProjectInput = {
14611469
description?: InputMaybe<Scalars['String']['input']>;
14621470
endDate?: InputMaybe<Scalars['DateTime']['input']>;
14631471
name?: InputMaybe<Scalars['String']['input']>;
1472+
rules?: InputMaybe<Scalars['String']['input']>;
14641473
startDate?: InputMaybe<Scalars['DateTime']['input']>;
14651474
};
14661475

@@ -1554,6 +1563,11 @@ export type UserRole = {
15541563
user: User;
15551564
};
15561565

1566+
export type ProjectRulesQueryVariables = Exact<{ [key: string]: never; }>;
1567+
1568+
1569+
export type ProjectRulesQuery = { __typename?: 'Query', myCurrentProject: { __typename?: 'Project', rules?: { __typename?: 'MarkdownText', markdown: string, html: string } | null } };
1570+
15571571
export type PointHistoryQueryVariables = Exact<{
15581572
first?: InputMaybe<Scalars['Int']['input']>;
15591573
}>;
@@ -1948,6 +1962,20 @@ export type ProfilePageQuery = { __typename?: 'Query', me: { __typename?: 'User'
19481962
>, leaderboard: { __typename?: 'LeaderboardConnection', me?: { __typename?: 'LeaderboardEntry', score: number, rank?: number | null } | null } } };
19491963

19501964

1965+
export const ProjectRulesDocument = gql`
1966+
query ProjectRules {
1967+
myCurrentProject {
1968+
rules {
1969+
markdown
1970+
html
1971+
}
1972+
}
1973+
}
1974+
`;
1975+
1976+
export function useProjectRulesQuery(options?: Omit<Urql.UseQueryArgs<never, ProjectRulesQueryVariables | undefined>, 'query'>) {
1977+
return Urql.useQuery<ProjectRulesQuery, ProjectRulesQueryVariables | undefined>({ query: ProjectRulesDocument, variables: undefined, ...options });
1978+
};
19511979
export const PointHistoryDocument = gql`
19521980
query PointHistory($first: Int) {
19531981
myCurrentProject {

frontend/app/components/profile/ProfileGetPoints.vue

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
<script setup lang="ts"></script>
1+
<script setup lang="ts">
2+
gql(`
3+
query ProjectRules {
4+
myCurrentProject {
5+
rules {
6+
markdown
7+
html
8+
}
9+
}
10+
}
11+
`)
12+
13+
const { isAuthReady } = useAuthReady()
14+
const { data, fetching, error } = useProjectRulesQuery({
15+
pause: computed(() => !isAuthReady.value),
16+
})
17+
</script>
218

319
<template>
420
<UModal
@@ -13,7 +29,38 @@
1329
<template #action>
1430
<DesignIconButton icon="lucide:x" @click="close" />
1531
</template>
32+
33+
<LoadingState v-if="fetching" />
34+
<ErrorState v-else-if="error" :error />
35+
<div
36+
v-else-if="data?.myCurrentProject.rules"
37+
id="project-rules"
38+
class="p-default"
39+
v-html="data.myCurrentProject.rules.html"
40+
/>
1641
</PageLayout>
1742
</template>
1843
</UModal>
1944
</template>
45+
46+
<style>
47+
#project-rules h1,
48+
#project-rules h2,
49+
#project-rules h3 {
50+
font-size: var(--font-size-title);
51+
line-height: var(--line-height-title);
52+
font-weight: var(--font-weight-title);
53+
letter-spacing: var(--letter-spacing-title);
54+
color: var(--color-text-default);
55+
margin-bottom: 4px;
56+
margin-top: 16px;
57+
}
58+
59+
#project-rules p {
60+
font-size: var(--font-size-paragraph);
61+
line-height: var(--line-height-paragraph);
62+
font-weight: var(--font-weight-paragraph);
63+
letter-spacing: var(--letter-spacing-paragraph);
64+
color: var(--color-text-default);
65+
}
66+
</style>

0 commit comments

Comments
 (0)