submit form contactus and start api projects

This commit is contained in:
zahravaziri
2025-06-09 17:14:44 +03:30
parent 11446b98e4
commit 3e9143f32c
18 changed files with 515 additions and 35 deletions
+18
View File
@@ -0,0 +1,18 @@
import api from "@/lib/axios";
interface payload {
first_name: string,
last_name: string,
email: string,
phone: string,
message: string,
}
export async function setContact(payload:payload) {
return api
.post('/contact', payload)
.then(({ data }) => {
return Promise.resolve();
})
.catch((error) => Promise.reject(error));
}
+40
View File
@@ -0,0 +1,40 @@
'use server';
import { IProjectCardProps } from '@/components/pages/project/project';
import api from '@/lib/axios';
import { IResponse } from '@/models/response';
import { cookies } from 'next/headers';
export async function getProjectCategories() {
const cookiesStore = await cookies();
return api
.get('/project_categories', {
headers: {
Cookie: cookiesStore.toString(),
},
})
.then(({ data }) => {
return Promise.resolve(data.data);
})
.catch((error) => Promise.reject(error));
}
export async function getProjects(
categoryId: string,
page = 1,
): Promise<IResponse<IProjectCardProps[]>> {
const cookiesStore = await cookies();
return api
.get(`/project_categories/${categoryId}/projects`, {
headers: {
Cookie: cookiesStore.toString(),
},
params: { page },
})
.then(({ data }) => {
return Promise.resolve(data);
})
.catch((error) => Promise.reject(error));
}