Skip to content

Commit

Permalink
refactor: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
HereEast committed Jan 28, 2025
1 parent 7061d93 commit 6aa2a59
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
8 changes: 2 additions & 6 deletions src/api-client/answers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export async function submitAnswers(formData: IFormDataProps[]) {
}

// GET BY SLUG
export async function getAnswersBySlug(
slug: string,
): Promise<IAnswerResult | null> {
export async function getAnswersBySlug(slug: string) {
try {
const response = await axios.get<IAnswerResult>(`/api/answers/${slug}`);

Expand All @@ -63,9 +61,7 @@ export async function getAnswersBySlug(
}

// GET BY SLUG ARRAY
export async function getAnswersBySlugArray(
slugs: string[],
): Promise<IAnswerResult[]> {
export async function getAnswersBySlugArray(slugs: string[]) {
if (!slugs.length) {
return [];
}
Expand Down
10 changes: 4 additions & 6 deletions src/api-client/people.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import axios, { AxiosResponse } from "axios";
import axios from "axios";

import { IPerson } from "~/models/Person";

// GET BY SLUG
export async function getPerson(slug: string): Promise<IPerson | null> {
export async function getPerson(slug: string) {
try {
const response: AxiosResponse<IPerson> = await axios.get(
`/api/people/${slug}`,
);
const response = await axios.get<IPerson>(`/api/people/${slug}`);

const data = response.data;

Expand All @@ -24,7 +22,7 @@ export async function getPerson(slug: string): Promise<IPerson | null> {
// GET ALL
export async function getPeople() {
try {
const response: AxiosResponse<IPerson[]> = await axios.get(`/api/people`);
const response = await axios.get<IPerson[]>(`/api/people`);

const data = response.data;

Expand Down
5 changes: 2 additions & 3 deletions src/api-client/questions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import axios, { AxiosResponse } from "axios";
import axios from "axios";

import { IQuestion } from "~/models/Question";

// GET ALL
export async function getQuestions() {
try {
const response: AxiosResponse<IQuestion[] | undefined> =
await axios.get(`/api/questions`);
const response = await axios.get<IQuestion[]>(`/api/questions`);

const data = response.data;

Expand Down
4 changes: 3 additions & 1 deletion src/api-client/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import axios from "axios";

import { ISubscription } from "~/models/Subscription";

export type SubscriptionProps = Pick<ISubscription, "email">;
interface SubscriptionProps {
email: string;
}

// CREATE SUBSCRIPTION
export async function createSubscription({ email }: SubscriptionProps) {
Expand Down
2 changes: 0 additions & 2 deletions src/app/api/names/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export async function POST(req: Request) {
try {
await connectDB();

// Check if exists and add counts.

const newName: IName = new Name({ name, link });
await newName.save();

Expand Down
3 changes: 2 additions & 1 deletion src/components/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ParsedParagraph } from "./ParsedParagraph";

import { IAnswerResult } from "~/api-client/answers";
import { IQuestion } from "~/models/Question";

interface ContentProps {
data: IAnswerResult;
Expand All @@ -15,7 +16,7 @@ export function Content({ data }: ContentProps) {

return (
<div key={index} className="space-y-5 rounded-3xl bg-white p-8">
<Question>{question.body}</Question>
<Question>{(question as IQuestion).body}</Question>
<Answer>{item.answer}</Answer>
</div>
);
Expand Down

0 comments on commit 6aa2a59

Please sign in to comment.