Skip to content

Commit

Permalink
Merge pull request #942 from hngprojects/layobright
Browse files Browse the repository at this point in the history
Layobright
  • Loading branch information
Ravencodess authored Aug 8, 2024
2 parents 986e8cb + 91835b0 commit 476703b
Show file tree
Hide file tree
Showing 13 changed files with 1,113 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"source.fixAll.eslint": "always"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "vscode.typescript-language-features"
}
}
100 changes: 100 additions & 0 deletions src/actions/faq.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
"use server";

import axios from "axios";

import { auth } from "~/lib/auth";

const apiUrl = process.env.API_URL;

interface Properties {
question: string;
answer: string;
category: string;
}

interface UpdateProperties {
question: string;
answer: string;
category: string;
}

export const CreateFaqs = async (payload: Properties) => {
//
try {
const session = await auth();

const response = await axios.post(`${apiUrl}/api/v1/faqs`, payload, {
headers: {
Authorization: `Bearer ${session?.access_token}`,
},
});

return {
data: response.data,
status: response.status,
};
} catch (error) {
return axios.isAxiosError(error) && error.response
? {
error: error.response.data.message || "Unable to Create FAQS",
status: error.response.status,
}
: {
error: "An unexpected error occurred.",
};
}
};

export const UpdateFaqs = async (payload: UpdateProperties, id: string) => {
//
try {
const session = await auth();

const response = await axios.put(`${apiUrl}/api/v1/faqs/${id}`, payload, {
headers: {
Authorization: `Bearer ${session?.access_token}`,
},
});

return {
data: response.data,
status: response.status,
};
} catch (error) {
return axios.isAxiosError(error) && error.response
? {
error: error.response.data.message || "Unable to Create FAQS",
status: error.response.status,
}
: {
error: "An unexpected error occurred.",
};
}
};

export const DeleteFaqs = async (id: string) => {
//
try {
const session = await auth();

const response = await axios.delete(`${apiUrl}/api/v1/faqs/${id}`, {
headers: {
Authorization: `Bearer ${session?.access_token}`,
},
});

return {
message: response.data.message,
status: response.status,
};
} catch (error) {
return axios.isAxiosError(error) && error.response
? {
error: error.response.data.message || "Unable to Create FAQS",
status: error.response.status,
}
: {
error: "An unexpected error occurred.",
};
}
};
75 changes: 0 additions & 75 deletions src/app/(auth-routes)/login/magic-link/page.test.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const sideItems = [
icon: List,
id: "squeeze",
},
{
route: "Faq Page",
link: "/dashboard/admin/faqs",
icon: List,
id: "faqs",
},
{
route: "Waitlist Page",
link: "/dashboard/admin/waitlist-page",
Expand Down
Loading

0 comments on commit 476703b

Please sign in to comment.