Skip to content

Commit

Permalink
🐛 Corrigindo os três bugs que ja haviam sido corrigidos, mas que se p…
Browse files Browse the repository at this point in the history
…erderam
  • Loading branch information
rausth committed Jul 17, 2023
1 parent c0b4fda commit 6059842
Show file tree
Hide file tree
Showing 8 changed files with 11,220 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import ufes.marktiabackend.filters.servicesfilter.ServicesFilterSpecification;
import ufes.marktiabackend.repositories.ServiceRepository;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -96,6 +97,7 @@ public ServiceResponseDTO create(@Valid ServiceRequestDTO serviceRequestDTO) {
.description(serviceRequestDTO.getDescription())
.price(serviceRequestDTO.getPrice())
.picpayUser(serviceRequestDTO.getPicpayUser())
.schedulings(new ArrayList<>())
.build();

ufes.marktiabackend.entities.Service savedService = serviceRepository.save(service);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import ufes.marktiabackend.repositories.UserRepository;
import ufes.marktiabackend.services.FederationService;

import java.util.Optional;

@Service
@RequiredArgsConstructor
public class AuthService {
Expand Down Expand Up @@ -62,8 +64,11 @@ public AuthResponseDTO register(RegisterRequestDTO registerRequestDTO) {
}

public AuthResponseDTO authenticate(AuthRequestDTO authRequestDTO) {
User user = userRepository.findByEmail(authRequestDTO.getEmail())
.orElseThrow(() -> new EntityNotFoundException("Usuário com as credenciais fornecidas não encontrado."));
Optional<User> user = userRepository.findByEmail(authRequestDTO.getEmail());

if (user.isEmpty() || !passwordEncoder.matches(authRequestDTO.getPassword(), user.get().getPassword())) {
throw new EntityNotFoundException("Usuário com as credenciais fornecidas não encontrado.");
}

try {
authenticationManager.authenticate(
Expand All @@ -76,10 +81,10 @@ public AuthResponseDTO authenticate(AuthRequestDTO authRequestDTO) {
}

return AuthResponseDTO.builder()
.id(user.getId().toString())
.name(user.getName())
.userRole(user.getUserRole().getValue())
.token(jwtService.generateToken(user))
.id(user.get().getId().toString())
.name(user.get().getName())
.userRole(user.get().getUserRole().getValue())
.token(jwtService.generateToken(user.get()))
.build();
}
}
5,571 changes: 5,571 additions & 0 deletions marktia-backend/src/main/resources/dadosDB/municipios_utf-8.csv

Large diffs are not rendered by default.

5,571 changes: 5,571 additions & 0 deletions marktia-db/municipios_utf-8.csv

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions marktia-frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
59 changes: 59 additions & 0 deletions marktia-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM node:18-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN yarn build

# If using npm comment out above and use below instead
# RUN npm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD ["node", "server.js"]
2 changes: 1 addition & 1 deletion marktia-frontend/components/common/service_details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ServiceDetailsProps = {

export default function ServiceDetails({ type, description, price, picpayUser }: ServiceDetailsProps) {
return (
<div className="p-5">
<div>
<div className="py-2"><span>Tipo: {type}</span></div>
<div className="py-2"><span>Descrição: {description}</span></div>
<div className="py-2"><span>Preço: <FormattedMoney money={price} /></span></div>
Expand Down
2 changes: 1 addition & 1 deletion marktia-frontend/controllers/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const getURLParams = (servicesFilter: ServicesFilter) => {

url += `providerId=${servicesFilter.providerId ? servicesFilter.providerId : ""}&`;
url += `name=${servicesFilter.name ? servicesFilter.name : ""}&`;
url += `type=${servicesFilter.type ? servicesFilter.type : ""}&`;
url += `type=${(servicesFilter.type !== null) ? servicesFilter.type : ""}&`;

url += `stateId=${servicesFilter.federation?.stateId ? servicesFilter.federation.stateId : ""}&`;
url += `regionId=${servicesFilter.federation?.regionId ? servicesFilter.federation.regionId : ""}&`;
Expand Down

0 comments on commit 6059842

Please sign in to comment.