Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…killVista-frontend into feature/delete-button
  • Loading branch information
KaustubhTrivedi committed Dec 4, 2023
2 parents 6bd3a1d + 97efaf3 commit e377a0e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:alpine as BUILD_IMAGE
FROM node:latest as BUILD_IMAGE

WORKDIR /app

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"react": "latest",
"react-dom": "latest",
"react-redux": "^8.1.3",
"sharp": "^0.33.0",
"tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.7",
"yup": "^1.3.2"
Expand Down
1 change: 1 addition & 0 deletions src/components/apis/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function apiRequest({ method, path, body, header }: apiRequesProps)
} else if (method === 'DELETE') {
res = await customAxios.delete(path, body)
}
console.log(res)
return { status: res?.status || res?.data?.status, message: res?.data }
} catch (error) {
if (axios.isAxiosError(error)) {
Expand Down
54 changes: 29 additions & 25 deletions src/components/user-dashboard/DataCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
import PlaceholderImage from '../../../public/placeholder_services.png'
import { TUserDashboardTable } from './columns'
import { Button } from '../ui/button'
import { useSelector } from 'react-redux'
import { selectAuthState } from '@/store/authSlice'

interface IProps {
data: TUserDashboardTable[]
Expand All @@ -27,7 +29,7 @@ export default function DataCards({
handleClickInfoForChat,
handleDeleteService,
}: IProps) {
console.log(userType)
const authState = useSelector(selectAuthState)
return (
<div className="grid 2xl:grid-cols-4 xl:grid-cols-3 lg:grid-cols-2 md:grid-cols-2 gap-7">
{data?.map((service: TUserDashboardTable, Index: number) => (
Expand All @@ -50,11 +52,27 @@ export default function DataCards({
<li>Pricing: {service?.pricing}</li>
</ul>
</CardContent>
<CardFooter>
<div>
{userType === 'service_provider' ? (
<>
<div className="flex space-x-5">
{authState && (
<CardFooter>
<div>
{userType === 'service_provider' ? (
<>
<div className="flex space-x-5">
<Button
onClick={() => {
clickChat()
handleClickInfoForChat(service)
}}
>
Contact
</Button>
<Button onClick={handleDeleteService(service?.service_id)}>
Delete Service
</Button>
</div>
</>
) : (
<>
<Button
onClick={() => {
clickChat()
Expand All @@ -63,25 +81,11 @@ export default function DataCards({
>
Contact
</Button>
<Button onClick={handleDeleteService(service?.service_id)}>
Delete Service
</Button>
</div>
</>
) : (
<>
<Button
onClick={() => {
clickChat()
handleClickInfoForChat(service)
}}
>
Contact
</Button>
</>
)}
</div>
</CardFooter>
</>
)}
</div>
</CardFooter>
)}
</Card>
))}
</div>
Expand Down
41 changes: 22 additions & 19 deletions src/components/user-dashboard/chatbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Chat, selectChatListState, setChatListState } from '@/store/chatSlilce'
import { selectUserId, selectUserType } from '@/store/userSlice'
import { ChatUserList } from './chatUserList'
import { TUserDashboardTable } from './columns'
import { selectAuthState } from '@/store/authSlice'

export interface ChatBoxProps {
handleChatBox: () => void
Expand All @@ -16,6 +17,7 @@ export interface ChatBoxProps {
const ChatBox = ({ handleChatBox, contactInfo }: ChatBoxProps) => {
const chatlist = useSelector(selectChatListState)
const userType = useSelector(selectUserType)
const authState = useSelector(selectAuthState)

const userId = useSelector(selectUserId)
const dispatch = useDispatch()
Expand All @@ -36,7 +38,7 @@ const ChatBox = ({ handleChatBox, contactInfo }: ChatBoxProps) => {
Number(item.user_id) === userId
: Number(item.provider_id) === userId,
)

console.log(messages)
dispatch(setChatListState(messages))
if (userType === 'service_provider') {
const reverseArray = res.message.reverse()
Expand All @@ -60,7 +62,6 @@ const ChatBox = ({ handleChatBox, contactInfo }: ChatBoxProps) => {
const handleMessageChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setMessage(event.target.value)
}

const handlePressSend = () => {
const chatform = {
user_id: userType === 'user' ? userId : userIdFromList,
Expand Down Expand Up @@ -143,23 +144,25 @@ const ChatBox = ({ handleChatBox, contactInfo }: ChatBoxProps) => {
})}
</div>
</div>
<div className="py-2 insent-x-0 bottom-0 lg:flex lg:justify-between items-stretch">
<input
type="text"
placeholder="Text Message"
value={message}
onChange={handleMessageChange}
className="px-3 py-3 w-full "
/>
<Button
className="ml-2 bg-slate-300 rounded-md text-slate-500 self-center "
onClick={() => {
message && handlePressSend()
}}
>
Send
</Button>
</div>
{authState && (
<div className="py-2 insent-x-0 bottom-0 lg:flex lg:justify-between items-stretch">
<input
type="text"
placeholder="Text Message"
value={message}
onChange={handleMessageChange}
className="px-3 py-3 w-full "
/>
<Button
className="ml-2 bg-slate-300 rounded-md text-slate-500 self-center "
onClick={() => {
message && handlePressSend()
}}
>
Send
</Button>
</div>
)}
</>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/provider-registration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const Index: FC<IndexProps> = () => {
date_created: new Date(),
},
}).then(res => {
if (res?.status === 200) {
if (res?.status === 201) {
const service_id = res?.message
if (profileImg) {
apiRequest({
Expand Down

0 comments on commit e377a0e

Please sign in to comment.